docker: fix image builder and runner from alpine to ubuntu

This commit is contained in:
Alex Lion
2025-07-11 12:52:13 +01:00
parent 68cf5a645d
commit 0a8c000ac1
3 changed files with 34 additions and 51 deletions

View File

@@ -7,6 +7,7 @@
- Upgrade to Tailwind 4+ - Upgrade to Tailwind 4+
- Refactor view templates to use {} instead of <%= %> - Refactor view templates to use {} instead of <%= %>
- Fix event name validation to be required - Fix event name validation to be required
- Docker image is now using Ubuntu instead of Alpine for better dependencies support
### v.2.3.2 ### v.2.3.2

View File

@@ -1,26 +1,20 @@
# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian instead of ARG BUILDER_IMAGE="hexpm/elixir:1.18.4-erlang-28.0.1-ubuntu-noble-20250619"
# Alpine to avoid DNS resolution issues in production. ARG RUNNER_IMAGE="ubuntu:24.04"
#
# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu
# https://hub.docker.com/_/ubuntu?tab=tags
#
#
# This file is based on these images:
#
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20210902-slim - for the release image
# - https://pkgs.org/ - resource for finding needed packages
# - Ex: hexpm/elixir:1.13.2-erlang-24.2.1-debian-bullseye-20210902-slim
#
ARG BUILDER_IMAGE="hexpm/elixir:1.18.4-erlang-28.0.1-alpine-3.21.3"
ARG RUNNER_IMAGE="alpine:3.21.3"
FROM ${BUILDER_IMAGE} as builder FROM ${BUILDER_IMAGE} as builder
# install build dependencies RUN apt-get update && apt-get install -y \
# RUN apt-get update -y && apt-get install -y curl build-essential git \ build-essential \
# && apt-get clean && rm -f /var/lib/apt/lists/*_* git \
RUN apk add --no-cache -U build-base git curl bash ca-certificates nodejs npm openssl ncurses curl \
bash \
ca-certificates \
nodejs \
npm \
openssl \
libncurses5-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV NODE_VERSION 22.17.0 ENV NODE_VERSION 22.17.0
ENV PRESENTATION_STORAGE_DIR /app/uploads ENV PRESENTATION_STORAGE_DIR /app/uploads
@@ -53,27 +47,14 @@ RUN mix deps.compile
COPY priv priv COPY priv priv
# note: if your project uses a tool like https://purgecss.com/,
# which customizes asset compilation based on what it finds in
# your Elixir templates, you will need to move the asset compilation
# step down so that `lib` is available.
COPY assets assets COPY assets assets
# Compile the release
COPY lib lib COPY lib lib
RUN mix compile RUN mix compile
RUN npm install -g sass RUN mix assets.deploy
RUN cd assets && npm i && \
sass --no-source-map --style=compressed css/custom.scss ../priv/static/assets/custom.css
RUN npm install -g tailwindcss
# compile assets
RUN mix assets.deploy.nosass
# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/ COPY config/runtime.exs config/
COPY rel rel COPY rel rel
@@ -83,20 +64,27 @@ RUN mix release
# the compiled release and other runtime necessities # the compiled release and other runtime necessities
FROM ${RUNNER_IMAGE} FROM ${RUNNER_IMAGE}
# RUN apt-get update -y && apt-get install -y curl libstdc++6 openssl libncurses5 locales ghostscript default-jre libreoffice-java-common \ RUN apt-get update -y && apt-get install -y curl libstdc++6 openssl locales ghostscript default-jre libreoffice-java-common \
# && apt-get install -y libreoffice --no-install-recommends && apt-get clean && rm -f /var/lib/apt/lists/*_* && apt-get install -y libreoffice --no-install-recommends && apt-get clean && rm -f /var/lib/apt/lists/*_*
RUN apk add --no-cache curl libstdc++ openssl ncurses ghostscript openjdk11-jre # RUN apk add --no-cache curl libstdc++ openssl ncurses ghostscript openjdk11-jre
# Install LibreOffice & Common Fonts # Install LibreOffice & Common Fonts
RUN apk --no-cache add bash libreoffice util-linux libreoffice-common \ RUN apt-get update && apt-get install -y \
font-droid-nonlatin font-droid ttf-dejavu ttf-freefont ttf-liberation && \ libreoffice \
rm -rf /var/cache/apk/* fonts-dejavu \
fonts-freefont-ttf \
fonts-liberation \
fonts-droid-fallback \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Microsoft Core Fonts # Install Microsoft Core Fonts
RUN apk --no-cache add msttcorefonts-installer fontconfig && \ RUN apt-get update && apt-get install -y \
update-ms-fonts && \ ttf-mscorefonts-installer \
fc-cache -f && \ fontconfig \
rm -rf /var/cache/apk/* && fc-cache -f \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV LANG en_US.UTF-8 ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en ENV LANGUAGE en_US:en

View File

@@ -134,17 +134,11 @@ defmodule Claper.MixProject do
"ecto.reset": ["ecto.drop", "ecto.setup"], "ecto.reset": ["ecto.drop", "ecto.setup"],
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"], test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
"assets.deploy": [ "assets.deploy": [
"cmd --cd assets npm install && npm run deploy", "cmd --cd assets npm install",
"tailwind default --minify", "tailwind default --minify",
"esbuild default --minify", "esbuild default --minify",
"sass default --no-source-map --style=compressed", "sass default --no-source-map --style=compressed",
"phx.digest" "phx.digest"
],
"assets.deploy.nosass": [
"cmd --cd assets npm install && npm run deploy",
"esbuild default --minify",
"tailwind default --minify",
"phx.digest"
] ]
] ]
end end