feat: Initial example of how to automatically update images at the edge with no downtime and automatic rollbacks
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
---
|
||||
services:
|
||||
diun:
|
||||
image: darkalex17/diun-docker:latest
|
||||
command: serve
|
||||
volumes:
|
||||
- "./data:/data"
|
||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||
- "./swarm-update.sh:/swarm-update.sh"
|
||||
- "/path/to/docker/config.json:/root/.docker/config.json:ro" # Specify the credentials config
|
||||
environment:
|
||||
- "LOG_LEVEL=info"
|
||||
- "LOG_JSON=false"
|
||||
- "DIUN_WATCH_WORKERS=20"
|
||||
- "DIUN_WATCH_SCHEDULE=*/1 * * * *" # Check once every minute
|
||||
- "DIUN_WATCH_JITTER=30s"
|
||||
- "DIUN_PROVIDERS_SWARM=true"
|
||||
- "DIUN_NOTIF_SCRIPT_CMD=sh"
|
||||
- "DIUN_NOTIF_SCRIPT_ARGS=/swarm-update.sh"
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.role == manager
|
||||
|
||||
radarr-mock:
|
||||
image: darkalex17/radarr-mock:latest
|
||||
ports:
|
||||
- 7878:7878
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:7878"] # Ensure the new container is healthy and functional so we know we can kill the old container
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 2
|
||||
start_period: 10s
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
max_attempts: 3 # At most, try 3 times to start the container
|
||||
delay: 5s
|
||||
update_config:
|
||||
order: start-first # Ensure a new container can be started before killing the old one
|
||||
failure_action: rollback
|
||||
delay: 10s
|
||||
parallelism: 1
|
||||
labels:
|
||||
- "diun.enable=true" # Tell diun to monitor this service/container's image
|
||||
Reference in New Issue
Block a user