Created
March 12, 2019 01:55
-
-
Save vovimayhem/fb50da3de63457577fe41e60d1c335de to your computer and use it in GitHub Desktop.
Docker Flow example for Docker Swarm
This file contains hidden or 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
# Deploy using `docker stack deploy -f docker-flow-stack.yml docker_flow` | |
version: '3.7' | |
networks: | |
network: # Allows referring to 'docker_flow_network' on other stacks | |
services: | |
proxy: | |
image: dockerflow/docker-flow-proxy:19.03.02-16 | |
ports: | |
- 80:80 | |
- 443:443 | |
networks: | |
- network | |
environment: | |
LISTENER_ADDRESS: swarm_listener | |
MODE: swarm | |
deploy: | |
mode: global | |
placement: | |
constraints: | |
- node.role == worker | |
swarm_listener: | |
image: dockerflow/docker-flow-swarm-listener:19.01.12-20 | |
networks: | |
- network | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
environment: | |
DF_NOTIFY_CREATE_SERVICE_URL: http://proxy:8080/v1/docker-flow-proxy/reconfigure | |
DF_NOTIFY_REMOVE_SERVICE_URL: http://proxy:8080/v1/docker-flow-proxy/remove | |
deploy: | |
placement: | |
constraints: | |
- node.role == manager |
This file contains hidden or 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
# Deploy using `docker stack deploy -f example-stack.yml example` | |
version: '3.7' | |
networks: | |
docker_flow_network: | |
external: true | |
services: | |
migrate: &app | |
image: your/image:latest | |
command: rails db:migrate | |
environment: | |
RAILS_MAX_THREADS: 25 | |
RAILS_LOG_TO_STDOUT: "true" | |
RAILS_SERVE_STATIC_FILES: "true" | |
DATABASE_URL: postgres://postgres@some-postgres-host:5432/example_production | |
RAILS_FORCE_SSL: "true" | |
deploy: &app_deploy | |
placement: | |
constraints: | |
- node.role == worker | |
resources: { reservations: { memory: "128M" }, limits: { memory: "256M" } } | |
restart_policy: | |
condition: on-failure | |
max_attempts: 3 | |
delay: 5s | |
web: | |
<<: *app | |
command: puma -t 2:25 -w 2 -p 3000 -e production | |
networks: | |
- docker_flow_network | |
deploy: | |
<<: *app_deploy | |
labels: | |
- com.df.notify=true | |
- com.df.distribute=true | |
- com.df.servicePath=/ | |
- com.df.serviceDomain=your.example.com,your.example.org | |
- com.df.port=3000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment