From f5e516af1faa4c05ca3241df2f5de7b6a49362af Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 11 Nov 2026 15:38:45 -0500 Subject: [PATCH] Add Docker-based development/test setup Allows for easily running an archweb development locally with a single command. --- .dockerignore | 7 +++++++ Dockerfile | 26 ++++++++++++++++++++++++++ README.md | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..aa9751bd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git +.venv +local_settings.py +*.db +collected_static +htmlcov +**/__pycache__ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..5c7a67a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM archlinux:latest + +RUN pacman -Syu --noconfirm --needed git python uv wget && pacman -Scc --noconfirm + +WORKDIR /app + +# Keep the virtualenv outside /app so it survives bind-mounting the source +ENV UV_PROJECT_ENVIRONMENT=/opt/venv +COPY pyproject.toml uv.lock ./ +RUN uv sync --frozen --no-install-project + +COPY . . + +# Fetch the style submodule if it was not initialized in the build context +RUN [ -e archlinux_common_style/django ] || \ + (rm -rf archlinux_common_style && \ + git clone --depth 1 https://gitlab.archlinux.org/archlinux/archlinux-common-style.git archlinux_common_style) + +RUN cp local_settings.py.example local_settings.py && \ + sed -i 's/^DEBUG = False/DEBUG = True/' local_settings.py + +EXPOSE 8000 + +CMD ["sh", "-c", "uv run ./manage.py migrate && \ + uv run ./manage.py loaddata main/fixtures/*.json devel/fixtures/*.json mirrors/fixtures/*.json releng/fixtures/*.json && \ + uv run ./manage.py runserver 0.0.0.0:8000"] diff --git a/README.md b/README.md index ed373dab..98d9e482 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,43 @@ probably want the following: # Testing Installation +## Docker (recommended) + +The provided `Dockerfile` builds an Arch Linux based development environment +in a single container. It uses SQLite, sets `DEBUG = True`, runs the migrations, +loads the fixtures and starts the development server. + +1. Build the image: + + docker build -t archweb-dev . + +2. Start the container: + + docker run --rm --name archweb -p 8000:8000 archweb-dev + + Archweb is now available at . + +3. Create a superuser (optional). The fixtures do not contain any users, and + registering an account requires an SMTP server. + + docker exec -e DJANGO_SUPERUSER_PASSWORD=admin archweb \ + uv run ./manage.py createsuperuser --noinput --username admin --email admin@example.com + +4. Populate the database with real package data (optional): + + docker exec archweb sh -c ' + wget https://geo.mirror.pkgbuild.com/core/os/x86_64/core.db.tar.gz && + uv run ./manage.py reporead x86_64 core.db.tar.gz && + wget https://geo.mirror.pkgbuild.com/core/os/x86_64/core.files.tar.gz && + uv run ./manage.py reporead --filesonly x86_64 core.files.tar.gz' + + See step 8 of the local installation below for customization notes. + +All data is stored inside the container and is lost when the container is +removed. + +## Local installation + 1. Run `uv sync`. 2. Initialize git submodules: