diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 63a51bb..bfdcfc6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,22 +25,22 @@ jobs: with: ssh-private-key: ${{ secrets.SSH_KEY }} - - name: Copy files to server + - name: Copy Docker files to server run: | - scp -o StrictHostKeyChecking=no docker-compose.yml Dockerfile ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera/ - scp -o StrictHostKeyChecking=no target/munera-1.0-SNAPSHOT.jar ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera/ + scp -o StrictHostKeyChecking=no docker-compose.yml Dockerfile ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/effe/munera/ - - name: Deploy using Docker Compose + - name: Deploy Docker containers run: | ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF' - cd /home/${{ secrets.SSH_USER }}/munera - - # Stop and remove only the specific application container - docker stop vaadin-app || true - docker rm vaadin-app || true + cd /home/effe/munera - # Build and start the containers (including the database container) + # Stop and remove existing containers for vaadin-app only + docker-compose stop vaadin-app || true + docker-compose rm -f vaadin-app || true + + # Rebuild and restart containers using docker-compose docker-compose up -d --build + EOF env: DB_ADDRESS: ${{ secrets.DB_ADDRESS }}