Skip to content

Instantly share code, notes, and snippets.

@yuklia
Created February 12, 2019 21:47
Show Gist options
  • Save yuklia/e22087b565bf576bc98cb95f73004694 to your computer and use it in GitHub Desktop.
Save yuklia/e22087b565bf576bc98cb95f73004694 to your computer and use it in GitHub Desktop.
Traefik with SSL certs Letsencrypt on Docker Swarm
version: '3.4'
services:
traefik:
image: ${REGISTRY}/traefik
build:
context: ./reverse-proxy/
command:
- "--web"
- "--entrypoints=Name:http Address::80 Redirect.EntryPoint:https"
- "--entrypoints=Name:https Address::443 TLS"
- "--defaultEntryPoints=http,https"
- "--acme"
- "--acme.storage=/etc/traefik/acme/acme.json"
- "--acme.entryPoint=https"
- "--acme.httpChallenge.entryPoint=http"
- "--acme.onHostRule=true"
- "--acme.onDemand=false"
- "--acme.email=letitbe@yopmail.com"
- "--docker"
- "--docker.swarmMode"
- "--docker.domain=tk"
- "--docker.watch"
- "--logLevel=DEBUG"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- traefik
ports:
- 80:80
- 443:443
- 8080:8080
deploy:
mode: global
update_config:
parallelism: 1
delay: 10s
labels:
- traefik.enable=false
restart_policy:
condition: on-failure
jenkins:
image: ${REGISTRY}/jenkins
build:
context: ./tools/jenkins
container_name: jenkins
deploy:
mode: replicated
replicas: 1
restart_policy:
condition: on-failure
labels:
- com.docker.stack.namespace=tool
- traefik.frontend.passHostHeader=true
- traefik.backend.loadbalancer.swarm=true
- traefik.backend=jenkins
- traefik.port=8080
- traefik.frontend.rule=Host:${HOSTNAME_JENKINS}
- traefik.docker.network=traefik
- traefik.frontend.entryPoints=http,https
- traefik.enable=true
ports:
- 8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- jenkins_home:/var/jenkins_home
networks:
- tool
- traefik
portainer:
image: portainer/portainer:1.20.0
container_name: portainer
command: -H unix:///var/run/docker.sock
deploy:
mode: replicated
replicas: 1
restart_policy:
condition: on-failure
labels:
- com.docker.stack.namespace=tool
- traefik.frontend.passHostHeader=true
- traefik.backend.loadbalancer.swarm=true
- traefik.backend=portainer
- traefik.port=9000
- traefik.frontend.rule=Host:${HOSTNAME_PORTAINER}
- traefik.docker.network=traefik
- traefik.frontend.entryPoints=http,https
- traefik.enable=true
ports:
- 9000
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
- portainer_data:/data
networks:
- tool
- traefik
agent:
image: portainer/agent
environment:
AGENT_CLUSTER_ADDR: tasks.agent
AGENT_PORT: 9001
LOG_LEVEL: debug
ports:
- target: 9001
published: 9001
protocol: tcp
mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- tool
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
volumes:
jenkins_home:
portainer_data:
networks:
tool:
driver: overlay
attachable: true
external: true
traefik:
driver: overlay
attachable: true
external: true
@jameslee007
Copy link

Hi , Can you please share the Dockerfile?

I am Running this and it gives "command traefik error: failed to decode configuration from flags: field not found, node: acme: error.

Thanks in advance.

@tronicanet
Copy link

FROM traefik:alpine

RUN mkdir -pv /etc/traefik/acme &&
touch /etc/traefik/acme/acme.json &&
chmod 600 /etc/traefik/acme/acme.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment