Skip to content

Instantly share code, notes, and snippets.

@shirren
Created September 4, 2017 05:05
Show Gist options
  • Save shirren/ad9f046094dedf973f98430f7846f463 to your computer and use it in GitHub Desktop.
Save shirren/ad9f046094dedf973f98430f7846f463 to your computer and use it in GitHub Desktop.
Docker Swarm Compose yml with https redirection example
version: '3.1'
services:
traefik:
command:
- --web
- --docker
- --docker.swarmmode
- --docker.domain="mydomain.com"
- --docker.watch
- --logLevel=WARN
- --entrypoints=Name:http Address::80 Redirect.EntryPoint:https
- --entryPoints=Name:https Address::443 TLS:/ssl/public.cert,/ssl/private.key
- --defaultentrypoints=https,http
deploy:
placement:
constraints: [node.role == manager]
restart_policy:
condition: on-failure
image: traefik
networks:
- app_network
ports:
- 80:80
- 443:443
- 8080:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /ssl:/ssl
springapp:
deploy:
labels:
- "traefik:backend=springapp"
- "traefik.frontend.rule=HostRegexp:mydomain.com,{subdomain:[a-zA-Z0-9-]+}.mydomain.com"
- "traefik.port=8000"
- "traefik.tags=web"
mode: replicated
replicas: 2
restart_policy:
condition: on-failure
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
image: mycompany/springapp
networks:
- app_network
networks:
app_network:
external: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment