From a2ffd714522a88cbadbdfd499244d196af29983e Mon Sep 17 00:00:00 2001 From: AV77web Date: Tue, 14 Jul 2026 16:15:32 +0200 Subject: [PATCH] modifiche a Dockerfile e inserito dockerfile.runtime --- .github/workflows/deploy.yml | 37 +++++++++++++++++++++++++++++------ docker-compose.prod.yml | 11 +++++++++++ dockerfile/Dockerfile.runtime | 8 ++++++++ 3 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 docker-compose.prod.yml create mode 100644 dockerfile/Dockerfile.runtime diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d89c3e8..466b2b0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,25 +18,50 @@ jobs: - run: npm run build env: VITE_API_URL: https://esameits24-26backend.andreavillari.it + - uses: https://github.com/actions/upload-artifact@v4 + with: + name: frontend-dist + path: dist/ + retention-days: 1 deploy: needs: build runs-on: ubuntu-latest - timeout-minutes: 45 + timeout-minutes: 15 steps: - uses: https://github.com/actions/checkout@v4 + + - uses: https://github.com/actions/download-artifact@v4 + with: + name: frontend-dist + path: dist + + - uses: https://github.com/appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.VPS_HOST }} + username: ${{ secrets.VPS_USER }} + key: ${{ secrets.VPS_SSH_KEY }} + source: "dist" + target: "/root/esameits24-26frontend" + overwrite: true + - uses: https://github.com/appleboy/ssh-action@v1.0.3 with: host: ${{ secrets.VPS_HOST }} username: ${{ secrets.VPS_USER }} key: ${{ secrets.VPS_SSH_KEY }} - command_timeout: 30m + command_timeout: 10m script: | + set -e echo "=== START $(date -Iseconds) ===" cd /root/esameits24-26frontend git pull --ff-only - echo "=== DOCKER BUILD $(date -Iseconds) ===" - docker compose --progress plain up -d --build + if [ ! -d dist ] || [ -z "$(ls -A dist 2>/dev/null)" ]; then + echo "ERRORE: dist/ mancante o vuota dopo SCP" + exit 1 + fi + echo "=== DOCKER BUILD RUNTIME $(date -Iseconds) ===" + docker compose -f docker-compose.prod.yml --progress plain up -d --build echo "=== END $(date -Iseconds) ===" - docker compose ps - echo "DEPLOY COMPLETE" \ No newline at end of file + docker compose -f docker-compose.prod.yml ps + echo "DEPLOY COMPLETE" diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..680d6c6 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,11 @@ +# Usato dal deploy CI: build solo nginx + dist (secondi, non minuti). +services: + app: + build: + context: . + dockerfile: dockerfile/Dockerfile.runtime + image: esameits24-26frontend-app:prod + container_name: esameits24-26frontend + restart: unless-stopped + ports: + - "127.0.0.1:3010:3010" diff --git a/dockerfile/Dockerfile.runtime b/dockerfile/Dockerfile.runtime new file mode 100644 index 0000000..45eb4d8 --- /dev/null +++ b/dockerfile/Dockerfile.runtime @@ -0,0 +1,8 @@ +# Immagine di produzione: serve la cartella dist giĆ  compilata in CI (nessun npm run build sulla VPS). +FROM nginx:alpine + +COPY dockerfile/nginx.conf /etc/nginx/conf.d/default.conf +COPY dist /usr/share/nginx/html + +EXPOSE 3010 +CMD ["nginx", "-g", "daemon off;"]