Service Management¶
Deploy¶
task deploy # Every stack
task deploy -- homepage # One stack
task deploy -- cicd forgejo # A subset
task deploy:plan -- homepage # What a deploy would change, without doing it
A named stack always deploys. Anything it needs, and anything swept in by a bare
task deploy, is ensured: deployed only if it has not already converged. That is
also the resume — a run killed partway is finished by running the same command again.
task ansible:cluster:up # bring the cluster up (swarm, labels, storage)
task deploy:full # bootstrap + cluster:up + deploy
Status¶
docker stack ls # List deployed stacks
docker stack services homepage # Services in a stack
docker service logs homepage_homepage --tail 50 -f # Logs
docker service ps homepage_homepage # Task placement/errors
Remove¶
task ansible:teardown:service -- -e "stack_name=homepage" # Keep volumes
task ansible:teardown:service -- -e "stack_name=homepage remove_volumes=true" # Delete data
Add a New Service¶
# stacks/apps/myservice/docker-compose.yml
services:
myservice:
image: myapp:latest
volumes:
- myservice_data:/data
networks:
- traefik-public
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.myservice.rule=Host(`myapp.${BASE_DOMAIN}`)"
- "traefik.http.routers.myservice.entrypoints=websecure"
- "traefik.http.routers.myservice.tls.certresolver=dns"
- "traefik.http.services.myservice.loadbalancer.server.port=8080"
- "traefik.swarm.network=traefik-public"
networks:
traefik-public:
external: true
volumes:
myservice_data:
driver: local
Storage Provisioning¶
iSCSI (databases, configs)¶
sudo mkdir -p /mnt/iscsi/app-data/myservice
sudo chown -R 1000:1000 /mnt/iscsi/app-data/myservice
# PostgreSQL needs UID 999
sudo chown -R 999:999 /mnt/iscsi/app-data/myservice/postgresql
CIFS (media, bulk files)¶
Create the share on your NAS. The deployment creates the Docker volume automatically using .env credentials.
volumes:
myservice_media:
driver: local
driver_opts:
type: "cifs"
o: "username=${SMB_USERNAME},password=${SMB_PASSWORD},vers=3.0"
device: "//${NAS_SERVER}/myservice"