Dockerize an Elixir escript (or mix task)

Thanks a lot for the support :smiley:

You’re totally right, but the tricky part is also that I want to build the escript directly inside the container to make it totally dependent to it so that I can share just the built image.

Right now I’ve managed to accomplish something with the following Dockerfile but I’m sincerely not sure about the COPY . .

# Dockerfile

FROM elixir:1.7.3-alpine

# install build dependencies

RUN apk add --update git

# prepare build dir

RUN mkdir /app

WORKDIR /app

# install hex + rebar

RUN mix local.hex --force && \

mix local.rebar --force

# set build ENV

ENV MIX_ENV=prod

# install mix dependencies

# COPY mix.exs mix.lock ./

# COPY config ./

# COPY deps ./

# COPY lib ./

COPY . .

RUN mix deps.get && \

mix escript.build

ENTRYPOINT ["./myscript"]