Skip to content

Commit caa4309

Browse files
committedFeb 20, 2024
Switch to Dockerfile from hexdocs.pm
1 parent cae0e94 commit caa4309

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed
 

‎Dockerfile

+20-14
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
1111
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20210902-slim - for the release image
1212
# - 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
1414
#
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}"
1721

1822
FROM ${BUILDER_IMAGE} as builder
1923

@@ -22,16 +26,14 @@ RUN apt-get update -y && apt-get install -y build-essential git \
2226
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
2327

2428
# prepare build dir
25-
# WORKDIR /app
26-
ENV MIX_ENV="dev"
29+
WORKDIR /app
2730

2831
# install hex + rebar
2932
RUN mix local.hex --force && \
3033
mix local.rebar --force
3134

3235
# set build ENV
33-
# ENV MIX_ENV="prod"
34-
ENV MIX_ENV="dev"
36+
ENV MIX_ENV="prod"
3537

3638
# install mix dependencies
3739
COPY mix.exs mix.lock ./
@@ -46,9 +48,6 @@ RUN mix deps.compile
4648

4749
COPY priv priv
4850

49-
# Compile the release
50-
COPY lib lib
51-
5251
# note: if your project uses a tool like https://purgecss.com/,
5352
# which customizes asset compilation based on what it finds in
5453
# your Elixir templates, you will need to move the asset compilation
@@ -58,6 +57,9 @@ COPY assets assets
5857
# compile assets
5958
RUN mix assets.deploy
6059

60+
# Compile the release
61+
COPY lib lib
62+
6163
RUN mix compile
6264

6365
# Changes to config/runtime.exs don't require recompiling the code
@@ -83,13 +85,17 @@ ENV LC_ALL en_US.UTF-8
8385
WORKDIR "/app"
8486
RUN chown nobody /app
8587

88+
# set runner ENV
89+
ENV MIX_ENV="prod"
90+
8691
# 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 ./
8893

8994
USER nobody
9095

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", "--"]
94100

95101
CMD /app/bin/server

0 commit comments

Comments
 (0)
Please sign in to comment.