Last active
March 9, 2023 07:38
-
-
Save aalokt89/a861ffb9034f24654633c074c3e367b5 to your computer and use it in GitHub Desktop.
docker swarm stack example
This file contains 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.8" | |
services: | |
web: | |
image: httpd:2.4.55 | |
ports: | |
- 80:80 | |
networks: | |
- frontend | |
deploy: | |
replicas: 10 | |
placement: | |
constraints: [node.role == worker] | |
restart_policy: | |
condition: on-failure | |
node: | |
image: node:19-alpine3.16 | |
networks: | |
- frontend | |
- backend | |
command: ["sleep", "10000"] # this is only to force keep the conotainer running since there is no actual app code | |
deploy: | |
replicas: 4 | |
placement: | |
constraints: [node.role == worker] | |
restart_policy: | |
condition: on-failure | |
db: | |
image: postgres:15.2 | |
volumes: | |
- db-data:/var/lib/postgresql/data | |
environment: | |
- POSTGRES_PASSWORD=mypass | |
networks: | |
- backend | |
deploy: | |
replicas: 1 | |
placement: | |
constraints: [node.role == worker] | |
restart_policy: | |
condition: on-failure | |
visualizer: | |
image: bretfisher/visualizer | |
ports: | |
- 8080:8080 | |
stop_grace_period: 1m30s | |
networks: | |
- frontend | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
deploy: | |
placement: | |
constraints: [node.role == manager] | |
networks: | |
frontend: | |
driver: bridge | |
backend: | |
driver: bridge | |
volumes: | |
db-data: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment