Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
MYSQL_ROOT_PASSWORD: root-${{ github.run_id }}
services:
postgres:
image: postgres:17
image: postgres:18
env:
POSTGRES_DB: ${{ env.DATABASE_NAME }}
POSTGRES_PASSWORD: ${{ env.DATABASE_PASSWORD }}
Expand All @@ -60,7 +60,7 @@ jobs:
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:8.4
image: mysql:9.7
env:
MYSQL_DATABASE: ${{ env.DATABASE_NAME }}
MYSQL_USER: ${{ env.DATABASE_USER }}
Expand Down Expand Up @@ -98,8 +98,13 @@ jobs:
- name: Modify database user permissions (mysql)
if: ${{ matrix.db == 'mysql' }}
run: |
mysql -h 127.0.0.1 -e "GRANT ALL ON \`test\\_${DATABASE_NAME}%\`.* to '${DATABASE_USER}'@'%';" \
-uroot -p${MYSQL_ROOT_PASSWORD}
mysql -h 127.0.0.1 -uroot -p${MYSQL_ROOT_PASSWORD} -e \
"GRANT ALL ON \`test\\_${DATABASE_NAME}%\`.* TO '${DATABASE_USER}'@'%';
FLUSH PRIVILEGES;"
- name: Configure MySQL client (mysql)
if: ${{ matrix.db == 'mysql' }}
run: |
printf '[mysqldump]\nset-gtid-purged=OFF\nno-tablespaces\n' > ~/.my.cnf
- name: Run unit tests (via tox)
run: tox
docs:
Expand Down Expand Up @@ -164,8 +169,10 @@ jobs:
- name: Modify database user permissions (mysql)
if: ${{ matrix.db == 'mysql' }}
run: |
docker compose exec -T -- db \
sh -c "exec mysql -uroot -p\"\${MYSQL_ROOT_PASSWORD}\" -e \"GRANT ALL ON \\\`test\\_\${MYSQL_DATABASE}%\\\`.* to '\${MYSQL_USER}'@'%'; FLUSH PRIVILEGES;\""
docker compose exec -T -- db sh -c \
"exec mysql -uroot -p\"\${MYSQL_ROOT_PASSWORD}\" -e \
\"GRANT ALL ON \\\`test\\_\${MYSQL_DATABASE}%\\\`.* TO '\${MYSQL_USER}'@'%';
FLUSH PRIVILEGES;\""
- name: Run unittest
run: docker compose run -T --rm web tox
- name: Test normal startup
Expand Down
6 changes: 3 additions & 3 deletions docker-compose-pg.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
services:
db:
image: postgres:17
image: postgres:18
volumes:
- ./tools/docker/db/postdata:/var/lib/postgresql/data
- ./tools/docker/db/postdata:/var/lib/postgresql
environment:
- POSTGRES_DB=patchwork
- POSTGRES_USER=patchwork
Expand All @@ -19,7 +19,7 @@ services:
depends_on:
- db
volumes:
- .:/home/patchwork/patchwork/
- .:/home/ubuntu/patchwork/
ports:
- "8000:8000"
environment:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-sqlite3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
services:
db:
image: mysql:latest
image: mysql:9.7
command: --gtid-mode=OFF --enforce-gtid-consistency=OFF
volumes:
- ./tools/docker/db/data:/var/lib/mysql
environment:
Expand All @@ -24,7 +25,8 @@ services:
depends_on:
- db
volumes:
- .:/home/patchwork/patchwork/
- .:/home/ubuntu/patchwork/
- ./tools/docker/mysql-client.cnf:/home/ubuntu/.my.cnf:ro
ports:
- "8000:8000"
environment:
Expand Down
21 changes: 11 additions & 10 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
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 DJANGO_SETTINGS_MODULE patchwork.settings.dev
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
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 -)"

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libmysqlclient-dev \
default-libmysqlclient-dev \
default-mysql-client \
libpq-dev \
libsqlite3-dev \
mysql-client \
postgresql-client \
sqlite3 \
tzdata \
Expand All @@ -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
4 changes: 2 additions & 2 deletions tools/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tools/docker/mysql-client.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[mysqldump]
# MySQL 9.5+ defaults gtid_mode=ON; suppress GTID state from dumps so that
# parallel test database cloning works without SYSTEM_VARIABLES_ADMIN.
set-gtid-purged=OFF
# Avoid requiring the PROCESS privilege for tablespace metadata.
no-tablespaces
Loading