diff --git a/.env b/.env index 4891a51c13..c6f805a3a8 100644 --- a/.env +++ b/.env @@ -1,10 +1,3 @@ -# Domain -# This would be set to the production domain with an env var on deployment -# used by Traefik to transmit traffic and acquire TLS certificates -DOMAIN=localhost -# To test the local Traefik config -# DOMAIN=localhost.tiangolo.com - # Environment: local, staging, production ENVIRONMENT=local diff --git a/compose.deploy.yml b/compose.deploy.yml index a54c2d4488..6ee6c9b099 100644 --- a/compose.deploy.yml +++ b/compose.deploy.yml @@ -38,7 +38,7 @@ services: restart: always labels: # Route HTTPS traffic for the Adminer subdomain - - traefik.http.routers.adminer-https.rule=Host(`adminer.${DOMAIN?Variable not set}`) + - traefik.http.routers.adminer-https.rule=Host(`adminer.${DOMAIN:?Variable not set}`) - traefik.http.routers.adminer-https.entrypoints=https - traefik.http.routers.adminer-https.tls=true # Use the Let's Encrypt resolver @@ -46,15 +46,15 @@ services: prestart: environment: - FRONTEND_HOST: https://${DOMAIN?Variable not set} + FRONTEND_HOST: https://${DOMAIN:?Variable not set} backend: restart: always environment: - FRONTEND_HOST: https://${DOMAIN?Variable not set} + FRONTEND_HOST: https://${DOMAIN:?Variable not set} labels: # Route HTTPS traffic for this domain - - traefik.http.routers.backend-https.rule=Host(`${DOMAIN?Variable not set}`) + - traefik.http.routers.backend-https.rule=Host(`${DOMAIN:?Variable not set}`) - traefik.http.routers.backend-https.entrypoints=https - traefik.http.routers.backend-https.tls=true # Use the Let's Encrypt resolver diff --git a/compose.override.yml b/compose.override.yml index f056a2ec43..2206fe267c 100644 --- a/compose.override.yml +++ b/compose.override.yml @@ -94,8 +94,8 @@ services: - backend - mailcatcher environment: - - FIRST_SUPERUSER=${FIRST_SUPERUSER?Variable not set} - - FIRST_SUPERUSER_PASSWORD=${FIRST_SUPERUSER_PASSWORD?Variable not set} + - FIRST_SUPERUSER=${FIRST_SUPERUSER:?Variable not set} + - FIRST_SUPERUSER_PASSWORD=${FIRST_SUPERUSER_PASSWORD:?Variable not set} - PLAYWRIGHT_BASE_URL=http://backend:8000 - VITE_API_URL=http://backend:8000 - MAILCATCHER_HOST=http://mailcatcher:1080 diff --git a/compose.yml b/compose.yml index b59c2d5700..0d164713e9 100644 --- a/compose.yml +++ b/compose.yml @@ -28,9 +28,9 @@ services: volumes: - app-db-data:/var/lib/postgresql environment: - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set} - - POSTGRES_USER=${POSTGRES_USER?Variable not set} - - POSTGRES_DB=${POSTGRES_DB?Variable not set} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?Variable not set} + - POSTGRES_USER=${POSTGRES_USER:?Variable not set} + - POSTGRES_DB=${POSTGRES_DB:?Variable not set} adminer: image: adminer @@ -42,7 +42,7 @@ services: # Enable Traefik for this service - traefik.enable=true # Route HTTP traffic for the Adminer subdomain - - traefik.http.routers.adminer-http.rule=Host(`adminer.${DOMAIN?Variable not set}`) + - traefik.http.routers.adminer-http.rule=Host(`adminer.${DOMAIN:-localhost}`) - traefik.http.routers.adminer-http.entrypoints=http # Define the port inside of the Docker service to use - traefik.http.services.adminer.loadbalancer.server.port=8080 @@ -57,19 +57,19 @@ services: condition: service_completed_successfully # The YAML anchor lets the prestart service reuse this environment mapping. environment: &backend-environment - PROJECT_NAME: ${PROJECT_NAME?Variable not set} + PROJECT_NAME: ${PROJECT_NAME:?Variable not set} BACKEND_CORS_ORIGINS: ${BACKEND_CORS_ORIGINS:-} - SECRET_KEY: ${SECRET_KEY?Variable not set} - FIRST_SUPERUSER: ${FIRST_SUPERUSER?Variable not set} - FIRST_SUPERUSER_PASSWORD: ${FIRST_SUPERUSER_PASSWORD?Variable not set} + SECRET_KEY: ${SECRET_KEY:?Variable not set} + FIRST_SUPERUSER: ${FIRST_SUPERUSER:?Variable not set} + FIRST_SUPERUSER_PASSWORD: ${FIRST_SUPERUSER_PASSWORD:?Variable not set} SMTP_HOST: ${SMTP_HOST} SMTP_USER: ${SMTP_USER:-} SMTP_PASSWORD: ${SMTP_PASSWORD:-} EMAILS_FROM_EMAIL: ${EMAILS_FROM_EMAIL} POSTGRES_SERVER: db - POSTGRES_DB: ${POSTGRES_DB} - POSTGRES_USER: ${POSTGRES_USER?Variable not set} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD?Variable not set} + POSTGRES_DB: ${POSTGRES_DB:?Variable not set} + POSTGRES_USER: ${POSTGRES_USER:?Variable not set} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Variable not set} SENTRY_DSN: ${SENTRY_DSN:-} healthcheck: @@ -89,7 +89,7 @@ services: - traefik.http.services.backend.loadbalancer.server.port=8000 # Route HTTP traffic for this domain - - traefik.http.routers.backend-http.rule=Host(`${DOMAIN?Variable not set}`) + - traefik.http.routers.backend-http.rule=Host(`${DOMAIN:-localhost}`) - traefik.http.routers.backend-http.entrypoints=http prestart: diff --git a/deployment.md b/deployment.md index 832d2d5462..48df8b516a 100644 --- a/deployment.md +++ b/deployment.md @@ -46,7 +46,7 @@ Copy the content and use that as password / secret key. And run that again to ge ### Required Environment Variables -Set the `DOMAIN`, by default `localhost` (for development), but when deploying you would use your own domain, for example: +Set the `DOMAIN` to your own domain, for example: ```bash export DOMAIN=fastapi-project.example.com