This commit comprehensively addresses issues with the local development and debugging environment, ensuring a smoother and more reliable developer experience.
Key changes include:
- **VSCode Debugger:** Corrected launch configuration (`.vscode/launch.json`) to properly run the Django development server with debugging enabled. It now correctly sets `DEBUG=True`, uses `0.0.0.0:8000`, and specifies the correct working directory.
- **Docker Compose:** Exposed the PostgreSQL port (`5432:5432`) in `docker-compose.yml` to allow direct connections from the host, facilitating local development and debugging without needing to run the full application stack.
- **Environment Variables:**
- Updated `.gitignore` to ignore all `.env.*` files, allowing for environment-specific configurations.
- Modified `src/pkmntrade_club/django_project/settings.py` to use `localhost` for `DJANGO_DATABASE_URL` and `REDIS_URL` by default, aligning with the exposed Docker services for easier local development. Default `DISABLE_SIGNUPS` and `DISABLE_CACHE` are now `True` for a more typical local dev setup.
- **Management Commands & Scripts:**
- Adjusted `manage.py` to correctly append the project's root directory to `sys.path`, resolving potential import issues when running management commands.
- Significantly improved `scripts/reset-db_make-migrations_seed-data.sh`:
- Removed reliance on sourcing `.env` directly.
- Ensured the database service (`db`) is started independently before migrations.
- Added explicit steps for running `prebuild.sh`, migrations, and `collectstatic`.
- Switched to using `uv run manage.py loaddata` for seeding, which is more consistent with the project's tooling.
- **Django Settings:** Added `SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"` and `SESSION_COOKIE_HTTPONLY = True` for improved session management and security.
These changes collectively fix the previously problematic development setup, enabling straightforward debugging and a more efficient workflow for local development.
54 lines
No EOL
1.3 KiB
YAML
54 lines
No EOL
1.3 KiB
YAML
services:
|
|
web:
|
|
build: .
|
|
command: bash -c "cd /code && uv pip install --editable . --no-deps && python manage.py runserver 0.0.0.0:8000"
|
|
ports:
|
|
- "8000:8000"
|
|
restart: unless-stopped
|
|
environment:
|
|
- DEBUG=true
|
|
volumes:
|
|
- ./seed:/seed:ro
|
|
- ./:/code
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_started
|
|
celery:
|
|
build: .
|
|
command: bash -c "cd /code && uv pip install --editable . --no-deps && celery -A pkmntrade_club.django_project worker -l INFO -B -E"
|
|
restart: unless-stopped
|
|
volumes:
|
|
- ./:/code
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_started
|
|
redis:
|
|
image: redis:latest
|
|
restart: always
|
|
ports:
|
|
- 6379:6379
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
db:
|
|
image: postgres:16
|
|
restart: always
|
|
ports:
|
|
- 5432:5432
|
|
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: |