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).
|
||
|---|---|---|
| .devcontainer | ||
| .github/workflows | ||
| .vscode | ||
| scripts | ||
| seed | ||
| server | ||
| src/pkmntrade_club | ||
| .cursorrules | ||
| .dockerignore | ||
| .envrc | ||
| .gitignore | ||
| .python-version | ||
| CONTRIBUTING.md | ||
| docker-compose.yml | ||
| Dockerfile | ||
| fly.toml | ||
| LICENSE | ||
| locustfile.py | ||
| manage.py | ||
| MANIFEST.in | ||
| pyproject.toml | ||
| README.md | ||
| uv.lock | ||
PKMN Trade Club
PKMN Trade Club is a Django-powered application built to connect Pokémon TCG Pocket trading enthusiasts in a secure, scalable, and community-driven environment. This platform leverages Django’s robust features and stability, a modular project structure, and best practices to deliver a smooth trading experience.
Table of Contents
Features
- Django & Python: Built with Django 5.1 and Python 3.12.
- Modular Architecture: Separate Django apps for trades, accounts, cards, and more.
- User Authentication: Comprehensive authentication powered by Django Allauth.
- Responsive UI: Custom theming with Tailwind CSS, DaisyUI, and AlpineJS.
- Production-Ready: Docker and PostgreSQL configuration for scalable deployments.
- Development Tools: Built-in support for migrations, testing, and seeding initial data.
- Security & Performance: Carefully configured for deployment with production best practices.
Installation
Local Development
-
Clone the repository:
git clone https://git.badblocks.dev/badbl0cks/pkmntrade.club.git cd pkmntrade.club -
Install dependencies via uv:
uv pip install -r requirements.txt -
Configure environment variables:
Copy the example environment file and update credentials as needed:
cp .env.example .env -
Apply migrations and seed initial data:
python manage.py migrate python manage.py createsuperuser python manage.py createcachetable django_cache -
Start the development server:
uv run manage.py runserverVisit http://127.0.0.1:8000 in your browser.
Docker Deployment
-
Build and run containers:
docker-compose up -d --build -
Run migrations and create a superuser inside the container:
docker-compose exec web python manage.py migrate docker-compose exec web python manage.py createsuperuser docker-compose exec web python manage.py createcachetable django_cache -
Access the site:
Configuration
-
Environment Variables:
Manage your local vs. production settings using.envand.env.production. Update these to match your database credentials, secret keys, and other configurations. -
Django Settings:
Production settings are indjango_project/settings.py. -
Database Settings:
Example configuration for PostgreSQL:DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'postgres', 'USER': 'postgres', 'PASSWORD': 'postgres', 'HOST': 'db', # as defined in docker-compose.yml 'PORT': 5432, } }
Database
The platform uses PostgreSQL as its primary database in production. For local development, you may use SQLite or configure PostgreSQL by updating your settings and environment variables as needed.
Running Tests
Run Django’s testing suite with:
python manage.py test
Deployment
For production deployments consider these additional steps:
- Production Server: Use a web server like Gunicorn.
- Static Files: Serve static files using Django’s WhiteNoise (or via a CDN).
- Fly.io Configuration: A
fly.tomlfile is provided if you wish to deploy on Fly.io. - Deployment Scripts: Use
deploy.shfor automated deployment tasks. - Security & Email: Update
DEFAULT_FROM_EMAIL,ALLOWED_HOSTS, and other security settings indjango_project/settings.py.
Contributing
Contributions, feature requests, and issues are welcome! Please refer to CONTRIBUTING.md for details on how to contribute to PKMN Trade Club.
License
This project is licensed under the MIT License. See LICENSE for more information.