This commit significantly refactors the Docker setup and application
configuration for improved robustness and flexibility.
Key changes include:
- Centralized Environment Variables:
- Default values for essential settings (database, email, cache, etc.)
are now defined in `django_project/settings.py` using `environ.Env`.
This provides sensible defaults and reduces reliance on `.env` files,
especially during Docker image builds.
- `docker-compose.yml` no longer defines environment variables directly
for `web` and `worker` services, deferring to `.env` and settings defaults.
- Dockerfile & Entrypoint Improvements:
- `DJANGO_SETTINGS_MODULE` is now exclusively set as an ENV in `Dockerfile`, instead of setting it in `entrypoint.sh`
- `entrypoint.sh` now conditionally appends `--static-path-mount`
only to the `granian` command, leveraging the upgraded Granian's
(v2.3.0+) ability to serve static files directly. The `STATIC_ROOT` is
dynamically fetched from Django settings.
- Dependency Updates:
- Upgraded `granian` from 2.2.5 to 2.3.1.
- Upgraded `click` from 8.2.0 to 8.2.1.
- `uv.lock` reflects these and other minor transitive dependency updates.
- Configuration Adjustments in `settings.py`:
- Add defaults for all env variables, and set to default local dev settings
- Introduced a `SCHEME` environment variable (defaulting to 'http')
used for `CSRF_TRUSTED_ORIGINS`, `META_SITE_PROTOCOL`,
`ACCOUNT_DEFAULT_HTTP_PROTOCOL`, etc.
- `TIME_ZONE` and various email settings (host, port, user, password, TLS)
are now configurable via environment variables with defaults.
- `CELERY_TIMEZONE` now defaults to the `TIME_ZONE` setting.
- Removed the unused `SCW_SECRET_KEY` variable (previously used for
EMAIL auth).
42 lines
No EOL
1 KiB
YAML
42 lines
No EOL
1 KiB
YAML
services:
|
|
web:
|
|
build: .
|
|
#command: ["django-admin", "runserver", "0.0.0.0:8000"]
|
|
ports:
|
|
- 8000:8000
|
|
restart: always
|
|
volumes:
|
|
- ./seed:/seed:ro
|
|
# DANGEROUS DUE TO DOCKERFILE PACKAGE BUILDING/INSTALLATION
|
|
# will need to use editable package instead somehow
|
|
#- ./src/pkmntrade_club:/app/lib/python3.12/site-packages/pkmntrade_club:ro
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
celery:
|
|
build: .
|
|
command: ["celery", "-A", "pkmntrade_club.django_project", "worker", "-l", "INFO", "-B", "-E"]
|
|
restart: always
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
image: redis:latest
|
|
restart: always
|
|
ports:
|
|
- 6379:6379
|
|
db:
|
|
image: postgres:16
|
|
restart: always
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data/
|
|
environment:
|
|
- "POSTGRES_HOST_AUTH_METHOD=trust"
|
|
healthcheck:
|
|
test: ["CMD", "pg_isready", "-U", "postgres", "-d", "postgres"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
volumes:
|
|
postgres_data: |