Add swarm config

This commit is contained in:
lif
2025-10-10 19:36:51 +01:00
parent 520fef57a1
commit 069ac709e1
9 changed files with 594 additions and 285 deletions

74
docker-stack.yml Normal file
View File

@@ -0,0 +1,74 @@
version: '3.8'
services:
portainer:
image: portainer/portainer-ce:latest
ports:
- "9000:9000"
- "9443:9443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
networks:
- swarm-network
traefik:
image: traefik:v2.10
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command:
- --api.dashboard=true
- --api.insecure=true
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
networks:
- swarm-network
web-app:
image: nginx:alpine
deploy:
replicas: 3
restart_policy:
condition: on-failure
labels:
- traefik.enable=true
- traefik.http.routers.webapp.rule=Host(`192.168.56.10`)
- traefik.http.services.webapp.loadbalancer.server.port=80
networks:
- swarm-network
hello-world:
image: hello-world:latest
deploy:
replicas: 2
restart_policy:
condition: on-failure
networks:
- swarm-network
volumes:
portainer_data:
driver: local
networks:
swarm-network:
driver: overlay
attachable: true