Instruction file imported from fao102/Style-Finder (
.github/instructions/docker-deployment.instructions.md). Copyright stays with the author.
Docker & Deployment Guidelines
Dockerfile (backend/Dockerfile.dockerfile)
- Base image:
python:3.11-slim. - Key env vars baked in:
PYTHONDONTWRITEBYTECODE=1,PYTHONUNBUFFERED=1,PYTHONPATH=/app,DJANGO_SETTINGS_MODULE=core.settings. - System deps installed:
build-essential,libpq-dev(required forpsycopg2-binary). - Entrypoint:
/entry.sh(copied frombackend/entry.sh). staticfiles/directory is created at build time forcollectstatic.- Do not add a
collectstaticcall to the Dockerfile orentry.shunless WhiteNoise static serving is tested end-to-end first.
entry.sh
Current sequence:
python manage.py migrate --noinputgunicorn core.wsgi:application --bind 0.0.0.0:$PORT --workers 1
- Railway injects
$PORTautomatically. Locally it defaults to 8000 if unset. - Increase
--workersonly after load testing; at 1 worker, memory footprint is minimal on Railway's free tier.
docker-compose.yml (local testing only)
- Starts a
postgres:15container and the Django web service. - Uses hardcoded Postgres credentials for local dev only — never use these in production.
- The web service mounts the current directory as a volume (
.:/app) for live reload during local testing. - Run with:
cd backend && docker-compose up --build
Production Deployment (Railway)
- Triggered by the GitHub Actions webhook in
.github/workflows/deploy.yml. - All secrets (
SECRET_KEY,DATABASE_URL,GEMINI_API_KEY,SERP_API_KEY,ALLOWED_HOSTS,CORS_ALLOWED_ORIGINS,CSRF_TRUSTED_ORIGINS,DEBUG) must be set as Railway environment variables — not in the Dockerfile. SECURE_SSL_REDIRECT=Trueand HSTS headers are enabled in production settings. Do not disable them.