Skip to content
This repository was archived by the owner on Jun 13, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/mix_docker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule MixDocker do
Mix.Task.run("release.init", args)
end

def build(args) do
def build(args \\ []) do
with_dockerfile @dockerfile_build, fn ->
docker :build, @dockerfile_build, image(:build), args
end
Expand Down Expand Up @@ -122,7 +122,8 @@ defmodule MixDocker do
end

defp docker(:build, dockerfile, tag, args) do
system! "docker", ["build", "-f", dockerfile, "-t", tag] ++ args ++ ["."]

system! "docker", ["build", "-f", dockerfile, "-t", tag, "--build-arg", "MIX_ENV=#{Mix.env}"] ++ args ++ ["."]
end

defp docker(:create, name, image) do
Expand Down
8 changes: 4 additions & 4 deletions priv/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM bitwalker/alpine-erlang:19.3

ENV HOME=/opt/app/ TERM=xterm
ARG MIX_ENV
ENV MIX_ENV ${MIX_ENV:-prod}

# Install Elixir and basic build dependencies
RUN \
Expand All @@ -17,14 +19,12 @@ RUN mix local.hex --force && \

WORKDIR /opt/app

ENV MIX_ENV=prod

# Cache elixir deps
RUN mkdir config
RUN mkdir config
COPY config/* config/
COPY mix.exs mix.lock ./
RUN mix do deps.get, deps.compile

COPY . .

RUN mix release --env=prod --verbose
RUN mix release --verbose --env=$MIX_ENV
5 changes: 4 additions & 1 deletion priv/Dockerfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ FROM bitwalker/alpine-erlang:19.3
RUN apk update && \
apk --no-cache --update add libgcc libstdc++ && \
rm -rf /var/cache/apk/*

ARG MIX_ENV
ENV MIX_ENV ${MIX_ENV:-prod}

EXPOSE 4000
ENV PORT=4000 MIX_ENV=prod REPLACE_OS_VARS=true SHELL=/bin/sh
ENV PORT=4000 REPLACE_OS_VARS=true SHELL=/bin/sh

ADD ${APP}.tar.gz ./
RUN chown -R default ./releases
Expand Down