From bd7deb563122224e6e8acefe4fb4dcb22bacb8dc Mon Sep 17 00:00:00 2001 From: hq1 Date: Thu, 30 Nov 2023 12:39:34 +0100 Subject: [PATCH] Update dockerfile for build options (#3567) * Update dockerfile for build options * Start permanent on small * Default to small * Default to small fixup --- .github/workflows/build-private-images.yml | 1 + .github/workflows/build-public-images.yml | 1 + Dockerfile | 8 ++++++-- mix.exs | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-private-images.yml b/.github/workflows/build-private-images.yml index d7202a68f..67f2d0b42 100644 --- a/.github/workflows/build-private-images.yml +++ b/.github/workflows/build-private-images.yml @@ -47,6 +47,7 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max build-args: | + MIX_ENV=prod BUILD_METADATA=${{ steps.meta.outputs.json }} - name: Image digest diff --git a/.github/workflows/build-public-images.yml b/.github/workflows/build-public-images.yml index 6a98175e3..edb215e5b 100644 --- a/.github/workflows/build-public-images.yml +++ b/.github/workflows/build-public-images.yml @@ -46,6 +46,7 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max build-args: | + MIX_ENV=small BUILD_METADATA=${{ steps.meta.outputs.json }} ERL_FLAGS=+JPperf true diff --git a/Dockerfile b/Dockerfile index 3c42ca473..cbf1b538a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,10 @@ #### Builder FROM hexpm/elixir:1.15.7-erlang-26.1.2-alpine-3.18.4 as buildcontainer +ARG MIX_ENV=small + # preparation -ENV MIX_ENV=prod +ENV MIX_ENV=$MIX_ENV ENV NODE_ENV=production ENV NODE_OPTIONS=--openssl-legacy-provider @@ -59,6 +61,8 @@ LABEL maintainer="plausible.io " ARG BUILD_METADATA={} ENV BUILD_METADATA=$BUILD_METADATA ENV LANG=C.UTF-8 +ARG MIX_ENV=small +ENV MIX_ENV=$MIX_ENV RUN apk upgrade --no-cache @@ -69,7 +73,7 @@ COPY ./rel/docker-entrypoint.sh /entrypoint.sh RUN chmod a+x /entrypoint.sh && \ adduser -h /app -u 1000 -s /bin/sh -D plausibleuser -COPY --from=buildcontainer /app/_build/prod/rel/plausible /app +COPY --from=buildcontainer /app/_build/${MIX_ENV}/rel/plausible /app RUN chown -R plausibleuser:plausibleuser /app USER plausibleuser WORKDIR /app diff --git a/mix.exs b/mix.exs index 96cfb8426..f7f1b9532 100644 --- a/mix.exs +++ b/mix.exs @@ -10,7 +10,7 @@ defmodule Plausible.MixProject do version: System.get_env("APP_VERSION", "0.0.1"), elixir: "~> 1.14", elixirc_paths: elixirc_paths(Mix.env()), - start_permanent: Mix.env() == :prod, + start_permanent: Mix.env() in [:prod, :small], aliases: aliases(), deps: deps(), test_coverage: [