# Use the custom label "traefik.constraint-label=traefik-public"
# This public Traefik will only use services with this label
# That way you can add other internal Traefik instances per stack if needed
# - "traefik.constraint-label=traefik-public"
# Enable ACME (Let's Encrypt): automatic SSL.
# Email address used for registration. (Required)
- "--
certificatesresolvers.le.acme.email=NIKOLAY@gmail.com"
# File or key used for certificates storage. (Required)
- "--
certificatesresolvers.le.acme.storage=acme.json"
# KeyType to use (Optional) By default: "RSA4096" (Available "EC256", "EC384", "RSA2048", "RSA4096", "RSA8192")
- "--certificatesresolvers.le.acme.keytype=RSA4096"
# Use a TLS-ALPN-01 ACME challenge. (Optional, recommended)
- "--certificatesresolvers.le.acme.tlschallenge=true"
ports:
- "80:80"
- "8080:8080"
- "443:443" ##Docker sends requests on port 443 to Traefik on port 443
volumes:
# Add Docker as a mounted volume, so that Traefik can read the labels of other services
- /var/run/docker.sock:/var/run/docker.sock:ro
# Mount the volume to store the certificates
- traefik-public-certificates:/_data
networks:
- "traefik-public"
whoami:
image: "containous/whoami"
#If you use a compose file with the Swarm mode, labels should be defined in the deploy part of your service.
deploy:
labels:
# Explicitly tell Traefik to expose this container
- "traefik.enable=true"
# Allow request only from the predefined entry point named "web"
- "traefik.http.routers.whoami-http.entrypoints=web"
# The domain the service will respond to
- "traefik.http.routers.whoami-http.rule=Host(
whoami.volkov.club
)"
# Without this a 504 may occur. Defines a default docker network to use for connections to all containers.
- "
traefik.docker.network=traefik-public"
# Docker Swarm does not provide any port detection information to Traefik.
# Therefore you must specify the port to use for communication by using the label
- "traefik.http.services.whoami.loadbalancer.server.port=80"
##
- "traefik.http.routers.whoami-https.entrypoints=websecure"
- "traefik.http.routers.whoami-https.rule=Host(
whoami.volkov.club
)"
# Make HTTPS route
- traefik.http.routers.whoami-https.tls=true
- traefik.http.routers.whoami-https.tls.certresolver=le
networks:
- "traefik-public"
gitlab:
image: gitlab/gitlab-ce:latest
ports:
- "22:22"
deploy:
placement:
constraints:
-
node.id == ps8mhdq5gfw50343agb2v0smm
labels:
- traefik.enable=true
-
traefik.docker.network=traefik-public
- traefik.backend=gitlab
- traefik.backend.loadbalancer.swarm=true
- traefik.http.routers.gitlab-http.entrypoints=web
- traefik.http.routers.gitlab-http.rule=Host(
gitlab.volkov.club
)
- traefik.http.services.gitlab.loadbalancer.server.port=80
- traefik.http.routers.gitlab-http.service=gitlab
volumes:
- /srv/gitlab/data/:/var/opt/gitlab
- /srv/gitlab/logs/:/var/log/gitlab
- /srv/gitlab/config/:/etc/gitlab
environment:
GITLAB_OMNIBUS_CONFIG: "from_file('/omnibus_config.rb')"
configs:
- source: gitlab
target: /omnibus_config.rb
secrets:
- gitlab_root_password
networks:
- "traefik-public"
gitlab-runner:
image: gitlab/gitlab-runner:alpine
deploy:
mode: replicated
replicas: 4
labels:
- traefik.enable=true
-
traefik.docker.network=traefik-public
configs:
gitlab:
file: ./gitlab.rb
secrets:
gitlab_root_password:
file: ./root_password.txt
volumes:
# Create a volume to store the certificates, there is a constraint to make sure
# Traefik is always deployed to the same Docker node with the same volume containing
# the HTTPS certificates
traefik-public-certificates: