Skip to content

Commit e28aebd

Browse files
committed
Update SO names; sync with debian.Dockerfile
1 parent 8e16ae2 commit e28aebd

File tree

1 file changed

+58
-35
lines changed

1 file changed

+58
-35
lines changed

deploy/distroless.Dockerfile

Lines changed: 58 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ ARG BASE_OS=debian
77
# Specify versions of Erlang, Elixir, and base OS.
88
# Choose a combination supported by https://hub.docker.com/r/hexpm/elixir/tags
99

10-
ARG ELIXIR_VER=1.16.2
11-
ARG OTP_VER=26.2.5
10+
ARG ELIXIR_VER=1.17.1
11+
ARG OTP_VER=27.0
1212

1313
# https://docker.debian.net/
1414
# https://hub.docker.com/_/debian
15-
ARG BUILD_OS_VER=bullseye-20230612-slim
16-
ARG PROD_OS_VER=bullseye-20230612-slim
15+
ARG BUILD_OS_VER=bookworm-20240612
16+
ARG PROD_OS_VER=bookworm-slim
1717

1818
# Specify snapshot explicitly to get repeatable builds, see https://snapshot.debian.org/
1919
# The tag without a snapshot (e.g., bullseye-slim) includes the latest snapshot.
@@ -68,7 +68,8 @@ ARG APP_GROUP=$APP_USER
6868
ARG APP_USER_ID=65532
6969
ARG APP_GROUP_ID=$APP_USER_ID
7070

71-
ARG LANG=C.UTF-8
71+
# ARG LANG=C.UTF-8
72+
ARG LANG=C.utf8
7273
# ARG LANG=en_US.UTF-8
7374

7475
# Elixir release env to build
@@ -152,6 +153,8 @@ FROM ${BUILD_BASE_IMAGE_NAME}:${BUILD_BASE_IMAGE_TAG} AS build-os-deps
152153
openssh-client \
153154
# Support ssl in container, as opposed to load balancer
154155
openssl \
156+
wget \
157+
zip \
155158
# Install default nodejs
156159
# nodejs \
157160
# Install default Postgres
@@ -160,7 +163,7 @@ FROM ${BUILD_BASE_IMAGE_NAME}:${BUILD_BASE_IMAGE_TAG} AS build-os-deps
160163
# $RUNTIME_PACKAGES \
161164
&& \
162165
locale-gen && \
163-
mkdir -p /etc/apt/keyrings && \
166+
mkdir -p -m 755 /etc/apt/keyrings && \
164167
# Install nodejs from nodesource.com
165168
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
166169
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
@@ -176,15 +179,21 @@ FROM ${BUILD_BASE_IMAGE_NAME}:${BUILD_BASE_IMAGE_TAG} AS build-os-deps
176179
curl -sL --ciphers ECDHE-RSA-AES128-GCM-SHA256 https://dl.yarnpkg.com/debian/pubkey.gpg -o /etc/apt/trusted.gpg.d/yarn.asc && \
177180
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
178181
printf "Package: *\nPin: release o=dl.yarnpkg.com\nPin-Priority: 500\n" | tee /etc/apt/preferences.d/yarn.pref && \
182+
# Install GitHub CLI
183+
# wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg && \
184+
# chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg && \
185+
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list && \
179186
# Install Trivy
180187
# curl -sL https://aquasecurity.github.io/trivy-repo/deb/public.key -o /etc/apt/trusted.gpg.d/trivy.asc && \
181188
# printf "deb https://aquasecurity.github.io/trivy-repo/deb %s main" "$(lsb_release -sc)" | tee -a /etc/apt/sources.list.d/trivy.list && \
182189
apt-get update -qq && \
183190
DEBIAN_FRONTEND=noninteractive \
184191
apt-get -y install -y -qq --no-install-recommends \
192+
# gh \
185193
nodejs \
186194
# trivy \
187195
yarn \
196+
# yarnpkg \
188197
&& \
189198
# Install latest Postgres from postgres.org repo
190199
# curl -sL https://www.postgresql.org/media/keys/ACCC4CF8.asc -o /etc/apt/trusted.gpg.d/postgresql-ACCC4CF8.asc && \
@@ -250,8 +259,8 @@ FROM build-os-deps AS build-deps-get
250259

251260
# Copy only the minimum files needed for deps, improving caching
252261
COPY --link config ./config
253-
COPY --link mix.exs .
254-
COPY --link mix.lock .
262+
COPY --link mix.exs ./
263+
COPY --link mix.lock ./
255264

256265
# COPY --link .env.default ./
257266

@@ -339,7 +348,7 @@ FROM build-deps-get AS prod-release
339348

340349
WORKDIR $APP_DIR
341350

342-
COPY --link .env.pro[d] .
351+
COPY --link .env.pro[d] ./
343352

344353
# Compile deps separately from application for better caching.
345354
# Doing "mix 'do' compile, assets.deploy" in a single stage is worse
@@ -353,39 +362,30 @@ FROM build-deps-get AS prod-release
353362

354363
RUN mix esbuild.install --if-missing
355364

356-
# Install JavaScript deps using yarn
365+
RUN mkdir -p ./assets
366+
367+
# Install JavaScript deps
357368
COPY --link assets/package.jso[n] assets/package.json
358369
COPY --link assets/package-lock.jso[n] assets/package-lock.json
359370
COPY --link assets/yarn.loc[k] assets/yarn.lock
371+
COPY --link assets/brunch-config.j[s] assets/brunch-config.js
372+
373+
WORKDIR ${APP_DIR}/assets
374+
375+
RUN --mount=type=cache,target=~/.npm,sharing=locked \
376+
set -exu && \
377+
corepack enable && \
378+
# yarn --cwd ./assets install --prod
379+
yarn install --prod
380+
# npm install
381+
# npm --prefer-offline --no-audit --progress=false --loglevel=error ci
382+
# node node_modules/brunch/bin/brunch build
360383

361-
RUN set -exu && \
362-
mkdir -p ./assets && \
363-
yarn --cwd ./assets install --prod
364-
# cd assets && yarn install --prod
365-
366-
# Install JavaScript deps using npm
367-
# WORKDIR "${APP_DIR}/assets"
368-
# COPY --link assets/package.jso[n] ./
369-
# COPY --link assets/package-lock.jso[n] ./
370-
# RUN npm install
371-
372-
# Compile assets the old way
373-
# WORKDIR "${APP_DIR}/assets"
374-
#
375-
# COPY --link assets/package.json ./
376-
# COPY --link assets/package-lock.json ./
377-
#
378-
# RUN --mount=type=cache,target=~/.npm,sharing=locked \
379-
# npm --prefer-offline --no-audit --progress=false --loglevel=error ci
380-
#
381-
# COPY --link assets ./
382-
#
383384
# RUN --mount=type=cache,target=~/.npm,sharing=locked \
384385
# npm run deploy
385386
#
386387
# Generate assets the really old way
387388
# RUN --mount=type=cache,target=~/.npm,sharing=locked \
388-
# npm install && \
389389
# node node_modules/webpack/bin/webpack.js --mode production
390390

391391
WORKDIR $APP_DIR
@@ -417,9 +417,22 @@ FROM build-deps-get AS prod-release
417417
# Build release
418418
COPY --link rel ./rel
419419

420+
# Generate systemd and deploy scripts
420421
# RUN mix do systemd.init, systemd.generate, deploy.init, deploy.generate
422+
421423
RUN mix release "$RELEASE"
422424

425+
# Create revision for CodeDeploy
426+
# WORKDIR /revision
427+
# COPY appspec.yml ./
428+
# RUN set -exu && \
429+
# mkdir -p etc bin systemd && \
430+
# cp /app/bin/* ./bin/ && \
431+
# cp /app/_build/${MIX_ENV}/systemd/lib/systemd/system/* ./systemd/ && \
432+
# cp /app/_build/${MIX_ENV}/${RELEASE}-*.tar.gz "./${RELEASE}.tar.gz" && \
433+
# zip -r /revision.zip . && \
434+
# rm -rf /revision/*
435+
423436
# Create staging image for files which are copied into final prod image
424437
FROM ${INSTALL_BASE_IMAGE_NAME}:${INSTALL_BASE_IMAGE_TAG} AS prod-install
425438
ARG LANG
@@ -506,6 +519,7 @@ FROM ${INSTALL_BASE_IMAGE_NAME}:${INSTALL_BASE_IMAGE_TAG} AS prod-install
506519
truncate -s 0 /var/log/apt/* && \
507520
truncate -s 0 /var/log/dpkg.log
508521

522+
RUN cat /etc/locale.gen
509523
RUN ls -l "/lib/"
510524
RUN ls -l "/lib/$(uname -m)-linux-gnu/"
511525
RUN ls -l "/usr/lib/"
@@ -529,10 +543,15 @@ FROM ${PROD_BASE_IMAGE_NAME}:${PROD_BASE_IMAGE_TAG} AS prod-base
529543

530544
# Copy shared libraries needed at runtime
531545

546+
# # libtinfo6
547+
# COPY --from=prod-install "/lib/${LINUX_ARCH}-linux-gnu/libtinfo.so.6.2" "/lib/${LINUX_ARCH}-linux-gnu/libtinfo.so.6"
548+
# # libncurses6
549+
# COPY --from=prod-install "/lib/${LINUX_ARCH}-linux-gnu/libncursesw.so.6.2" "/lib/${LINUX_ARCH}-linux-gnu/libncurses2.so.6"
550+
532551
# libtinfo6
533-
COPY --from=prod-install "/lib/${LINUX_ARCH}-linux-gnu/libtinfo.so.6.2" "/lib/${LINUX_ARCH}-linux-gnu/libtinfo.so.6"
552+
COPY --from=prod-install "/lib/${LINUX_ARCH}-linux-gnu/libtinfo.so.6" "/lib/${LINUX_ARCH}-linux-gnu/libtinfo.so.6"
534553
# libncurses6
535-
COPY --from=prod-install "/lib/${LINUX_ARCH}-linux-gnu/libncursesw.so.6.2" "/lib/${LINUX_ARCH}-linux-gnu/libncurses2.so.6"
554+
COPY --from=prod-install "/lib/${LINUX_ARCH}-linux-gnu/libncursesw.so.6" "/lib/${LINUX_ARCH}-linux-gnu/libncurses2.so.6"
536555

537556
# Part of distroless/cc image
538557
# libgcc-s1
@@ -573,6 +592,10 @@ FROM prod-base AS prod
573592
# Needed for RELEASE_TMP
574593
"/run/${APP_NAME}"
575594

595+
# Copy CodeDeploy revision into prod image for publishing later
596+
# This could be put in a separate target, but it's faster to do it from prod test
597+
# COPY --from=prod-release --chown="$APP_USER:$APP_GROUP" /revision.zip /revision.zip
598+
576599
# USER $APP_USER
577600

578601
# Setting WORKDIR after USER makes directory be owned by the user.

0 commit comments

Comments
 (0)