docs + woodpecker

This commit is contained in:
Luca Banfi
2026-05-18 15:06:58 +02:00
parent 8d79f5f9a3
commit 24ca567921
4 changed files with 208 additions and 0 deletions
+104
View File
@@ -0,0 +1,104 @@
---
# .woodpecker.yml — RPA TDI Dashboard Service
# Forge: Gitea — Runner: Ubuntu cloud + Docker
#
# Flusso:
# push / PR → lint + syntax
# tag prod → lint + syntax + build + deploy (automatico)
#
# Per pubblicare:
# git tag prod && git push --tags
when:
event: [push, pull_request, tag]
steps:
- name: lint
image: python:3.12-slim
when:
event: [push, pull_request, tag]
commands:
- pip install flake8 --quiet
- flake8 . --max-line-length=120 --exclude=__pycache__
- name: syntax
image: python:3.12-slim
when:
event: [push, pull_request, tag]
depends_on: [lint]
commands:
- pip install python-dotenv --quiet
- python -m compileall -q .
- name: build
image: python:3.12-slim
when:
event: tag
tag: prod
commands:
- apt-get update -qq && apt-get install -y zip --quiet
- pip install python-dotenv rcssmin rjsmin --quiet
- |
python - <<'EOF'
import os, zipfile, fnmatch
EXCLUDE_FILES = ["tmp_*", "*.md"]
EXCLUDE_DIRS = {".git", "__pycache__", "data", "tests", "docs", "secrets"}
EXCLUDE_EXACTLY = {".env"}
OUT = "rpa-tdi-dashboard-prod.zip"
def is_excluded(rel):
parts = rel.replace("\\", "/").split("/")
if parts[0] in EXCLUDE_DIRS:
return True
name = parts[-1]
if name in EXCLUDE_EXACTLY:
return True
for pat in EXCLUDE_FILES:
if fnmatch.fnmatch(name, pat):
return True
return False
with zipfile.ZipFile(OUT, "w", zipfile.ZIP_DEFLATED) as zf:
for root, dirs, files in os.walk("."):
dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS and not d.startswith(".")]
for f in files:
path = os.path.join(root, f)
rel = os.path.relpath(path, ".")
if not is_excluded(rel):
zf.write(path, rel)
print(f" + {rel}")
print(f"\n✓ {OUT}")
EOF
- ls -lh rpa-tdi-dashboard-prod.zip
# Copia i file su /ATG_RUN_TEST/Dashboard e riavvia il container
# Prerequisiti sulla VM:
# - /ATG_RUN_TEST/Dashboard/.env → già presente con le variabili locali
# - Woodpecker runner configurato con volumes abilitati (WOODPECKER_BACKEND_DOCKER_VOLUMES=true)
- name: deploy
image: docker:cli
when:
event: tag
tag: prod
depends_on: [build]
volumes:
- /ATG_RUN_TEST/Dashboard:/app
- /var/run/docker.sock:/var/run/docker.sock
commands:
- apk add --no-cache unzip --quiet
- unzip -o rpa-tdi-dashboard-prod.zip -d /app
- echo "✓ File estratti in /ATG_RUN_TEST/Dashboard"
- docker stop rpa-dashboard-test 2>/dev/null || true
- docker rm rpa-dashboard-test 2>/dev/null || true
- docker run -d
--name rpa-dashboard-test
--restart unless-stopped
-v /ATG_RUN_TEST/Dashboard:/app
-v /ATG_RUN_TEST/db:/rpa-db
-w /app
-e RPA_DB_DIR=/rpa-db
-p 8473:8473
python:3.12-slim
sh -c "pip install -r requirements.txt -q && python Dashboard.py"
- echo "✓ Container avviato su http://57.131.52.95:8473"
View File
View File
+104
View File
@@ -0,0 +1,104 @@
# RPA Dashboard — Autodeploy con Woodpecker CI
## Panoramica
Il deploy avviene automaticamente tramite **Woodpecker CI** collegato a **Gitea**.
Non serve nessun intervento manuale: basta taggare un commit con `prod`.
---
## Flusso
```
push / PR → lint + syntax check (verifica automatica ad ogni commit)
tag prod → lint → syntax → build → deploy
└─ estrae i file su /ATG_RUN_TEST/Dashboard
└─ riavvia il container Docker
└─ dashboard live su http://57.131.52.95:8473
```
---
## Pubblicare una nuova versione
```bash
# 1. Commit delle modifiche
git add .
git commit -m "descrizione modifica"
# 2. Spostare il tag prod sul commit corrente
git tag -f prod
git push --force --tags
```
Woodpecker riceve il webhook da Gitea e avvia la pipeline in automatico.
---
## Step della pipeline (`.woodpecker.yml`)
| Step | Trigger | Cosa fa |
|---|---|---|
| `lint` | push / PR / tag | flake8 — controlla stile e errori Python |
| `syntax` | push / PR / tag | `py_compile` su tutti i `.py` |
| `build` | tag `prod` | crea `rpa-tdi-dashboard-prod.zip` (esclude `.env`, `__pycache__`, `*.md`, ecc.) |
| `deploy` | tag `prod` | estrae lo zip in `/ATG_RUN_TEST/Dashboard`, riavvia il container |
---
## Infrastruttura
| Componente | Dettaglio |
|---|---|
| Forge | Gitea (self-hosted) |
| CI | Woodpecker CI — Ubuntu cloud + Docker |
| VM | `57.131.52.95` |
| Porta dashboard | `8473` |
| Cartella deploy | `/ATG_RUN_TEST/Dashboard` |
| Cartella DB | `/ATG_RUN_TEST/db` |
| Container | `rpa-dashboard-test` |
---
## Prerequisiti sulla VM (setup iniziale, una tantum)
```bash
# Creare le cartelle
mkdir -p /ATG_RUN_TEST/Dashboard
mkdir -p /ATG_RUN_TEST/db
# Creare il .env con le variabili locali Linux
cat > /ATG_RUN_TEST/Dashboard/.env <<EOF
LOGIN=true
DASHBOARD_USER=TDI_admin
DASHBOARD_PASSWORD=Dashboard_TDI_26!
RPA_REPORT_PORT=8473
EOF
# Copiare i file .db nella cartella db
# es. cp rpa_FORMAZIONE.db /ATG_RUN_TEST/db/
```
Abilitare i volume mounts nel Woodpecker runner (nel file di config dell'agent):
```env
WOODPECKER_BACKEND_DOCKER_VOLUMES=true
```
---
## Verifica deploy
```bash
# Stato del container
docker ps | grep rpa-dashboard-test
# Log in tempo reale
docker logs -f rpa-dashboard-test
# Riavvio manuale (se necessario)
docker restart rpa-dashboard-test
```
Dashboard: `http://57.131.52.95:8473/login`