How to get rid of the redundancy in .drone.yml and Dockerfile

Hi,
I use drone to compile, test and publish my elixir/phoenix project. But there is redundant configuration and redundant build steps in .drone.yml and Dockerfile.
E.g. the source code will be compiled two times. First the drone step “test” compiles the code and second, the step “docker” compiles the source code again because of the Dockerfile.
Is it possible to directly publish the docker image, that was created for the drone step “test”?
Kind regards, Alain

Dockerfile:

FROM elixir:1.7

MAINTAINER "Alain Helfenstein"
LABEL maintainer "alain.helfenstein@semantiker.ch"

RUN mix local.hex --force

RUN mix local.rebar --force

COPY . .

RUN mix deps.get
RUN mix compile

drone config:

kind: pipeline
name: default
workspace:
  base: /drone

steps:
- name: u-test
  image: ubuntu
  commands:
  - pwd

- name: install
  image: elixir:1.7
  volumes:
  - name: mix
    path: /root/.mix
  commands:
  - mix local.rebar --force
  - mix local.hex --force
  - mix deps.get

- name: test
  image: elixir:1.7
  volumes:
  - name: mix
    path: /root/.mix
  commands:
  - mix test

# publish to dockerhub
- name: docker
  image: plugins/docker
  settings:
    repo: xxxx/yyyy
    username: xxxx
    password:
      from_secret: dh-pw

volumes:
- name: mix
  temp: {}