Swarmlab docs

Application development in a distributed system

Development of Distributed Systems from Design to Application


You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
2.8 KiB

3 years ago
= Deploy
== Create Yaml file
.docker-compose
[source,yaml]
----
services:
3 years ago
myapp: //<1>
image: node:8.2.1-alpine //<2>
hostname: myapp
3 years ago
volumes:
3 years ago
- /PATH_to_app/app.js:/code/app.js //<3>
- /PATH_to_app/index.html:/code/index.html //<3>
3 years ago
ports:
3 years ago
- "8000:8000" //<4>
3 years ago
networks:
3 years ago
- mynet //<5>
3 years ago
deploy:
restart_policy:
delay: 10s
max_attempts: 10
window: 60s
3 years ago
replicas: 1
3 years ago
placement:
constraints:
3 years ago
- node.labels.myapp==true //<6>
3 years ago
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}}
3 years ago
3 years ago
mybrowser:
3 years ago
image: hub.swarmlab.io:5480/hybrid-firefox
3 years ago
deploy:
mode: replicated
restart_policy:
delay: 10s
max_attempts: 10
window: 60s
replicas: 2
placement:
max_replicas_per_node: 1
constraints:
3 years ago
- node.labels.group==myapp
3 years ago
ports:
- "8080:80"
- "9443:443"
3 years ago
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>
3 years ago
- /tmp/.X11-unix:/tmp/.X11-unix //<10>
3 years ago
networks:
3 years ago
- myapp //<5>
3 years ago
#privileged: true
environment:
- DISPLAY=\${DISPLAY} //<10>
#cap_add:
# - NET_ADMIN //<11>
3 years ago
networks:
3 years ago
myapp: //<5>
3 years ago
driver: overlay
3 years ago
3 years ago
----
<1> Service name
<2> Image name
3 years ago
<3> Volume (bind) to Use
3 years ago
<4> Expose port
<5> Network to Use
<6> Node Placement
<7> Start server
3 years ago
<8> Resources config
<9> Restart policy
3 years ago
<10> X app
<11> use host net
3 years ago
3 years ago
== start service
=== docker-compose
.Docker-compose
[source,bash]
----
env MYPASSWORD=v9ptvq4dedcrtcrykjcubk28j \
docker-compose -f file.yml up
----
=== docker swarm
.Docker swarm
[source,bash]
----
env PASSWORD=K507R1zQ6Jifc9MAW3 \
docker stack deploy -c file.yml ondemand_os2
----
== stop service
=== docker-compose
.Docker-compose
[source,bash]
----
docker-compose -f file.yml down
----
=== docker swarm
.Docker swarm
[source,bash]
----
docker service rm ondemand_os2_myapp
docker service rm ondemand_os2_wyweb
----
3 years ago