Last active
July 5, 2020 13:20
-
-
Save back-2-95/3fe30a9fe538d3abb1198aa6ed766559 to your computer and use it in GitHub Desktop.
Local development support for Traefik v1 and v2 in the same project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
services: | |
app: | |
labels: | |
# Traefik 2 labels, note that I point to container_name of app service with ${COMPOSE_PROJECT_NAME}-app. | |
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-app.entrypoints=https" | |
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-app.rule=Host(`${APP_HOSTNAME}`)" | |
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-app.tls=true" | |
- "traefik.http.services.${COMPOSE_PROJECT_NAME}-app.loadbalancer.server.port=8080" | |
- "traefik.docker.network=my-network" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
services: | |
app: | |
hostname: "${APP_HOSTNAME}" | |
container_name: "${COMPOSE_PROJECT_NAME}-app" | |
image: "${APP_IMAGE}" | |
volumes: | |
- .:/app:delegated | |
environment: | |
APP_ENV: "${APP_ENV}" | |
networks: | |
- internal | |
- my-network | |
labels: | |
# Shared label for both Traefik 1 and 2 | |
traefik.enable: true | |
# Traefik 1 labels | |
traefik.port: 8080 | |
traefik.frontend.rule: "Host:${APP_HOSTNAME}" | |
traefik.frontend.redirect.entryPoint: https | |
db: | |
container_name: "${COMPOSE_PROJECT_NAME}-db" | |
image: mysql:5.7 | |
volumes: | |
- db_data:/var/lib/mysql | |
ports: | |
- 3306 | |
networks: | |
- internal | |
networks: | |
internal: | |
external: false | |
my-network: | |
external: true | |
volumes: | |
db_data: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Traefik v1.7 or v2.2 is running on the same network (my-network).
Labels can be also in the same file but then they need to be written in following format:
instead of