From 2ea89cb3bca6952488364f4e6b760f05c9f57fed Mon Sep 17 00:00:00 2001 From: synthia Date: Tue, 11 Apr 2023 17:49:44 -0700 Subject: [PATCH 1/2] Moves build tasks from build.sh to Dockerfile (#2223) --- Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ee6470e2..6d0eb9b28 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM elixir:1.10 AS dev RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f RUN apt -q update && \ - apt -q install -y default-mysql-client inotify-tools festival && \ + apt -q install -y default-mysql-client inotify-tools festival yarnpkg && \ apt -q install -y --no-install-recommends ffmpeg libaacs0 && \ apt -q clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* @@ -19,13 +19,16 @@ ADD mix.exs mix.lock /app/ ADD config /app/config WORKDIR /app -RUN mix deps.get --only prod +RUN mix deps.get RUN mix deps.compile ADD . /app RUN mix compile RUN mix phx.digest +RUN yarnpkg install --no-progress +RUN yarnpkg deploy + ENV PORT=80 EXPOSE 80 From 9c902e55d04397758b245d290500815a55ca0824 Mon Sep 17 00:00:00 2001 From: synthia Date: Mon, 17 Apr 2023 12:50:43 -0700 Subject: [PATCH 2/2] Multi-stage dockerfile build for #2223 --- Dockerfile | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6d0eb9b28..49244225d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,15 +4,13 @@ FROM elixir:1.10 AS dev RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f RUN apt -q update && \ - apt -q install -y default-mysql-client inotify-tools festival yarnpkg && \ + apt -q install -y default-mysql-client inotify-tools festival && \ apt -q install -y --no-install-recommends ffmpeg libaacs0 && \ apt -q clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN mix local.hex --force RUN mix local.rebar --force -FROM dev AS release - ENV MIX_ENV=prod ADD mix.exs mix.lock /app/ @@ -26,10 +24,23 @@ ADD . /app RUN mix compile RUN mix phx.digest -RUN yarnpkg install --no-progress -RUN yarnpkg deploy +FROM node:10 as js + +COPY --from=dev /deps /deps +ADD . /app +WORKDIR /app + +RUN yarn install --no-progress +RUN yarn deploy +FROM dev AS release + +COPY --from=js /app/assets /app/ + +ENV MIX_ENV=prod ENV PORT=80 + +WORKDIR /app EXPOSE 80 CMD elixir --sname server -S mix phx.server