fix(deploy): force remove containers before deployment
All checks were successful
Test Runner / test-basic (push) Successful in 9s
Test Runner / test-php (push) Successful in 8s
Deploy Application / deploy (push) Successful in 43s

The --force-recreate flag alone doesn't handle containers that exist
outside the compose project context. Now explicitly:
1. Run docker compose down first
2. Force remove any orphaned containers with known names
3. Then create fresh containers
This commit is contained in:
2025-11-24 22:10:38 +01:00
parent 6c266861ec
commit 5e74ce73a6

View File

@@ -117,10 +117,20 @@ fi
print_info "Pulling latest images..."
docker compose $COMPOSE_FILES pull || print_warning "Failed to pull some images, continuing..."
# Stop and remove existing containers to prevent name conflicts
print_info "Stopping existing containers..."
docker compose $COMPOSE_FILES down --remove-orphans || print_warning "No existing containers to stop"
# Remove any orphaned containers with conflicting names
for container in nginx php redis scheduler queue-worker; do
if docker ps -a --format '{{.Names}}' | grep -q "^${container}$"; then
print_warning "Removing orphaned container: $container"
docker rm -f "$container" 2>/dev/null || true
fi
done
# Deploy stack
print_info "Deploying application stack..."
# --force-recreate: Recreate containers even if unchanged
# --remove-orphans: Remove containers for services not in compose file
docker compose $COMPOSE_FILES up -d --force-recreate --remove-orphans
# Wait for services to be healthy