Browse Source

refactor: pull erlang, elixir, and alphine versions into args (#7762)

Chris Garvis 2 years ago
parent
commit
83881023e1
1 changed files with 14 additions and 9 deletions
  1. 14 9
      frameworks/Elixir/phoenix/phoenix.dockerfile

+ 14 - 9
frameworks/Elixir/phoenix/phoenix.dockerfile

@@ -1,7 +1,11 @@
-###############
-# Build stage #
-###############
-FROM elixir:1.14.0 as build
+ARG ELIXIR="1.14.2"
+ARG ERLANG="25.1.2"
+ARG ALPINE="3.16.2"
+
+ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR}-erlang-${ERLANG}-alpine-${ALPINE}"
+ARG RUNNER_IMAGE="alpine:${ALPINE}"
+
+FROM ${BUILDER_IMAGE} AS builder
 
 
 ARG MIX_ENV="prod"
 ARG MIX_ENV="prod"
 
 
@@ -21,12 +25,13 @@ COPY lib ./lib
 COPY rel ./rel
 COPY rel ./rel
 RUN mix release --force --path /export
 RUN mix release --force --path /export
 
 
-####################
-# Deployment Stage #
-####################
-FROM erlang:25.1
+# start a new build stage so that the final image will only contain
+# the compiled release and other runtime necessities
+FROM ${RUNNER_IMAGE}
+
+RUN apk add --no-cache libstdc++ openssl ncurses-libs
 
 
-COPY --from=build /export /opt
+COPY --from=builder /export /opt
 
 
 EXPOSE 8080
 EXPOSE 8080