|
|
|
= Deploy
|
|
|
|
|
|
|
|
== Create Yaml file
|
|
|
|
|
|
|
|
.docker-compose
|
|
|
|
[source,yaml]
|
|
|
|
----
|
|
|
|
services:
|
|
|
|
myapp: //<1>
|
|
|
|
image: node:8.2.1-alpine //<2>
|
|
|
|
hostname: myapp
|
|
|
|
volumes:
|
|
|
|
- /PATH_to_app/app.js:/code/app.js //<3>
|
|
|
|
- /PATH_to_app/index.html:/code/index.html //<3>
|
|
|
|
ports:
|
|
|
|
- "8000:8000" //<4>
|
|
|
|
networks:
|
|
|
|
- mynet //<5>
|
|
|
|
deploy:
|
|
|
|
restart_policy:
|
|
|
|
delay: 10s
|
|
|
|
max_attempts: 10
|
|
|
|
window: 60s
|
|
|
|
replicas: 1
|
|
|
|
placement:
|
|
|
|
constraints:
|
|
|
|
- node.labels.myapp==true //<6>
|
|
|
|
resources: //<8>
|
|
|
|
limits:
|
|
|
|
cpus: '0.50'
|
|
|
|
memory: 500M
|
|
|
|
reservations:
|
|
|
|
cpus: '0.25'
|
|
|
|
memory: 200M
|
|
|
|
restart_policy: //<9>
|
|
|
|
condition: on-failure
|
|
|
|
delay: 5s
|
|
|
|
max_attempts: 5
|
|
|
|
window: 120s
|
|
|
|
update_config:
|
|
|
|
parallelism: 2
|
|
|
|
delay: 10s
|
|
|
|
order: stop-first
|
|
|
|
environment:
|
|
|
|
- MYPASSWORD=${PASSWORD}
|
|
|
|
- NODENAME={{.Node.Hostname}}
|
|
|
|
- NODEID={{.Node.ID}}
|
|
|
|
- SERVICEID={{.Service.ID}}
|
|
|
|
- SERVICENAME={{.Service.Name}}
|
|
|
|
- TASKID={{.Task.ID}}
|
|
|
|
- TASKNAME={{.Task.Name}}
|
|
|
|
- TASKREPID={{.Task.Slot}}
|
|
|
|
|
|
|
|
|
|
|
|
mybrowser:
|
|
|
|
image: nginx:1.17.9-alpine
|
|
|
|
deploy:
|
|
|
|
mode: replicated
|
|
|
|
restart_policy:
|
|
|
|
delay: 10s
|
|
|
|
max_attempts: 10
|
|
|
|
window: 60s
|
|
|
|
replicas: 2
|
|
|
|
placement:
|
|
|
|
max_replicas_per_node: 1
|
|
|
|
constraints:
|
|
|
|
- node.labels.group==myapp
|
|
|
|
ports:
|
|
|
|
- "8080:80"
|
|
|
|
- "9443:443"
|
|
|
|
volumes: //<7>
|
|
|
|
- /PATH_to_FILE/my.conf:/DIR_in_container/my.conf //<3>
|
|
|
|
#- /PATH_to_FILE/public.crt:/etc/nginx/public.crt //<3>
|
|
|
|
#- /PATH_to_FILE/private.key:/etc/nginx/private.key //<3>
|
|
|
|
networks:
|
|
|
|
- myapp //<5>
|
|
|
|
|
|
|
|
|
|
|
|
networks:
|
|
|
|
myapp: //<5>
|
|
|
|
driver: overlay
|
|
|
|
|
|
|
|
|
|
|
|
----
|
|
|
|
<1> Service name
|
|
|
|
<2> Image name
|
|
|
|
<3> Volume (bind) to Use
|
|
|
|
<4> Expose port
|
|
|
|
<5> Network to Use
|
|
|
|
<6> Node Placement
|
|
|
|
<7> Start server
|
|
|
|
<8> Resources config
|
|
|
|
<9> Restart policy
|
|
|
|
|
|
|
|
|
|
|
|
|