image: atlassian/default-image:2

pipelines:
  default:
    - step:
        name: Deploiement container unique (multi-projets PHP)
        script:
          - pipe: atlassian/ssh-run:0.8.0
            variables:
              SSH_USER: $SSH_USER
              SERVER: $SSH_HOST
              COMMAND: |
                set -euo pipefail

                # Aller a la racine du repo sur le VPS (adapte si besoin)
                cd ~/tools

                # Mettre a jour le code
                git fetch origin master
                git reset --hard origin/master

                # Build & (re)start du container unique
                test -f docker-compose.yaml || { echo "docker-compose.yaml manquant a la racine"; exit 1; }
                docker compose -p tools-php -f docker-compose.yaml build --pull
                docker compose -p tools-php -f docker-compose.yaml up -d --remove-orphans

                # Checks utiles
                docker compose -p tools-php -f docker-compose.yaml ps || true
                ss -ltnp | grep ':4010' || true
