fix(ci): pass debian_base for v15, fix bench build, and verify arbitrary uid startup

This commit is contained in:
Revant Nandgaonkar 2026-09-19 14:44:03 +05:30
parent a31b3da69d
commit 11287d3199
8 changed files with 70 additions and 31 deletions

View File

@ -56,4 +56,7 @@ jobs:
with:
targets: bench
push: true
set: "*.platform=linux/amd64,linux/arm64"
set: |
*.platform=linux/amd64,linux/arm64
*.attest=type=sbom
*.attest=type=provenance,mode=max

View File

@ -49,6 +49,7 @@ jobs:
version: "15"
python_version: "3.11"
node_version: "22"
debian_base: "bookworm"
v15_publish:
if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }}
@ -60,6 +61,7 @@ jobs:
erpnext_version: ${{ needs.v15_test.outputs.erpnext_version }}
python_version: "3.11"
node_version: "22"
debian_base: "bookworm"
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

View File

@ -19,6 +19,11 @@ on:
required: true
type: string
description: NodeJS Version
debian_base:
required: false
type: string
default: trixie
description: Debian Base Distribution
outputs:
frappe_version:
description: "Resolved frappe image tag"
@ -86,6 +91,7 @@ jobs:
run: |
echo "PYTHON_VERSION=${{ inputs.python_version }}" >> "$GITHUB_ENV"
echo "NODE_VERSION=${{ inputs.node_version }}" >> "$GITHUB_ENV"
echo "DEBIAN_BASE=${{ inputs.debian_base }}" >> "$GITHUB_ENV"
- name: Build
uses: docker/bake-action@v7.3.0

View File

@ -23,6 +23,11 @@ on:
required: true
type: string
description: NodeJS Version
debian_base:
required: false
type: string
default: trixie
description: Debian Base Distribution
secrets:
DOCKERHUB_USERNAME:
required: true
@ -62,6 +67,7 @@ jobs:
run: |
echo "PYTHON_VERSION=${{ inputs.python_version }}" >> "$GITHUB_ENV"
echo "NODE_VERSION=${{ inputs.node_version }}" >> "$GITHUB_ENV"
echo "DEBIAN_BASE=${{ inputs.debian_base }}" >> "$GITHUB_ENV"
- name: Login to Docker Hub
uses: docker/login-action@v4.6.0
@ -73,7 +79,10 @@ jobs:
uses: docker/bake-action@v7.3.0
with:
push: true
set: "*.platform=linux/amd64,linux/arm64"
set: |
*.platform=linux/amd64,linux/arm64
*.attest=type=sbom
*.attest=type=provenance,mode=max
- name: Login to GHCR
uses: docker/login-action@v4.6.0
@ -87,6 +96,9 @@ jobs:
with:
targets: base-images
push: true
set: "*.platform=linux/amd64,linux/arm64"
set: |
*.platform=linux/amd64,linux/arm64
*.attest=type=sbom
*.attest=type=provenance,mode=max
env:
REGISTRY_USER: ghcr.io/${{ github.repository_owner }}

View File

@ -11,6 +11,9 @@ variable PYTHON_VERSION {
variable NODE_VERSION {
default = "24"
}
variable DEBIAN_BASE {
default = "trixie"
}
variable "FRAPPE_VERSION" {
default = "develop"
@ -42,10 +45,6 @@ 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"
@ -97,11 +96,8 @@ target "default-args" {
ERPNEXT_BRANCH = "${ERPNEXT_VERSION}"
PYTHON_VERSION = "${PYTHON_VERSION}"
NODE_VERSION = "${NODE_VERSION}"
DEBIAN_BASE = "${DEBIAN_BASE}"
}
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"

View File

@ -5,6 +5,8 @@ LABEL author=frappé
ARG GIT_REPO=https://github.com/frappe/bench.git
ARG GIT_BRANCH=v5.x
ARG INSTALL_CHROMIUM=true
ARG WKHTMLTOPDF_VERSION=0.12.6.1-3
ARG WKHTMLTOPDF_DISTRO=bookworm
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
@ -36,7 +38,6 @@ RUN apt-get update \
tree \
nano \
less \
software-properties-common \
bash-completion \
# For psycopg2
libpq-dev \
@ -74,7 +75,14 @@ RUN apt-get update \
file \
# For MIME type detection
media-types \
# Chromium
# 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 --no-install-recommends -y ./$downloaded_file \
&& rm $downloaded_file \
# Chromium \
&& if [ "$INSTALL_CHROMIUM" != "false" ]; then \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
chromium-headless-shell; \
@ -84,16 +92,6 @@ RUN apt-get update \
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales
# Detect arch and install wkhtmltopdf
ARG WKHTMLTOPDF_VERSION=0.12.6.1-3
ARG WKHTMLTOPDF_DISTRO=bookworm
RUN 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 \
&& wget -q https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file \
&& dpkg -i $downloaded_file \
&& rm $downloaded_file
# Create new user with home directory, improve docker compatibility with UID/GID 1000,
# add user to sudo group, allow passwordless sudo, switch to that user
# and change directory to user home directory

View File

@ -57,7 +57,7 @@ RUN useradd -u 1000 -g 0 -d /home/frappe -ms /bin/bash frappe \
&& 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 \
&& apt-get install --no-install-recommends -y ./$downloaded_file \
&& rm $downloaded_file \
# Chromium \
&& if [ "$INSTALL_CHROMIUM" != "false" ]; then \

View File

@ -176,15 +176,37 @@ class TestPostgres:
)
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(
def test_arbitrary_uid_execution(compose: Compose):
"""Verify container starts and runs under arbitrary UID with GID 0 (OpenShift restricted-v2).
Executes the entrypoint directly to verify:
- Container startup with arbitrary non-root UID (e.g. 1000680000) and GID 0
- Entrypoint dynamic user lookup (/etc/passwd mapping)
- Effective runtime umask (0002)
- Writability of required paths (/home/frappe, /tmp, sites directory)
"""
check_script = (
"import os, pwd, tempfile; "
"uid = os.getuid(); "
"gid = os.getgid(); "
"user = pwd.getpwuid(uid).pw_name; "
"assert gid == 0, f'Expected GID 0, got {gid}'; "
"old_umask = os.umask(0); "
"os.umask(old_umask); "
"assert old_umask == 0o002, f'Expected umask 0002, got {oct(old_umask)}'; "
"with tempfile.NamedTemporaryFile(dir='/home/frappe') as f: f.write(b'ok'); "
"with tempfile.NamedTemporaryFile(dir='/home/frappe/frappe-bench/sites') as f: f.write(b'ok'); "
"print(f'VERIFIED:{user}:{uid}:{gid}')"
)
compose(
"run",
"--rm",
"--no-deps",
"--user",
"1000680000:0",
"backend",
python_path,
"/home/frappe/frappe-bench/env/bin/python",
"-c",
"import os; print(f'UID:{os.getuid()},GID:{os.getgid()}')",
check_script,
)
assert "UID:1000680000,GID:0" in output