Skip to content

Commit 1d86eec

Browse files
committed
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 <stephen@that.guru>
1 parent 60f8be6 commit 1d86eec

6 files changed

Lines changed: 13 additions & 22 deletions

File tree

‎.github/workflows/ci.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ jobs:
147147
cache: 'pip'
148148
- name: Build docker-compose service
149149
run: |
150-
docker compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g)
150+
docker compose build
151151
- name: Test createsuperuser/changepassword
152152
run: |
153153
docker compose run -T --rm web \

‎docker-compose-pg.yml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ services:
1515
dockerfile: ./tools/docker/Dockerfile
1616
args:
1717
- UID
18-
- GID
1918
depends_on:
2019
- db
2120
volumes:
22-
- .:/home/patchwork/patchwork/
21+
- .:/home/ubuntu/patchwork/
2322
ports:
2423
- "8000:8000"
2524
environment:
26-
- UID
27-
- GID
2825
- DATABASE_TYPE=postgres
2926
- DATABASE_HOST=db
3027
- DATABASE_PORT=5432

‎docker-compose-sqlite3.yml‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ services:
66
dockerfile: ./tools/docker/Dockerfile
77
args:
88
- UID
9-
- GID
109
command: python3 manage.py runserver 0.0.0.0:8000
1110
volumes:
12-
- .:/home/patchwork/patchwork/
11+
- .:/home/ubuntu/patchwork/
1312
ports:
1413
- "8000:8000"
1514
environment:
16-
- UID
17-
- GID
1815
- DATABASE_TYPE=sqlite3
19-
- DATABASE_NAME=/home/patchwork/patchwork/tools/docker/db/db.sqlite3
16+
- DATABASE_NAME=/home/ubuntu/patchwork/tools/docker/db/db.sqlite3

‎docker-compose.yml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@ services:
2020
dockerfile: ./tools/docker/Dockerfile
2121
args:
2222
- UID
23-
- GID
2423
depends_on:
2524
- db
2625
volumes:
27-
- .:/home/patchwork/patchwork/
26+
- .:/home/ubuntu/patchwork/
2827
ports:
2928
- "8000:8000"
3029
environment:
31-
- UID
32-
- GID
3330
# skip DATABASE_TYPE explicitly as mysql should be the default type.
3431
- DATABASE_HOST=db
3532
- DATABASE_PORT=3306

‎tools/docker/Dockerfile‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
FROM ghcr.io/getpatchwork/pyenv:latest
22

3+
# Match the host user's UID so the container can write to bind-mounted volumes.
4+
# Ubuntu 24.04 ships with an 'ubuntu' user (UID 1000); we just remap it.
35
ARG UID=1000
4-
ARG GID=1000
6+
RUN usermod -u "${UID}" ubuntu && chown -R ubuntu:ubuntu /home/ubuntu
57

68
ARG TZ="Australia/Canberra"
79
ENV DEBIAN_FRONTEND noninteractive
810
ENV PYTHONUNBUFFERED 1
9-
ENV PROJECT_HOME /home/patchwork/patchwork
11+
ENV PROJECT_HOME /home/ubuntu/patchwork
1012
ENV DJANGO_SETTINGS_MODULE patchwork.settings.dev
1113

12-
RUN groupadd -o --gid=$GID patchwork && \
13-
useradd --uid=$UID --gid=$GID --create-home patchwork
1414
RUN rm -f /etc/localtime; ln -s /usr/share/zoneinfo/$TZ /etc/localtime
1515

1616
RUN eval "$(pyenv init -)"
@@ -37,5 +37,5 @@ RUN pip install -r /opt/requirements-dev.txt
3737
COPY tools/docker/entrypoint.sh /usr/local/bin/entrypoint.sh
3838
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
3939
CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
40-
USER patchwork
41-
WORKDIR /home/patchwork/patchwork
40+
USER ubuntu
41+
WORKDIR /home/ubuntu/patchwork

‎tools/docker/entrypoint.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ test_database() {
4040

4141
# check if patchwork is mounted. Checking if we exist is a
4242
# very good start!
43-
if [ ! -f ~patchwork/patchwork/tools/docker/entrypoint.sh ]; then
43+
if [ ! -f ~/patchwork/tools/docker/entrypoint.sh ]; then
4444
cat << EOF
4545
The patchwork directory doesn't seem to be mounted!
4646
4747
Are you using docker-compose? If so, you may need to create an SELinux rule.
4848
Refer to the development installation documentation for more information.
49-
If not, you need -v PATH_TO_PATCHWORK:/home/patchwork/patchwork
49+
If not, you need -v PATH_TO_PATCHWORK:/home/ubuntu/patchwork
5050
EOF
5151
exit 1
5252
fi

0 commit comments

Comments
 (0)