CI: Gitea-Action baut und deployt bei Push auf main (Runner-Whitelist, dist-Laufzeitmount)
Build & Deploy / deploy (push) Successful in 23s
Build & Deploy / deploy (push) Successful in 23s
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
name: Build & Deploy
|
||||
|
||||
# Fährt automatisch bei jedem Push auf main aus:
|
||||
# Abhängigkeiten → Build → dist/ auf den VPS kopieren → Health-Check.
|
||||
# Das dist/-Verzeichnis ist auf dem Web-Container als Laufzeit-Mount
|
||||
# eingebunden (/opt/1bis8/web/dist), nginx pickt neue Dateien sofort auf.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: node:22-alpine
|
||||
# /opt/1bis8 des Hosts steht im Job als /deploy bereit (Whitelist im Runner)
|
||||
options: -v /opt/1bis8:/deploy
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Abhängigkeiten installieren
|
||||
run: cd app && npm ci
|
||||
|
||||
- name: Build
|
||||
run: cd app && npm run build
|
||||
|
||||
- name: Deploy auf 1bis.hocks.eu
|
||||
run: |
|
||||
rm -rf /deploy/web/dist/*
|
||||
cp -a app/dist/. /deploy/web/dist/
|
||||
|
||||
- name: Health-Check
|
||||
run: |
|
||||
apk add --no-cache curl
|
||||
sleep 3
|
||||
curl -sf https://1bis.hocks.eu/ > /dev/null
|
||||
curl -sf https://1bis8.hocks.eu/ > /dev/null
|
||||
echo "1 bis 8 Party antwortet – Deploy erfolgreich"
|
||||
@@ -28,10 +28,16 @@ npm run build # Produktions-Build → app/dist/
|
||||
|
||||
## Deployment (VPS 82.165.218.97, /opt/1bis8)
|
||||
|
||||
**Automatisch:** Bei jedem Push auf `main` baut die Gitea-Action
|
||||
(`.gitea/workflows/deploy.yml`) die App und kopiert `dist/` auf den Server –
|
||||
der Web-Container nutzt das Verzeichnis als Laufzeit-Mount und nimmt die
|
||||
Änderungen sofort an. Anschließend läuft ein Health-Check gegen beide Domains.
|
||||
|
||||
**Manuell:**
|
||||
|
||||
```bash
|
||||
cd app && npm run build
|
||||
scp -P 38592 -r dist root@82.165.218.97:/opt/1bis8/web/
|
||||
ssh -p 38592 root@82.165.218.97 "cd /opt/1bis8 && docker compose up -d --build"
|
||||
```
|
||||
|
||||
- TLS, Subdomains und Routing: Nginx Proxy Manager (`npm_default`-Netz)
|
||||
|
||||
@@ -20,7 +20,9 @@ services:
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./web/docker/templates/default.conf.template:/etc/nginx/templates/default.conf.template:ro
|
||||
# envsubst ersetzt ${MAIL_API_TOKEN} beim Start aus app.env
|
||||
# dist/ als Laufzeit-Mount: CI ersetzt die Dateien und nginx pickt sie
|
||||
# sofort auf – kein Image-Rebuild noetig (Build im Image bleibt Fallback)
|
||||
- ./web/dist:/usr/share/nginx/html:ro
|
||||
env_file:
|
||||
- app.env
|
||||
depends_on:
|
||||
|
||||
Reference in New Issue
Block a user