Repository navigation
Add Docker-based development/test setup #786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .git | ||
| .venv | ||
| local_settings.py | ||
| *.db | ||
| collected_static | ||
| htmlcov | ||
| **/__pycache__ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| FROM archlinux:latest | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a Containerfile, which both podman/docker should support. |
||
|
|
||
| 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 . . | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I suppose this is why you neeed the |
||
|
|
||
| # 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"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,43 @@ probably want the following: | |
|
|
||
| # Testing Installation | ||
|
|
||
| ## Docker (recommended) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this recommended? I would like to use Podman instead for example. |
||
|
|
||
| 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 <http://localhost:8000>. | ||
|
|
||
| 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it is useful to keep the DB around or allow bind mounting it? |
||
|
|
||
| ## Local installation | ||
|
|
||
| 1. Run `uv sync`. | ||
| 2. Initialize git submodules: | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sadly not vendor neutral, there is containerignore but ofcourse docker does not support that....