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.
This commit significantly improves the local development experience by enabling hot reloading for the Django application. This is achieved by installing the project as an editable package within the Docker services.
Key changes:
- **Hot Reloading:**
- Modified `docker-compose.yml` for `web` and `celery` services to use `uv pip install --editable . --no-deps`.
- Mounted the project root (`./`) to `/code` in `web` and `celery` services to facilitate the editable install.
- **Docker & Build Enhancements:**
- Added `uv` binary to stage-1 in the `Dockerfile` for faster package operations.
- Adjusted file permissions in `Dockerfile` during the app copy.
- Set `DEBUG=true` for the `web` service in `docker-compose.yml` for easier local debugging.
- Changed `restart` policy to `unless-stopped` for `web` and `celery` dev services.
- Added a healthcheck for the `redis` service in the dev `docker-compose.yml`.
- **Code & Script Cleanup:**
- Removed the custom `HealthCheckView` from the `home` app, as health checks are now handled by django-health-checks.
- Updated paths and commands in `scripts/entrypoint.sh`, `scripts/prebuild.sh`, and `scripts/reset-db_make-migrations_seed-data.sh` to align with the new setup and remove obsolete steps (e.g., db cache table creation; we now use redis).