-
Notifications
You must be signed in to change notification settings - Fork 1
Prod #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prod #18
Changes from all commits
6f7e293
85ef946
b4cc128
5b17fb6
273e983
a8f658b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,8 @@ | ||||||||||
| # Copy to ".env" at the repository root (Docker Compose and local tooling load it from here). | ||||||||||
| # Django also loads this file via backend/setrsoft/settings.py (repo root). | ||||||||||
|
|
||||||||||
| # Docker | ||||||||||
| DOCKER_NETWORK_NAME=proxy-tier | ||||||||||
| #Docker | ||||||||||
| DOCKER_NETWORK_NAME=default | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
|
||||||||||
| DOCKER_NETWORK_NAME=default | |
| # Name of the pre-existing external Docker network shared with the reverse proxy (e.g. Traefik). | |
| # Docker Compose will not create external networks automatically, so this must match an existing network. | |
| DOCKER_NETWORK_NAME=proxy-tier |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,11 @@ | ||
| # Production stack: Nginx (web) serves the Vite build and proxies /api/ and /admin/ to Gunicorn. | ||
| # Backend is not published on the host; only port 80 (web) is exposed. | ||
| # | ||
| # Usage: cp .env.example .env, set POSTGRES_PASSWORD and SECRET_KEY, then: | ||
| # docker compose -f docker-compose.prod.yml up -d --build | ||
| # | ||
| # Smoke checks (with stack up): curl -sSf http://localhost/ | ||
| # curl -sSf http://localhost/api/health/ curl -sSf http://localhost/editor/ | head | ||
| services: | ||
| db: | ||
| image: postgres:16-alpine | ||
| env_file: | ||
| - .env | ||
| env_file: .env | ||
| environment: | ||
| POSTGRES_DB: ${POSTGRES_DB:-setrsoft} | ||
| POSTGRES_USER: ${POSTGRES_USER:-setrsoft} | ||
| POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env or the environment} | ||
| POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD} | ||
| volumes: | ||
| - postgres_data_prod:/var/lib/postgresql/data | ||
| healthcheck: | ||
|
|
@@ -23,32 +14,31 @@ services: | |
| timeout: 5s | ||
| retries: 5 | ||
| networks: | ||
| - setrsoft_network | ||
| - internal_bridge | ||
|
|
||
| backend: | ||
| build: | ||
| context: ./backend | ||
| dockerfile: Dockerfile | ||
| expose: | ||
| - "${PORT_BACKEND:-8000}" | ||
| env_file: | ||
| - .env | ||
| env_file: .env | ||
| environment: | ||
| POSTGRES_HOST: db | ||
| POSTGRES_PORT: ${POSTGRES_PORT:-5432} | ||
| POSTGRES_DB: ${POSTGRES_DB:-setrsoft} | ||
| POSTGRES_USER: ${POSTGRES_USER:-setrsoft} | ||
| POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env or the environment} | ||
| SECRET_KEY: ${SECRET_KEY:?Set SECRET_KEY in .env or the environment} | ||
| POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD} | ||
| SECRET_KEY: ${SECRET_KEY:?Set SECRET_KEY} | ||
| DEBUG: ${DEBUG:-False} | ||
| ALLOWED_HOSTS: ${ALLOWED_HOSTS:?Set ALLOWED_HOSTS in .env} | ||
| ALLOWED_HOSTS: ${ALLOWED_HOSTS:?Set ALLOWED_HOSTS} | ||
| CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS:-http://${SERVER_IP}} | ||
| TRUST_PROXY: ${TRUST_PROXY:-1} | ||
| depends_on: | ||
| db: | ||
| condition: service_healthy | ||
| networks: | ||
| - setrsoft_network | ||
| - internal_bridge | ||
|
|
||
| web: | ||
| build: | ||
|
|
@@ -59,18 +49,34 @@ services: | |
| - VITE_PUBLIC_POSTHOG_PROJECT_TOKEN=${VITE_PUBLIC_POSTHOG_PROJECT_TOKEN:-} | ||
| - VITE_PUBLIC_POSTHOG_HOST=${VITE_PUBLIC_POSTHOG_HOST:-} | ||
| container_name: setrsoft-frontend | ||
| restart: unless-stopped | ||
| labels: | ||
| - "traefik.enable=true" | ||
| - "traefik.docker.network=${DOCKER_NETWORK_NAME:-default}" | ||
| # HTTP → redirect HTTPS | ||
| - "traefik.http.routers.setrsoft-http.rule=Host(`setrsoft.com`) || Host(`www.setrsoft.com`)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The domain name is hardcoded, which limits the flexibility of the production configuration. It is better to use the - "traefik.http.routers.setrsoft-http.rule=Host(`${SERVER_IP}`) || Host(`www.${SERVER_IP}`)" |
||
| - "traefik.http.routers.setrsoft-http.entrypoints=http" | ||
| - "traefik.http.routers.setrsoft-http.middlewares=redirect-to-https" | ||
| - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" | ||
| # HTTPS | ||
| - "traefik.http.routers.setrsoft-https.rule=Host(`setrsoft.com`) || Host(`www.setrsoft.com`)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| - "traefik.http.routers.setrsoft-https.entrypoints=https" | ||
| - "traefik.http.routers.setrsoft-https.tls=true" | ||
| - "traefik.http.routers.setrsoft-https.tls.certresolver=letsencrypt" | ||
| # Service | ||
| - "traefik.http.services.setrsoft-web.loadbalancer.server.port=80" | ||
|
Comment on lines
+62
to
+67
|
||
| depends_on: | ||
| - backend | ||
| networks: | ||
| - setrsoft_network | ||
| - proxy-tier | ||
| - internal_bridge | ||
| - public_gateway | ||
|
|
||
| volumes: | ||
| postgres_data_prod: | ||
|
|
||
| networks: | ||
| setrsoft_network: | ||
| internal_bridge: | ||
| driver: bridge | ||
| proxy-tier: | ||
| public_gateway: | ||
| external: true | ||
| name: ${DOCKER_NETWORK_NAME:-proxy-tier} | ||
| name: ${DOCKER_NETWORK_NAME:-default} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment header formatting is inconsistent with the rest of the file:
#Dockeris missing a space (# Docker).