Skip to content

Instantly share code, notes, and snippets.

@ohlookemus
Created January 29, 2018 18:26
Show Gist options
  • Save ohlookemus/5bcfe93b092b86287d2902e9fc17084e to your computer and use it in GitHub Desktop.
Save ohlookemus/5bcfe93b092b86287d2902e9fc17084e to your computer and use it in GitHub Desktop.
Sample Docker Compose Traefik Config
version: '3'
services:
api:
container_name: api
restart: always
image: registry.example.com/example/example-api:prd
build: .
expose:
- "8000"
env_file: .env
labels:
- "traefik.enable=true"
- "traefik.protocol=http"
- "traefik.port=8000"
- "traefik.backend=example_api"
- "traefik.frontend.passHostHeader=true"
- "traefik.frontend.rule=Host:api.example.com"
- "traefik.docker.network=exampleapi_proxy"
environment:
PYTHONUNBUFFERED: 'true'
networks:
- back-end
- proxy
command: >
/usr/local/bin/gunicorn -w 2 -b :8000
--access-logfile -
--reload
example.app:create_app()
dashboard:
container_name: dashboard
restart: always
image: registry.example.com/portal/dashboard:prd
labels:
- "traefik.enable=true"
- "traefik.protocol=http"
- "traefik.port=8080"
- "traefik.backend=dashboard"
- "traefik.frontend.passHostHeader=true"
- "traefik.frontend.rule=Host:hive.example.com"
- "traefik.docker.network=exampleapi_proxy"
expose:
- "8080"
networks:
- proxy
example_dashboard:
container_name: example_dashboard
restart: always
image: registry.example.com/portal/example-frontend:prd
labels:
- "traefik.enable=true"
- "traefik.protocol=http"
- "traefik.port=8080"
- "traefik.backend=example_dashboard"
- "traefik.frontend.passHostHeader=true"
- "traefik.frontend.rule=Host:hive.example.com;PathPrefixStrip:/example"
- "traefik.docker.network=exampleapi_proxy"
expose:
- "8080"
networks:
- proxy
proxy:
restart: always
image: traefik:latest
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik.toml:/traefik.toml
networks:
- proxy
volumes:
redis: {}
es_data: {}
networks:
proxy:
back-end:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment