diff --git a/deployment/scripts/deploy.sh b/deployment/scripts/deploy.sh index 92f85651..e9b1798f 100755 --- a/deployment/scripts/deploy.sh +++ b/deployment/scripts/deploy.sh @@ -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