1 Deploy e Aggiornamento
Emanuele edited this page 2026-03-25 00:10:52 +01:00

Deploy Automatico — contact-page-static

Panoramica

Il repo contact-page-static viene deployato automaticamente su https://me.emanuelegori.uno/ tramite un webhook Forgejo.

Flusso di aggiornamento

Push su main → Forgejo webhook → webhook-listener (porta 9000) → clone + sync → nginx serve i file
  1. Push su main — solo il branch main triggera il deploy
  2. Webhook Forgejo → POST a contact-page-webhook:9000/hook (rete Docker interna)
  3. webhook-listener.py (/home/debian/contact-page/webhook-listener.py):
    • Clone shallow in /tmp/contact-page-repo
    • Copia file in /home/debian/contact-page/www/ (esclude: .git, .gitignore, README.md, CHANGELOG.md, LICENSE*.md, .forgejo)
    • Sostituisce <!-- LAST_UPDATE --> in index.html con timestamp italiano (es. Last update: 25 mar 2026, 14:30)
    • Pulisce la directory temporanea
  4. Nginx (container contact-page) serve da ./www in read-only → aggiornamento immediato

Docker Compose

File: /home/debian/contact-page/docker-compose.yml

Servizio Immagine Container Ruolo
webhook-listener python:3-alpine contact-page-webhook Riceve webhook, clona e sincronizza
nginx nginx:alpine contact-page Serve i file statici

Entrambi su rete esterna npm-net. Nginx Proxy Manager fa reverse proxy con SSL (proxy host #9).

  • Nel repo, index.html deve contenere il placeholder <!-- LAST_UPDATE -->
  • Al deploy, il webhook-listener lo sostituisce con il timestamp corrente in formato italiano
  • Se il placeholder manca, il timestamp non viene aggiornato (warning nel log)

File esclusi dal deploy

Questi file del repo non vengono copiati nella directory servita da nginx:

  • .git/, .gitignore, .forgejo/
  • README.md, CHANGELOG.md
  • LICENSE.md, LICENSE.IT.md

Comandi utili

# Vedere i log del webhook listener
docker logs contact-page-webhook --tail 50

# Vedere i log di nginx
docker logs contact-page --tail 50

# Restart manuale
cd /home/debian/contact-page && docker compose restart

# Verificare lo stato
docker ps | grep contact-page

Struttura directory sul server

/home/debian/contact-page/
├── docker-compose.yml
├── webhook-listener.py
└── www/                    ← file serviti da nginx
    ├── index.html
    ├── style.css
    ├── avatar.png
    ├── og-image.png
    ├── favicon.ico
    └── icons/