fix(ci): pass debian_base for v15, fix bench build, and verify arbitrary uid startup
This commit is contained in:
parent
a31b3da69d
commit
11287d3199
|
|
@ -56,4 +56,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
targets: bench
|
targets: bench
|
||||||
push: true
|
push: true
|
||||||
set: "*.platform=linux/amd64,linux/arm64"
|
set: |
|
||||||
|
*.platform=linux/amd64,linux/arm64
|
||||||
|
*.attest=type=sbom
|
||||||
|
*.attest=type=provenance,mode=max
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ jobs:
|
||||||
version: "15"
|
version: "15"
|
||||||
python_version: "3.11"
|
python_version: "3.11"
|
||||||
node_version: "22"
|
node_version: "22"
|
||||||
|
debian_base: "bookworm"
|
||||||
|
|
||||||
v15_publish:
|
v15_publish:
|
||||||
if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }}
|
if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }}
|
||||||
|
|
@ -60,6 +61,7 @@ jobs:
|
||||||
erpnext_version: ${{ needs.v15_test.outputs.erpnext_version }}
|
erpnext_version: ${{ needs.v15_test.outputs.erpnext_version }}
|
||||||
python_version: "3.11"
|
python_version: "3.11"
|
||||||
node_version: "22"
|
node_version: "22"
|
||||||
|
debian_base: "bookworm"
|
||||||
secrets:
|
secrets:
|
||||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ on:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
description: NodeJS Version
|
description: NodeJS Version
|
||||||
|
debian_base:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: trixie
|
||||||
|
description: Debian Base Distribution
|
||||||
outputs:
|
outputs:
|
||||||
frappe_version:
|
frappe_version:
|
||||||
description: "Resolved frappe image tag"
|
description: "Resolved frappe image tag"
|
||||||
|
|
@ -86,6 +91,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo "PYTHON_VERSION=${{ inputs.python_version }}" >> "$GITHUB_ENV"
|
echo "PYTHON_VERSION=${{ inputs.python_version }}" >> "$GITHUB_ENV"
|
||||||
echo "NODE_VERSION=${{ inputs.node_version }}" >> "$GITHUB_ENV"
|
echo "NODE_VERSION=${{ inputs.node_version }}" >> "$GITHUB_ENV"
|
||||||
|
echo "DEBIAN_BASE=${{ inputs.debian_base }}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
uses: docker/bake-action@v7.3.0
|
uses: docker/bake-action@v7.3.0
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@ on:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
description: NodeJS Version
|
description: NodeJS Version
|
||||||
|
debian_base:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: trixie
|
||||||
|
description: Debian Base Distribution
|
||||||
secrets:
|
secrets:
|
||||||
DOCKERHUB_USERNAME:
|
DOCKERHUB_USERNAME:
|
||||||
required: true
|
required: true
|
||||||
|
|
@ -62,6 +67,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo "PYTHON_VERSION=${{ inputs.python_version }}" >> "$GITHUB_ENV"
|
echo "PYTHON_VERSION=${{ inputs.python_version }}" >> "$GITHUB_ENV"
|
||||||
echo "NODE_VERSION=${{ inputs.node_version }}" >> "$GITHUB_ENV"
|
echo "NODE_VERSION=${{ inputs.node_version }}" >> "$GITHUB_ENV"
|
||||||
|
echo "DEBIAN_BASE=${{ inputs.debian_base }}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v4.6.0
|
uses: docker/login-action@v4.6.0
|
||||||
|
|
@ -73,7 +79,10 @@ jobs:
|
||||||
uses: docker/bake-action@v7.3.0
|
uses: docker/bake-action@v7.3.0
|
||||||
with:
|
with:
|
||||||
push: true
|
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
|
- name: Login to GHCR
|
||||||
uses: docker/login-action@v4.6.0
|
uses: docker/login-action@v4.6.0
|
||||||
|
|
@ -87,6 +96,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
targets: base-images
|
targets: base-images
|
||||||
push: true
|
push: true
|
||||||
set: "*.platform=linux/amd64,linux/arm64"
|
set: |
|
||||||
|
*.platform=linux/amd64,linux/arm64
|
||||||
|
*.attest=type=sbom
|
||||||
|
*.attest=type=provenance,mode=max
|
||||||
env:
|
env:
|
||||||
REGISTRY_USER: ghcr.io/${{ github.repository_owner }}
|
REGISTRY_USER: ghcr.io/${{ github.repository_owner }}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ variable PYTHON_VERSION {
|
||||||
variable NODE_VERSION {
|
variable NODE_VERSION {
|
||||||
default = "24"
|
default = "24"
|
||||||
}
|
}
|
||||||
|
variable DEBIAN_BASE {
|
||||||
|
default = "trixie"
|
||||||
|
}
|
||||||
|
|
||||||
variable "FRAPPE_VERSION" {
|
variable "FRAPPE_VERSION" {
|
||||||
default = "develop"
|
default = "develop"
|
||||||
|
|
@ -42,10 +45,6 @@ target "bench" {
|
||||||
args = {
|
args = {
|
||||||
GIT_REPO = "${BENCH_REPO}"
|
GIT_REPO = "${BENCH_REPO}"
|
||||||
}
|
}
|
||||||
attest = [
|
|
||||||
"type=sbom",
|
|
||||||
"type=provenance,mode=max"
|
|
||||||
]
|
|
||||||
labels = {
|
labels = {
|
||||||
"org.opencontainers.image.source" = "https://github.com/frappe/frappe_docker"
|
"org.opencontainers.image.source" = "https://github.com/frappe/frappe_docker"
|
||||||
"org.opencontainers.image.url" = "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}"
|
ERPNEXT_BRANCH = "${ERPNEXT_VERSION}"
|
||||||
PYTHON_VERSION = "${PYTHON_VERSION}"
|
PYTHON_VERSION = "${PYTHON_VERSION}"
|
||||||
NODE_VERSION = "${NODE_VERSION}"
|
NODE_VERSION = "${NODE_VERSION}"
|
||||||
|
DEBIAN_BASE = "${DEBIAN_BASE}"
|
||||||
}
|
}
|
||||||
attest = [
|
|
||||||
"type=sbom",
|
|
||||||
"type=provenance,mode=max"
|
|
||||||
]
|
|
||||||
labels = {
|
labels = {
|
||||||
"org.opencontainers.image.source" = "https://github.com/frappe/frappe_docker"
|
"org.opencontainers.image.source" = "https://github.com/frappe/frappe_docker"
|
||||||
"org.opencontainers.image.url" = "https://github.com/frappe/frappe_docker"
|
"org.opencontainers.image.url" = "https://github.com/frappe/frappe_docker"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ LABEL author=frappé
|
||||||
ARG GIT_REPO=https://github.com/frappe/bench.git
|
ARG GIT_REPO=https://github.com/frappe/bench.git
|
||||||
ARG GIT_BRANCH=v5.x
|
ARG GIT_BRANCH=v5.x
|
||||||
ARG INSTALL_CHROMIUM=true
|
ARG INSTALL_CHROMIUM=true
|
||||||
|
ARG WKHTMLTOPDF_VERSION=0.12.6.1-3
|
||||||
|
ARG WKHTMLTOPDF_DISTRO=bookworm
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
||||||
|
|
@ -36,7 +38,6 @@ RUN apt-get update \
|
||||||
tree \
|
tree \
|
||||||
nano \
|
nano \
|
||||||
less \
|
less \
|
||||||
software-properties-common \
|
|
||||||
bash-completion \
|
bash-completion \
|
||||||
# For psycopg2
|
# For psycopg2
|
||||||
libpq-dev \
|
libpq-dev \
|
||||||
|
|
@ -74,7 +75,14 @@ RUN apt-get update \
|
||||||
file \
|
file \
|
||||||
# For MIME type detection
|
# For MIME type detection
|
||||||
media-types \
|
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 \
|
&& if [ "$INSTALL_CHROMIUM" != "false" ]; then \
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
||||||
chromium-headless-shell; \
|
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 \
|
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
|
&& 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,
|
# 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
|
# add user to sudo group, allow passwordless sudo, switch to that user
|
||||||
# and change directory to user home directory
|
# and change directory to user home directory
|
||||||
|
|
|
||||||
|
|
@ -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 \
|
&& if [ "$(uname -m)" = "x86_64" ]; then export ARCH=amd64; fi \
|
||||||
&& downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb \
|
&& downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb \
|
||||||
&& curl -sLO https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file \
|
&& 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 \
|
&& rm $downloaded_file \
|
||||||
# Chromium \
|
# Chromium \
|
||||||
&& if [ "$INSTALL_CHROMIUM" != "false" ]; then \
|
&& if [ "$INSTALL_CHROMIUM" != "false" ]; then \
|
||||||
|
|
|
||||||
|
|
@ -176,15 +176,37 @@ class TestPostgres:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_arbitrary_uid_execution(compose: Compose, python_path: str):
|
def test_arbitrary_uid_execution(compose: Compose):
|
||||||
"""Verify backend container runs smoothly under arbitrary UID with GID 0 (OpenShift restricted-v2)."""
|
"""Verify container starts and runs under arbitrary UID with GID 0 (OpenShift restricted-v2).
|
||||||
# UID 1000680000 is a representative OpenShift assigned arbitrary non-root UID
|
|
||||||
output = compose.exec(
|
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",
|
"--user",
|
||||||
"1000680000:0",
|
"1000680000:0",
|
||||||
"backend",
|
"backend",
|
||||||
python_path,
|
"/home/frappe/frappe-bench/env/bin/python",
|
||||||
"-c",
|
"-c",
|
||||||
"import os; print(f'UID:{os.getuid()},GID:{os.getgid()}')",
|
check_script,
|
||||||
)
|
)
|
||||||
assert "UID:1000680000,GID:0" in output
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue