Improve deployment script with better diagnostics and more resilient node constraints

This commit is contained in:
Colin 2025-10-12 22:26:35 -04:00
parent 7605702fc1
commit 3fcf235f36
Signed by: colin
SSH Key Fingerprint: SHA256:nRPCQTeMFLdGytxRQmPVK9VXY3/ePKQ5lGRyJhT5DY8
2 changed files with 25 additions and 9 deletions

View File

@ -23,13 +23,29 @@ steps:
- echo "nameserver 1.0.0.1" >> /etc/resolv.conf - echo "nameserver 1.0.0.1" >> /etc/resolv.conf
- HOSTNAME=$(docker info --format "{{.Name}}") - HOSTNAME=$(docker info --format "{{.Name}}")
- echo "Deploying on $HOSTNAME" - echo "Deploying on $HOSTNAME"
- docker node ls >/dev/null 2>&1 || (echo "Runner must be on a Swarm manager" && exit 1) - docker node ls || (echo "Runner must be on a Swarm manager" && exit 1)
- mkdir -p /mnt/data/nixc.us/woodpecker/production/db /mnt/data/nixc.us/woodpecker/production/data - echo "Checking for existing networks..."
- chmod -R 777 /mnt/data/nixc.us/woodpecker/production - docker network ls
- echo "Starting deployment in background - CI job will complete while services update" - echo "Creating required directories..."
- (sleep 5 && docker stack deploy --with-registry-auth -c stack.yml woodpecker) & - mkdir -p /mnt/data/nixc.us/woodpecker/production/db /mnt/data/nixc.us/woodpecker/production/data || true
- sleep 3 - chmod -R 777 /mnt/data/nixc.us/woodpecker/production || true
- echo "Deployment initiated successfully - CI job completing" - echo "Ensuring traefik network exists..."
- docker network create --driver=overlay --attachable traefik || true
- echo "Removing any existing stack..."
- docker stack rm woodpecker || true
- echo "Waiting for cleanup..."
- sleep 10
- echo "Deploying stack..."
- docker stack deploy --with-registry-auth -c stack.yml woodpecker
- echo "Waiting for services to start..."
- sleep 15
- echo "Service status:"
- docker service ls | grep woodpecker
- echo "Checking logs for server:"
- docker service logs --tail 10 woodpecker_server || true
- echo "Checking logs for database:"
- docker service logs --tail 10 woodpecker_db || true
- echo "Deployment completed"
when: when:
branch: main branch: main
event: [push] event: [push]

View File

@ -20,7 +20,7 @@ services:
replicas: 1 replicas: 1
placement: placement:
constraints: constraints:
- node.hostname == macmini1 - node.role == manager
labels: labels:
- "traefik.enable=false" - "traefik.enable=false"
update_config: update_config:
@ -63,7 +63,7 @@ services:
replicas: 1 replicas: 1
placement: placement:
constraints: constraints:
- node.hostname == macmini1 - node.role == manager
labels: labels:
# Web UI Configuration # Web UI Configuration
traefik.enable: "true" traefik.enable: "true"