xpeditis2.0/docker/deploy-to-portainer.sh
David d65cb721b5
Some checks are pending
CD Production (Hetzner k3s) / Promote Images (preprod → prod) (push) Waiting to run
CD Production (Hetzner k3s) / Deploy to k3s (xpeditis-prod) (push) Blocked by required conditions
CD Production (Hetzner k3s) / Smoke Tests (push) Blocked by required conditions
CD Production (Hetzner k3s) / Deployment Summary (push) Blocked by required conditions
CD Production (Hetzner k3s) / Notify Success (push) Blocked by required conditions
CD Production (Hetzner k3s) / Notify Failure (push) Blocked by required conditions
chore: sync full codebase from cicd branch
Aligns main with the complete application codebase (cicd branch).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 12:56:44 +02:00

147 lines
3.6 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# ============================================================================
# Script de Déploiement Portainer - Xpeditis
# ============================================================================
# Ce script build et push les images Docker vers le registry Scaleway
# Usage: ./deploy-to-portainer.sh [backend|frontend|all]
# ============================================================================
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
REGISTRY="rg.fr-par.scw.cloud/weworkstudio"
TAG="preprod"
# Functions
print_header() {
echo -e "\n${BLUE}========================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}========================================${NC}\n"
}
print_success() {
echo -e "${GREEN}$1${NC}"
}
print_error() {
echo -e "${RED}$1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_info() {
echo -e "${BLUE} $1${NC}"
}
# Check if Docker is running
check_docker() {
print_info "Checking Docker..."
if ! docker info > /dev/null 2>&1; then
print_error "Docker is not running. Please start Docker Desktop."
exit 1
fi
print_success "Docker is running"
}
# Build and push backend
build_backend() {
print_header "Building Backend Image"
cd apps/backend
print_info "Building image: ${REGISTRY}/xpeditis-backend:${TAG}"
docker build -t ${REGISTRY}/xpeditis-backend:${TAG} .
print_success "Backend image built successfully"
print_info "Pushing image to registry..."
docker push ${REGISTRY}/xpeditis-backend:${TAG}
print_success "Backend image pushed successfully"
cd ../..
}
# Build and push frontend
build_frontend() {
print_header "Building Frontend Image"
cd apps/frontend
print_info "Building image: ${REGISTRY}/xpeditis-frontend:${TAG}"
docker build -t ${REGISTRY}/xpeditis-frontend:${TAG} .
print_success "Frontend image built successfully"
print_info "Pushing image to registry..."
docker push ${REGISTRY}/xpeditis-frontend:${TAG}
print_success "Frontend image pushed successfully"
cd ../..
}
# Main script
main() {
print_header "Xpeditis Deployment Script"
# Check Docker
check_docker
# Get target from argument
TARGET=${1:-all}
case $TARGET in
backend)
build_backend
;;
frontend)
build_frontend
;;
all)
build_backend
build_frontend
;;
*)
print_error "Invalid target: $TARGET"
echo "Usage: $0 [backend|frontend|all]"
exit 1
;;
esac
print_header "Deployment Summary"
if [ "$TARGET" = "all" ] || [ "$TARGET" = "backend" ]; then
echo -e "Backend: ${GREEN}${REGISTRY}/xpeditis-backend:${TAG}${NC}"
fi
if [ "$TARGET" = "all" ] || [ "$TARGET" = "frontend" ]; then
echo -e "Frontend: ${GREEN}${REGISTRY}/xpeditis-frontend:${TAG}${NC}"
fi
echo ""
print_success "Images successfully built and pushed!"
echo ""
print_warning "Next Steps:"
echo " 1. Go to Portainer: https://portainer.weworkstudio.com"
echo " 2. Navigate to: Stacks → xpeditis-preprod"
echo " 3. Click 'Update the stack'"
echo " 4. Check '✅ Re-pull image and redeploy'"
echo " 5. Click 'Update'"
echo ""
print_info "Documentation: DEPLOYMENT_CHECKLIST.md"
}
# Run main
main "$@"