-
-
Notifications
You must be signed in to change notification settings - Fork 230
[feature] Add Docker support for development and testing #741 #743
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
922648d
421e002
cf37332
6b8edbe
4da8d3e
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,37 @@ | ||
| # Python bytecode | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
|
|
||
| # Virtual environments | ||
| .venv/ | ||
| venv/ | ||
| env/ | ||
| ENV/ | ||
|
|
||
| # Packaging / build artifacts | ||
| build/ | ||
| dist/ | ||
| *.egg-info/ | ||
| .eggs/ | ||
| pip-wheel-metadata/ | ||
|
|
||
| # Test / coverage / type-check caches | ||
| .pytest_cache/ | ||
| .coverage | ||
| .coverage.* | ||
| .mypy_cache/ | ||
| .pyre/ | ||
| .ruff_cache/ | ||
|
|
||
| # Git / editor / OS files | ||
| .git/ | ||
| .gitignore | ||
| .gitattributes | ||
| .vscode/ | ||
| .idea/ | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| docker-compose*.yml | ||
| Dockerfile* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # NOTE: This Docker image is for development purposes only. | ||
|
|
||
| FROM python:3.12-slim-bookworm | ||
|
|
||
| # System dependencies from the developer installation guide | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| xmlsec1 \ | ||
| gettext \ | ||
| fping \ | ||
| gdal-bin \ | ||
| libproj-dev \ | ||
| libgeos-dev \ | ||
| libspatialite-dev \ | ||
| spatialite-bin \ | ||
| libsqlite3-mod-spatialite \ | ||
| sqlite3 \ | ||
| libsqlite3-dev \ | ||
| zlib1g-dev \ | ||
| libjpeg-dev \ | ||
| openssl \ | ||
| libssl-dev \ | ||
| libglib2.0-0 \ | ||
| libcairo2 \ | ||
| libpango-1.0-0 \ | ||
| libpangocairo-1.0-0 \ | ||
| libgdk-pixbuf-2.0-0 \ | ||
| shared-mime-info \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install test requirements first so this layer is cached separately | ||
| # from the source code copy below. | ||
| COPY requirements-test.txt . | ||
| RUN pip install --no-cache-dir -r requirements-test.txt | ||
|
|
||
| # Copy source and install the package with all optional extras | ||
| COPY . . | ||
| RUN pip install --no-cache-dir -e ".[saml,openvpn_status]" | ||
|
|
||
| ENV PYTHONUNBUFFERED=1 \ | ||
| REDIS_HOST=redis \ | ||
| INFLUXDB_HOST=influxdb | ||
|
|
||
| EXPOSE 8000 | ||
| CMD ["bash", "docker-entrypoint.sh"] |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||||||
| #!/bin/bash | ||||||||||||||||
|
|
||||||||||||||||
| set -euo pipefail | ||||||||||||||||
|
|
||||||||||||||||
| create_superuser() { | ||||||||||||||||
| local username="$1" | ||||||||||||||||
| local email="$2" | ||||||||||||||||
| local password="$3" | ||||||||||||||||
| cat <<EOF | python manage.py shell | ||||||||||||||||
| from django.contrib.auth import get_user_model | ||||||||||||||||
|
|
||||||||||||||||
| User = get_user_model() | ||||||||||||||||
|
|
||||||||||||||||
| if not User.objects.filter(username="$username").exists(): | ||||||||||||||||
| User.objects.create_superuser("$username", "$email", "$password") | ||||||||||||||||
| else: | ||||||||||||||||
| print('User "{}" exists already, not created'.format("$username")) | ||||||||||||||||
| EOF | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| python manage.py migrate --no-input | ||||||||||||||||
| create_superuser admin admin@example.com admin | ||||||||||||||||
|
Comment on lines
+21
to
+22
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. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Do not bootstrap the Docker admin with fixed Line 22 creates the same superuser in every environment, and the new docs advertise those credentials for the published admin UI. That makes any reachable dev instance trivially compromiseable. Read these values from environment variables and require an explicit choice instead of a built-in password. Proposed fix python manage.py migrate --no-input
-create_superuser admin admin@example.com admin
+create_superuser \
+ "${DJANGO_SUPERUSER_USERNAME:?set DJANGO_SUPERUSER_USERNAME}" \
+ "${DJANGO_SUPERUSER_EMAIL:?set DJANGO_SUPERUSER_EMAIL}" \
+ "${DJANGO_SUPERUSER_PASSWORD:?set DJANGO_SUPERUSER_PASSWORD}"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| exec python manage.py runserver 0.0.0.0:8000 | ||||||||||||||||
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.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
Add common Django/Python development artifacts to reduce build context bloat.
The following patterns are missing and commonly appear in Django projects:
.tox/— tox virtualenv directoriesdb.sqlite3— local SQLite database*.mo— compiled translation filesnode_modules/— if any frontend assets use npmAlso verify that
docker-compose*.ymlandDockerfile*are intentionally ignored; these are safe since Docker consumes them directly, but document this if other compose files exist.Also applies to: 36-37
🤖 Prompt for AI Agents