modifiche a Dockerfile e inserito dockerfile.runtime
This commit is contained in:
parent
05f1629aee
commit
a2ffd71452
3 changed files with 50 additions and 6 deletions
37
.github/workflows/deploy.yml
vendored
37
.github/workflows/deploy.yml
vendored
|
|
@ -18,25 +18,50 @@ jobs:
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
env:
|
env:
|
||||||
VITE_API_URL: https://esameits24-26backend.andreavillari.it
|
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:
|
deploy:
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 45
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- uses: https://github.com/actions/checkout@v4
|
- 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
|
- uses: https://github.com/appleboy/ssh-action@v1.0.3
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.VPS_HOST }}
|
host: ${{ secrets.VPS_HOST }}
|
||||||
username: ${{ secrets.VPS_USER }}
|
username: ${{ secrets.VPS_USER }}
|
||||||
key: ${{ secrets.VPS_SSH_KEY }}
|
key: ${{ secrets.VPS_SSH_KEY }}
|
||||||
command_timeout: 30m
|
command_timeout: 10m
|
||||||
script: |
|
script: |
|
||||||
|
set -e
|
||||||
echo "=== START $(date -Iseconds) ==="
|
echo "=== START $(date -Iseconds) ==="
|
||||||
cd /root/esameits24-26frontend
|
cd /root/esameits24-26frontend
|
||||||
git pull --ff-only
|
git pull --ff-only
|
||||||
echo "=== DOCKER BUILD $(date -Iseconds) ==="
|
if [ ! -d dist ] || [ -z "$(ls -A dist 2>/dev/null)" ]; then
|
||||||
docker compose --progress plain up -d --build
|
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) ==="
|
echo "=== END $(date -Iseconds) ==="
|
||||||
docker compose ps
|
docker compose -f docker-compose.prod.yml ps
|
||||||
echo "DEPLOY COMPLETE"
|
echo "DEPLOY COMPLETE"
|
||||||
|
|
|
||||||
11
docker-compose.prod.yml
Normal file
11
docker-compose.prod.yml
Normal file
|
|
@ -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"
|
||||||
8
dockerfile/Dockerfile.runtime
Normal file
8
dockerfile/Dockerfile.runtime
Normal file
|
|
@ -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;"]
|
||||||
Loading…
Add table
Reference in a new issue