Move ARG to running container instead of build container

This commit is contained in:
Uku Taht 2022-05-27 15:24:11 +03:00
parent f0e0062dc1
commit b667d65d52
4 changed files with 23 additions and 20 deletions

View File

@ -42,6 +42,8 @@ jobs:
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
build-arg: BUILD_METADATA=${{ steps.meta.outputs.json }} build-args: |
BUILD_METADATA=${{ steps.meta.outputs.json }}
- name: Image digest - name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }} run: echo ${{ steps.docker_build.outputs.digest }}

View File

@ -5,33 +5,31 @@
FROM hexpm/elixir:1.13.4-erlang-24.3.3-alpine-3.15.3 as buildcontainer FROM hexpm/elixir:1.13.4-erlang-24.3.3-alpine-3.15.3 as buildcontainer
# preparation # preparation
ARG APP_VER=0.0.1
ENV MIX_ENV=prod ENV MIX_ENV=prod
ENV NODE_ENV=production ENV NODE_ENV=production
ENV APP_VERSION=$APP_VER
RUN mkdir /app RUN mkdir /app
WORKDIR /app WORKDIR /app
# install build dependencies # install build dependencies
RUN apk add --no-cache git nodejs yarn python3 npm ca-certificates wget gnupg make erlang gcc libc-dev && \ RUN apk add --no-cache git nodejs yarn python3 npm ca-certificates wget gnupg make erlang gcc libc-dev && \
npm install npm@latest -g && \ npm install npm@latest -g && \
npm install -g webpack npm install -g webpack
RUN wget https://s3.eu-central-1.wasabisys.com/plausible-application/geonames.csv -q RUN wget https://s3.eu-central-1.wasabisys.com/plausible-application/geonames.csv -q
COPY mix.exs ./ COPY mix.exs ./
COPY mix.lock ./ COPY mix.lock ./
RUN mix local.hex --force && \ RUN mix local.hex --force && \
mix local.rebar --force && \ mix local.rebar --force && \
mix deps.get --only prod && \ mix deps.get --only prod && \
mix deps.compile mix deps.compile
COPY assets/package.json assets/package-lock.json ./assets/ COPY assets/package.json assets/package-lock.json ./assets/
COPY tracker/package.json tracker/package-lock.json ./tracker/ COPY tracker/package.json tracker/package-lock.json ./tracker/
RUN npm install --prefix ./assets && \ RUN npm install --prefix ./assets && \
npm install --prefix ./tracker npm install --prefix ./tracker
COPY assets ./assets COPY assets ./assets
COPY tracker ./tracker COPY tracker ./tracker
@ -40,12 +38,12 @@ COPY priv ./priv
COPY lib ./lib COPY lib ./lib
RUN npm run deploy --prefix ./assets && \ RUN npm run deploy --prefix ./assets && \
npm run deploy --prefix ./tracker && \ npm run deploy --prefix ./tracker && \
mix phx.digest priv/static && \ mix phx.digest priv/static && \
mix download_country_database && \ mix download_country_database && \
# https://hexdocs.pm/sentry/Sentry.Sources.html#module-source-code-storage # https://hexdocs.pm/sentry/Sentry.Sources.html#module-source-code-storage
mix sentry_recompile && \ mix sentry_recompile && \
mv geonames.csv ./priv/geonames.csv mv geonames.csv ./priv/geonames.csv
WORKDIR /app WORKDIR /app
COPY rel rel COPY rel rel
@ -54,6 +52,9 @@ RUN mix release plausible
# Main Docker Image # Main Docker Image
FROM alpine:3.15.3 FROM alpine:3.15.3
LABEL maintainer="tckb <tckb@tgrthi.me>" LABEL maintainer="tckb <tckb@tgrthi.me>"
ARG BUILD_METADATA={}
ENV BUILD_METADATA=$BUILD_METADATA
ENV LANG=C.UTF-8 ENV LANG=C.UTF-8
RUN apk upgrade --no-cache RUN apk upgrade --no-cache
@ -63,7 +64,7 @@ RUN apk add --no-cache openssl ncurses libstdc++ libgcc
COPY .gitlab/build-scripts/docker-entrypoint.sh /entrypoint.sh COPY .gitlab/build-scripts/docker-entrypoint.sh /entrypoint.sh
RUN chmod a+x /entrypoint.sh && \ RUN chmod a+x /entrypoint.sh && \
adduser -h /app -u 1000 -s /bin/sh -D plausibleuser adduser -h /app -u 1000 -s /bin/sh -D plausibleuser
COPY --from=buildcontainer /app/_build/prod/rel/plausible /app COPY --from=buildcontainer /app/_build/prod/rel/plausible /app
RUN chown -R plausibleuser:plausibleuser /app RUN chown -R plausibleuser:plausibleuser /app

View File

@ -1,6 +1,6 @@
BASE_URL=http://localhost:8000 BASE_URL=http://localhost:8000
DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5432/plausible_dev DATABASE_URL=postgres://postgres:postgres@host.docker.internal:5432/plausible_dev
CLICKHOUSE_DATABASE_URL=http://127.0.0.1:8123/plausible_events_db CLICKHOUSE_DATABASE_URL=http://host.docker.internal:8123/plausible_events_db
SECRET_KEY_BASE=/njrhntbycvastyvtk1zycwfm981vpo/0xrvwjjvemdakc/vsvbrevlwsc6u8rcg SECRET_KEY_BASE=/njrhntbycvastyvtk1zycwfm981vpo/0xrvwjjvemdakc/vsvbrevlwsc6u8rcg
ENVIRONMENT=dev ENVIRONMENT=dev
MAILER_ADAPTER=Bamboo.LocalAdapter MAILER_ADAPTER=Bamboo.LocalAdapter

View File

@ -66,7 +66,7 @@ defmodule PlausibleWeb.Api.ExternalController do
_ -> %{} _ -> %{}
end end
build_info = System.get_env("BUILD_METADATA", "{}") |> Jason.decode!() build_metadata = System.get_env("BUILD_METADATA", "{}") |> Jason.decode!()
geo_database = geo_database =
case Geolix.metadata([:geolocation]) do case Geolix.metadata([:geolocation]) do
@ -80,7 +80,7 @@ defmodule PlausibleWeb.Api.ExternalController do
info = info =
Map.merge(version, %{ Map.merge(version, %{
geo_database: geo_database, geo_database: geo_database,
build: build_info build: build_metadata
}) })
json(conn, info) json(conn, info)