From: Stephen Finucane Date: Sat, 6 Jun 2026 12:04:43 +0000 (+0100) Subject: docker: Fix compat with latest patchwork/pyenv image X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c4ec9da20c153e0667fc89a0f9f7ee7251f16cf;p=thirdparty%2Fpatchwork.git docker: Fix compat with latest patchwork/pyenv image We switched to the Ubuntu 24.04 base image some time back. This includes an ubuntu user that conflicts with the patchwork user we were creating. Simplify this by using the ubuntu user instead. Signed-off-by: Stephen Finucane --- diff --git a/docker-compose-pg.yml b/docker-compose-pg.yml index 3e277e5c..57db07a2 100644 --- a/docker-compose-pg.yml +++ b/docker-compose-pg.yml @@ -19,7 +19,7 @@ services: depends_on: - db volumes: - - .:/home/patchwork/patchwork/ + - .:/home/ubuntu/patchwork/ ports: - "8000:8000" environment: diff --git a/docker-compose-sqlite3.yml b/docker-compose-sqlite3.yml index 900cb71f..f3e2622c 100644 --- a/docker-compose-sqlite3.yml +++ b/docker-compose-sqlite3.yml @@ -9,11 +9,11 @@ services: - GID command: python3 manage.py runserver 0.0.0.0:8000 volumes: - - .:/home/patchwork/patchwork/ + - .:/home/ubuntu/patchwork/ ports: - "8000:8000" environment: - UID - GID - DATABASE_TYPE=sqlite3 - - DATABASE_NAME=/home/patchwork/patchwork/tools/docker/db/db.sqlite3 + - DATABASE_NAME=/home/ubuntu/patchwork/tools/docker/db/db.sqlite3 diff --git a/docker-compose.yml b/docker-compose.yml index 61c61865..86b03f39 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,7 +24,7 @@ services: depends_on: - db volumes: - - .:/home/patchwork/patchwork/ + - .:/home/ubuntu/patchwork/ ports: - "8000:8000" environment: diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 6d942492..ad41bc2b 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -1,16 +1,17 @@ FROM ghcr.io/getpatchwork/pyenv:latest +# Match the host user's UID so the container can write to bind-mounted volumes. +# Ubuntu 24.04 ships with an 'ubuntu' user (UID 1000); we just remap it. ARG UID=1000 ARG GID=1000 +RUN groupmod -g "${GID}" ubuntu && usermod -u "${UID}" ubuntu && chown -R ubuntu:ubuntu /home/ubuntu ARG TZ="Australia/Canberra" ENV DEBIAN_FRONTEND noninteractive ENV PYTHONUNBUFFERED 1 -ENV PROJECT_HOME /home/patchwork/patchwork +ENV PROJECT_HOME /home/ubuntu/patchwork ENV DJANGO_SETTINGS_MODULE patchwork.settings.dev -RUN groupadd -o --gid=$GID patchwork && \ - useradd --uid=$UID --gid=$GID --create-home patchwork RUN rm -f /etc/localtime; ln -s /usr/share/zoneinfo/$TZ /etc/localtime RUN eval "$(pyenv init -)" @@ -37,5 +38,5 @@ RUN pip install -r /opt/requirements-dev.txt COPY tools/docker/entrypoint.sh /usr/local/bin/entrypoint.sh ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"] -USER patchwork -WORKDIR /home/patchwork/patchwork +USER ubuntu +WORKDIR /home/ubuntu/patchwork diff --git a/tools/docker/entrypoint.sh b/tools/docker/entrypoint.sh index c78c0581..f141b723 100755 --- a/tools/docker/entrypoint.sh +++ b/tools/docker/entrypoint.sh @@ -40,13 +40,13 @@ test_database() { # check if patchwork is mounted. Checking if we exist is a # very good start! -if [ ! -f ~patchwork/patchwork/tools/docker/entrypoint.sh ]; then +if [ ! -f ~/patchwork/tools/docker/entrypoint.sh ]; then cat << EOF The patchwork directory doesn't seem to be mounted! Are you using docker-compose? If so, you may need to create an SELinux rule. Refer to the development installation documentation for more information. -If not, you need -v PATH_TO_PATCHWORK:/home/patchwork/patchwork +If not, you need -v PATH_TO_PATCHWORK:/home/ubuntu/patchwork EOF exit 1 fi