10
10
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
11
11
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20210902-slim - for the release image
12
12
# - https://pkgs.org/ - resource for finding needed packages
13
- # - Ex: hexpm/elixir:1.12 .0-erlang-24.0.1 -debian-bullseye-20210902-slim
13
+ # - Ex: hexpm/elixir:1.14 .0-erlang-24.3.4 -debian-bullseye-20210902-slim
14
14
#
15
- ARG BUILDER_IMAGE="hexpm/elixir:1.12.0-erlang-24.0.1-debian-bullseye-20210902-slim"
16
- ARG RUNNER_IMAGE="debian:bullseye-20210902-slim"
15
+ ARG ELIXIR_VERSION=1.14.0
16
+ ARG OTP_VERSION=24.3.4
17
+ ARG DEBIAN_VERSION=bullseye-20210902-slim
18
+
19
+ ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
20
+ ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
17
21
18
22
FROM ${BUILDER_IMAGE} as builder
19
23
@@ -22,16 +26,14 @@ RUN apt-get update -y && apt-get install -y build-essential git \
22
26
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
23
27
24
28
# prepare build dir
25
- # WORKDIR /app
26
- ENV MIX_ENV="dev"
29
+ WORKDIR /app
27
30
28
31
# install hex + rebar
29
32
RUN mix local.hex --force && \
30
33
mix local.rebar --force
31
34
32
35
# set build ENV
33
- # ENV MIX_ENV="prod"
34
- ENV MIX_ENV="dev"
36
+ ENV MIX_ENV="prod"
35
37
36
38
# install mix dependencies
37
39
COPY mix.exs mix.lock ./
@@ -46,9 +48,6 @@ RUN mix deps.compile
46
48
47
49
COPY priv priv
48
50
49
- # Compile the release
50
- COPY lib lib
51
-
52
51
# note: if your project uses a tool like https://purgecss.com/,
53
52
# which customizes asset compilation based on what it finds in
54
53
# your Elixir templates, you will need to move the asset compilation
@@ -58,6 +57,9 @@ COPY assets assets
58
57
# compile assets
59
58
RUN mix assets.deploy
60
59
60
+ # Compile the release
61
+ COPY lib lib
62
+
61
63
RUN mix compile
62
64
63
65
# Changes to config/runtime.exs don't require recompiling the code
@@ -83,13 +85,17 @@ ENV LC_ALL en_US.UTF-8
83
85
WORKDIR "/app"
84
86
RUN chown nobody /app
85
87
88
+ # set runner ENV
89
+ ENV MIX_ENV="prod"
90
+
86
91
# Only copy the final release from the build stage
87
- COPY --from=builder --chown=nobody:root /app/_build/prod /rel/live_beats ./
92
+ COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV} /rel/my_app ./
88
93
89
94
USER nobody
90
95
91
- # Set the runtime ENV
92
- ENV ECTO_IPV6="true"
93
- ENV ERL_AFLAGS="-proto_dist inet6_tcp"
96
+ # If using an environment that doesn't automatically reap zombie processes, it is
97
+ # advised to add an init process such as tini via `apt-get install`
98
+ # above and adding an entrypoint. See https://github.com/krallin/tini for details
99
+ # ENTRYPOINT ["/tini", "--"]
94
100
95
101
CMD /app/bin/server
0 commit comments