✨ Traefik v2 by tiangolo · Pull Request #199 · fastapi/full-stack-fastapi-template · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions {{cookiecutter.project_slug}}/.env
41 changes: 26 additions & 15 deletions {{cookiecutter.project_slug}}/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@ services:
ports:
- "80:80"
- "8090:8080"
command: --docker \
--docker.watch \
--docker.exposedbydefault=false \
--constraints=tag==${TRAEFIK_TAG} \
--logLevel=DEBUG \
--accessLog \
--web
command:
# Enable Docker in Traefik, so that it reads labels from Docker services
- --providers.docker
# Add a constraint to only use services with the label for this stack
# from the env var TRAEFIK_TAG
- --providers.docker.constraints=Label(`traefik.constraint-label-stack`, `${TRAEFIK_TAG}`)
# Do not expose all Docker services, only the ones explicitly exposed
- --providers.docker.exposedbydefault=false
# Disable Docker Swarm mode for local development
# - --providers.docker.swarmmode
# Enable the access log, with HTTP requests
- --accesslog
# Enable the Traefik log, for configurations and errors
- --log
# Enable the Dashboard and API
- --api
# Enable the Dashboard and API in insecure mode for local development
- --api.insecure=true
labels:
- traefik.frontend.rule=Host:${DOMAIN}
- traefik.enable=true
- traefik.port=80
- traefik.http.routers.${STACK_NAME}-traefik-public-http.rule=Host(`${DOMAIN}`)
- traefik.http.services.${STACK_NAME}-traefik-public.loadbalancer.server.port=80

pgadmin:
ports:
Expand All @@ -42,10 +53,10 @@ services:
# command: bash -c "while true; do sleep 1; done" # Infinite loop to keep container live doing nothing
command: /start-reload.sh
labels:
- traefik.frontend.rule=PathPrefix:/api,/docs,/redoc
- traefik.enable=true
- traefik.port=80
- traefik.tags=${TRAEFIK_TAG}
- traefik.constraint-label-stack=${TRAEFIK_TAG}
- traefik.http.routers.${STACK_NAME}-backend-http.rule=PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`)
- traefik.http.services.${STACK_NAME}-backend.loadbalancer.server.port=80

celeryworker:
volumes:
Expand All @@ -67,10 +78,10 @@ services:
args:
FRONTEND_ENV: dev
labels:
- traefik.frontend.rule=PathPrefix:/
- traefik.enable=true
- traefik.port=80
- traefik.tags=${TRAEFIK_TAG}
- traefik.constraint-label-stack=${TRAEFIK_TAG}
- traefik.http.routers.${STACK_NAME}-frontend-http.rule=PathPrefix(`/`)
- traefik.http.services.${STACK_NAME}-frontend.loadbalancer.server.port=80

networks:
traefik-public:
Expand Down
120 changes: 78 additions & 42 deletions {{cookiecutter.project_slug}}/docker-compose.yml