feat(images): upgrade to debian trixie and support openshift arbitrary uid

This commit is contained in:
Revant Nandgaonkar 2026-09-19 14:05:21 +05:30
parent c74f28db98
commit a31b3da69d
9 changed files with 89 additions and 49 deletions

View File

@ -136,9 +136,9 @@ Each Frappe/ERPNext release triggers new stable images builds as well as bump to
# Maintenance
In case of new release of Debian. e.g. bullseye to bookworm. Change following files:
In case of new release of Debian. e.g. bookworm to trixie. Change following files:
- `images/erpnext/Containerfile` and `images/custom/Containerfile`: Change the files to use new debian release, make sure new python version tag that is available on new debian release image. e.g. 3.9.9 (bullseye) to 3.9.17 (bookworm) or 3.10.5 (bullseye) to 3.10.12 (bookworm). Make sure apt-get packages and wkhtmltopdf version are also upgraded accordingly.
- `images/production/Containerfile` and `images/custom/Containerfile`: Change the files to use new debian release, make sure new python version tag that is available on new debian release image. Make sure apt-get packages and wkhtmltopdf version are also upgraded accordingly.
- `images/bench/Dockerfile`: Change the files to use new debian release. Make sure apt-get packages and wkhtmltopdf version are also upgraded accordingly.
Change following files on release of ERPNext

View File

@ -42,6 +42,14 @@ target "bench" {
args = {
GIT_REPO = "${BENCH_REPO}"
}
attest = [
"type=sbom",
"type=provenance,mode=max"
]
labels = {
"org.opencontainers.image.source" = "https://github.com/frappe/frappe_docker"
"org.opencontainers.image.url" = "https://github.com/frappe/frappe_docker"
}
context = "images/bench"
target = "bench"
tags = [
@ -90,6 +98,14 @@ target "default-args" {
PYTHON_VERSION = "${PYTHON_VERSION}"
NODE_VERSION = "${NODE_VERSION}"
}
attest = [
"type=sbom",
"type=provenance,mode=max"
]
labels = {
"org.opencontainers.image.source" = "https://github.com/frappe/frappe_docker"
"org.opencontainers.image.url" = "https://github.com/frappe/frappe_docker"
}
}
target "erpnext" {

View File

@ -1,4 +1,4 @@
FROM debian:bookworm-slim AS bench
FROM debian:trixie-slim AS bench
LABEL author=frappé
@ -46,7 +46,7 @@ RUN apt-get update \
libldap2-dev \
libmariadb-dev \
libsasl2-dev \
libtiff5-dev \
libtiff-dev \
libwebp-dev \
pkg-config \
redis-tools \

View File

@ -1,5 +1,5 @@
ARG PYTHON_VERSION=3.14
ARG DEBIAN_BASE=bookworm
ARG DEBIAN_BASE=trixie
FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base
COPY resources/core/nginx/nginx-template.conf /templates/nginx/frappe.conf.template
@ -15,7 +15,7 @@ ENV NVM_DIR=/home/frappe/.nvm
ENV NVM_SYMLINK_CURRENT=true
ENV PATH=${NVM_DIR}/current/bin/:${PATH}
RUN useradd -ms /bin/bash frappe \
RUN useradd -u 1000 -g 0 -d /home/frappe -ms /bin/bash frappe \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
curl \
@ -24,26 +24,26 @@ RUN useradd -ms /bin/bash frappe \
nginx \
gettext-base \
file \
# weasyprint dependencies
# weasyprint dependencies \
libpango-1.0-0 \
libharfbuzz0b \
libpangoft2-1.0-0 \
libpangocairo-1.0-0 \
# For backups
# For backups \
restic \
gpg \
# MariaDB
# MariaDB \
mariadb-client \
less \
# Postgres
# Postgres \
libpq-dev \
postgresql-client \
# For healthcheck
# For healthcheck \
wait-for-it \
jq \
# For MIME type detection
# For MIME type detection \
media-types \
# NodeJS
# NodeJS \
&& mkdir -p ${NVM_DIR} \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.6/install.sh | bash \
&& . ${NVM_DIR}/nvm.sh \
@ -56,33 +56,31 @@ RUN useradd -ms /bin/bash frappe \
&& echo 'export NVM_DIR="/home/frappe/.nvm"' >>/home/frappe/.bashrc \
&& echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' >>/home/frappe/.bashrc \
&& echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >>/home/frappe/.bashrc \
# Install wkhtmltopdf with patched qt
# Install wkhtmltopdf with patched qt \
&& if [ "$(uname -m)" = "aarch64" ]; then export ARCH=arm64; fi \
&& if [ "$(uname -m)" = "x86_64" ]; then export ARCH=amd64; fi \
&& downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb \
&& curl -sLO https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file \
&& apt-get install -y ./$downloaded_file \
&& rm $downloaded_file \
# Chromium
# Chromium \
&& if [ "$INSTALL_CHROMIUM" != "false" ]; then \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
chromium-headless-shell; \
fi \
# Clean up
# Clean up \
&& rm -rf /var/lib/apt/lists/* \
&& rm -fr /etc/nginx/sites-enabled/default \
&& mkdir -p /etc/nginx/snippets \
&& pip3 install frappe-bench \
# Fixes for non-root nginx and logs to stdout
# Fixes for non-root nginx and logs to stdout \
&& sed -i '/user www-data/d' /etc/nginx/nginx.conf \
&& ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log \
&& touch /run/nginx.pid \
&& chown -R frappe:frappe /etc/nginx/conf.d \
&& chown -R frappe:frappe /etc/nginx/nginx.conf \
&& chown -R frappe:frappe /etc/nginx/snippets \
&& chown -R frappe:frappe /var/log/nginx \
&& chown -R frappe:frappe /var/lib/nginx \
&& chown -R frappe:frappe /run/nginx.pid \
# OpenShift and arbitrary UID compatibility (GID 0 & group writable) \
&& chgrp -R 0 /home/frappe /etc/nginx /var/log/nginx /var/lib/nginx /run \
&& chmod -R g=u /home/frappe /etc/nginx /var/log/nginx /var/lib/nginx /run \
&& chmod g+w /etc/passwd \
&& chmod 755 /usr/local/bin/nginx-entrypoint.sh \
&& chmod 644 /templates/nginx/frappe.conf.template
@ -107,7 +105,7 @@ RUN apt-get update \
libldap2-dev \
libmariadb-dev \
libsasl2-dev \
libtiff5-dev \
libtiff-dev \
libwebp-dev \
pkg-config \
redis-tools \
@ -126,7 +124,7 @@ ARG FRAPPE_BRANCH=version-16
ARG FRAPPE_PATH=https://github.com/frappe/frappe
ARG CACHE_BUST=""
RUN --mount=type=secret,id=apps_json,target=/opt/frappe/apps.json,uid=1000,gid=1000 \
RUN --mount=type=secret,id=apps_json,target=/opt/frappe/apps.json,uid=1000,gid=0 \
: "${CACHE_BUST}" && \
export APP_INSTALL_ARGS="" && \
if [ -f /opt/frappe/apps.json ] && [ -s /opt/frappe/apps.json ]; then \
@ -148,7 +146,8 @@ FROM base AS backend
USER frappe
COPY --from=builder --chown=frappe:frappe /home/frappe/frappe-bench /home/frappe/frappe-bench
COPY --from=builder --chown=frappe:0 /home/frappe/frappe-bench /home/frappe/frappe-bench
RUN chmod -R g=u /home/frappe/frappe-bench
WORKDIR /home/frappe/frappe-bench

View File

@ -9,7 +9,7 @@ ARG CACHE_BUST=""
USER frappe
RUN --mount=type=secret,id=apps_json,target=/opt/frappe/apps.json,uid=1000,gid=1000 \
RUN --mount=type=secret,id=apps_json,target=/opt/frappe/apps.json,uid=1000,gid=0 \
: "${CACHE_BUST}" && \
export APP_INSTALL_ARGS="" && \
if [ -f /opt/frappe/apps.json ] && [ -s /opt/frappe/apps.json ]; then \
@ -31,7 +31,8 @@ FROM ${FRAPPE_IMAGE_PREFIX}/base:${FRAPPE_BRANCH} AS backend
USER frappe
COPY --from=builder --chown=frappe:frappe /home/frappe/frappe-bench /home/frappe/frappe-bench
COPY --from=builder --chown=frappe:0 /home/frappe/frappe-bench /home/frappe/frappe-bench
RUN chmod -R g=u /home/frappe/frappe-bench
WORKDIR /home/frappe/frappe-bench

View File

@ -1,5 +1,5 @@
ARG PYTHON_VERSION=3.14
ARG DEBIAN_BASE=bookworm
ARG DEBIAN_BASE=trixie
FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base
ARG WKHTMLTOPDF_VERSION=0.12.6.1-3
@ -11,7 +11,7 @@ ENV NVM_DIR=/home/frappe/.nvm
ENV NVM_SYMLINK_CURRENT=true
ENV PATH=${NVM_DIR}/current/bin/:${PATH}
RUN useradd -ms /bin/bash frappe \
RUN useradd -u 1000 -g 0 -d /home/frappe -ms /bin/bash frappe \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
curl \
@ -20,26 +20,26 @@ RUN useradd -ms /bin/bash frappe \
nginx \
gettext-base \
file \
# weasyprint dependencies
# weasyprint dependencies \
libpango-1.0-0 \
libharfbuzz0b \
libpangoft2-1.0-0 \
libpangocairo-1.0-0 \
# For backups
# For backups \
restic \
gpg \
# MariaDB
# MariaDB \
mariadb-client \
less \
# Postgres
# Postgres \
libpq-dev \
postgresql-client \
# For healthcheck
# For healthcheck \
wait-for-it \
jq \
# For MIME type detection
# For MIME type detection \
media-types \
# NodeJS
# NodeJS \
&& mkdir -p ${NVM_DIR} \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.6/install.sh | bash \
&& . ${NVM_DIR}/nvm.sh \
@ -52,33 +52,31 @@ RUN useradd -ms /bin/bash frappe \
&& echo 'export NVM_DIR="/home/frappe/.nvm"' >>/home/frappe/.bashrc \
&& echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' >>/home/frappe/.bashrc \
&& echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >>/home/frappe/.bashrc \
# Install wkhtmltopdf with patched qt
# Install wkhtmltopdf with patched qt \
&& if [ "$(uname -m)" = "aarch64" ]; then export ARCH=arm64; fi \
&& if [ "$(uname -m)" = "x86_64" ]; then export ARCH=amd64; fi \
&& downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb \
&& curl -sLO https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file \
&& apt-get install -y ./$downloaded_file \
&& rm $downloaded_file \
# Chromium
# Chromium \
&& if [ "$INSTALL_CHROMIUM" != "false" ]; then \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
chromium-headless-shell; \
fi \
# Clean up
# Clean up \
&& rm -rf /var/lib/apt/lists/* \
&& rm -fr /etc/nginx/sites-enabled/default \
&& mkdir -p /etc/nginx/snippets \
&& pip3 install frappe-bench \
# Fixes for non-root nginx and logs to stdout
# Fixes for non-root nginx and logs to stdout \
&& sed -i '/user www-data/d' /etc/nginx/nginx.conf \
&& ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log \
&& touch /run/nginx.pid \
&& chown -R frappe:frappe /etc/nginx/conf.d \
&& chown -R frappe:frappe /etc/nginx/nginx.conf \
&& chown -R frappe:frappe /etc/nginx/snippets \
&& chown -R frappe:frappe /var/log/nginx \
&& chown -R frappe:frappe /var/lib/nginx \
&& chown -R frappe:frappe /run/nginx.pid
# OpenShift and arbitrary UID compatibility (GID 0 & group writable) \
&& chgrp -R 0 /home/frappe /etc/nginx /var/log/nginx /var/lib/nginx /run \
&& chmod -R g=u /home/frappe /etc/nginx /var/log/nginx /var/lib/nginx /run \
&& chmod g+w /etc/passwd
COPY resources/core/nginx/nginx-template.conf /templates/nginx/frappe.conf.template
COPY resources/core/nginx/nginx-entrypoint.sh /usr/local/bin/nginx-entrypoint.sh
@ -99,7 +97,7 @@ RUN apt-get update \
libldap2-dev \
libmariadb-dev \
libsasl2-dev \
libtiff5-dev \
libtiff-dev \
libwebp-dev \
pkg-config \
redis-tools \
@ -139,7 +137,8 @@ USER frappe
RUN echo "echo \"Commands restricted in prodution container, Read FAQ before you proceed: https://frappe.io/ctr-faq\"" >> ~/.bashrc
COPY --from=builder --chown=frappe:frappe /home/frappe/frappe-bench /home/frappe/frappe-bench
COPY --from=builder --chown=frappe:0 /home/frappe/frappe-bench /home/frappe/frappe-bench
RUN chmod -R g=u /home/frappe/frappe-bench
WORKDIR /home/frappe/frappe-bench

View File

@ -1,6 +1,14 @@
#!/bin/bash
set -e
umask 0002
if ! whoami &>/dev/null; then
if [ -w /etc/passwd ]; then
echo "frappe:x:$(id -u):0:frappe user:${HOME:-/home/frappe}:/bin/bash" >>/etc/passwd
fi
fi
ASSETS_PATH="/home/frappe/frappe-bench/sites/assets"
BAKED_PATH="/home/frappe/frappe-bench/assets"

View File

@ -1,4 +1,7 @@
#!/bin/bash
set -e
umask 0002
# Set variables that do not exist
if [[ -z "$BACKEND" ]]; then

View File

@ -174,3 +174,17 @@ class TestPostgres:
"--admin-password",
"admin",
)
def test_arbitrary_uid_execution(compose: Compose, python_path: str):
"""Verify backend container runs smoothly under arbitrary UID with GID 0 (OpenShift restricted-v2)."""
# UID 1000680000 is a representative OpenShift assigned arbitrary non-root UID
output = compose.exec(
"--user",
"1000680000:0",
"backend",
python_path,
"-c",
"import os; print(f'UID:{os.getuid()},GID:{os.getgid()}')",
)
assert "UID:1000680000,GID:0" in output