Merge remote-tracking branch 'origin/feat/split-apps' into merge-split
# Conflicts: # apps/sito/compose.yaml
@@ -3,9 +3,14 @@ dist/
|
||||
.astro/
|
||||
.env
|
||||
.env.bak*
|
||||
data/*.db*
|
||||
uploads/*
|
||||
!uploads/.gitkeep
|
||||
assets-src/
|
||||
**/data/*.db*
|
||||
**/uploads/*
|
||||
!**/uploads/.gitkeep
|
||||
**/assets-src/
|
||||
|
||||
# Artefatti di lavoro dei subagenti (ledger, brief, review package)
|
||||
.superpowers/
|
||||
|
||||
# Cache di Python generata rieseguendo l'oracolo
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
node_modules
|
||||
dist
|
||||
data
|
||||
.env
|
||||
.git
|
||||
tests
|
||||
*.md
|
||||
@@ -0,0 +1,30 @@
|
||||
# Stage 1: build
|
||||
FROM node:22-slim AS build
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: runtime
|
||||
FROM node:22-slim AS runtime
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --omit=dev && npm cache clean --force
|
||||
COPY --from=build /app/dist ./dist
|
||||
COPY scripts ./scripts
|
||||
# Contenuti del Biohacking Campus (generati con sync-campus e committati nel repo)
|
||||
COPY campus-content ./campus-content
|
||||
|
||||
# Tre database distinti, tutti nello stesso volume:
|
||||
# - piattaforme.db utenti e sessioni di quest'app (NON quelli del sito)
|
||||
# - longevity.db misure e punteggi, senza nomi
|
||||
# - identity.db la mappatura codice ↔ persona, l'unico file con dei nomi dentro
|
||||
ENV HOST=0.0.0.0 \
|
||||
PORT=4321 \
|
||||
DB_PATH=/app/data/piattaforme.db \
|
||||
LONGEVITY_DB_PATH=/app/data/longevity.db \
|
||||
IDENTITY_DB_PATH=/app/data/identity.db
|
||||
EXPOSE 4321
|
||||
CMD ["node", "./dist/server/entry.mjs"]
|
||||
@@ -0,0 +1,69 @@
|
||||
# InsanityLab — aree riservate (`apps.insanitylab.it`)
|
||||
|
||||
Applicazione Astro autosufficiente con le tre aree riservate: **Biohacking Campus**,
|
||||
**Stress Index** e **Longevity**. Nasce il 03/09/2026 separando dal sito
|
||||
(`apps/sito`, `insanitylab.it`) tutto ciò che sta dietro un login.
|
||||
|
||||
## Cosa la rende separata
|
||||
|
||||
| | Sito | Quest'app |
|
||||
|---|---|---|
|
||||
| Host | `insanitylab.it` | `apps.insanitylab.it` |
|
||||
| Utenti | 3 redazionali (`admin`, `superuser`, `user`) | uno per ogni cliente del centro (`piattaforme`, `cliente`, `trainer`, `admin`) |
|
||||
| Database | `insanitylab.db` (contenuti, articoli, utenti del sito) | `piattaforme.db` + `longevity.db` + `identity.db` |
|
||||
| Login | `/admin/login`, solo redazione | `/login`, ed è l'unica porta |
|
||||
|
||||
Non c'è SSO e non c'è cookie condiviso: **una sessione del sito qui non vale**, ed è la
|
||||
separazione, non un difetto. Le due `lib/auth.ts` sono parenti ma non sono la stessa cosa —
|
||||
~170 righe duplicate una volta sola, libere di divergere come già divergono i ruoli.
|
||||
|
||||
## Sviluppo
|
||||
|
||||
```bash
|
||||
npm ci
|
||||
npm run dev # http://localhost:4321
|
||||
npm test # 26 file, 197 test
|
||||
npm run create-user -- <nome> <password> <ruolo> # ruoli: piattaforme, cliente, trainer, admin
|
||||
```
|
||||
|
||||
I dati stanno in `data/` (gitignorata): `piattaforme.db`, `longevity.db`, `identity.db`.
|
||||
|
||||
## Rilascio
|
||||
|
||||
⚠️⚠️ **Il DNS viene prima del container.** `apps.insanitylab.it` deve già risolvere verso
|
||||
l'IP della VPS quando si alza lo stack: avviarlo prima significa una catena di sfide TLS
|
||||
fallite, e Let's Encrypt limita proprio quelle. La zona è su **Aruba**, serve un record
|
||||
**A** `apps` → l'IP della macchina.
|
||||
|
||||
```bash
|
||||
mkdir -p /opt/docker/insanitylab-platforms/data # i dati stanno FUORI dal clone git
|
||||
docker compose up -d --build
|
||||
node scripts/migra-utenti.mjs # prova a vuoto
|
||||
node scripts/migra-utenti.mjs --applica # porta gli utenti dal DB del sito
|
||||
```
|
||||
|
||||
## Trappole già pagate
|
||||
|
||||
⚠️ **Le versioni si fissano esatte.** `^7.0.5` sulla nuova app aveva risolto ad **astro
|
||||
7.3.0**, che con `@astrojs/node 11.1.5` non si parla (`"./_internal/logger" is not
|
||||
exported`) e il build muore. Astro, l'adapter node e l'integrazione react sono pinnati
|
||||
alle stesse versioni che girano in produzione sul sito.
|
||||
|
||||
⚠️ **`security.allowedDomains` in `astro.config.mjs` non è decorativo.** Dietro Traefik il
|
||||
TLS termina al proxy: senza quell'elenco Astro ignora `X-Forwarded-Proto`/`Host` e il
|
||||
controllo CSRF respinge **ogni** POST con 403 — cioè il login smette di funzionare e
|
||||
l'errore sembra «credenziali sbagliate».
|
||||
|
||||
⚠️ **`name: insanitylab-platforms` nel compose.** Senza, il progetto si chiamerebbe
|
||||
`platforms` (dal nome della cartella) e un `down --remove-orphans` dato altrove potrebbe
|
||||
toccare container che non sono suoi.
|
||||
|
||||
⚠️ **Il default di `canAccessPath` è chiuso**, al contrario del sito da cui viene: là le
|
||||
rotte non elencate (blog, upload) erano di chiunque fosse loggato, qui ogni sezione è di
|
||||
qualcuno. Una rotta nuova senza regola risulta **vietata**, e lo si scopre provandola.
|
||||
|
||||
⚠️ **Le API rispondono con uno stato, non con un redirect** (401/403 su `/api/*`): mandare
|
||||
un 302 verso il login a chi ha chiesto del JSON produce un 200 con dentro dell'HTML.
|
||||
|
||||
⚠️ **Stress Index non ha un backend**: `src/lib/stress-index/data.ts` sono dieci clienti
|
||||
inventati scritti a mano. In linea c'è la sua interfaccia, non i suoi dati.
|
||||
@@ -0,0 +1,27 @@
|
||||
import { defineConfig } from 'astro/config';
|
||||
import node from '@astrojs/node';
|
||||
import react from '@astrojs/react';
|
||||
|
||||
export default defineConfig({
|
||||
site: 'https://apps.insanitylab.it',
|
||||
output: 'server',
|
||||
|
||||
// ⚠️ Dietro Traefik il TLS termina al proxy: senza allowedDomains Astro ignora
|
||||
// X-Forwarded-Proto/Host e il checkOrigin CSRF respinge OGNI POST con 403 — cioè
|
||||
// il login smette di funzionare, e l'errore sembra "credenziali sbagliate".
|
||||
// Stessa configurazione del sito, con l'host di quest'app.
|
||||
security: {
|
||||
allowedDomains: [
|
||||
// L'host definitivo, quando il record A su Aruba ci sara'.
|
||||
{ hostname: 'apps.insanitylab.it', protocol: 'https' },
|
||||
// ⚠️ L'host in uso oggi (03/09/2026): il dominio del cliente resta su Aruba e le aree
|
||||
// riservate stanno su un sottodominio nostro. Finche' e' in uso deve stare qui:
|
||||
// senza, dietro Traefik il controllo CSRF di Astro respinge ogni POST con 403 e il
|
||||
// login sembra rifiutare le credenziali.
|
||||
{ hostname: 'piattaforme.tielogic.xyz', protocol: 'https' },
|
||||
],
|
||||
},
|
||||
|
||||
adapter: node({ mode: 'standalone' }),
|
||||
integrations: [react()],
|
||||
});
|
||||
|
Before Width: | Height: | Size: 370 KiB After Width: | Height: | Size: 370 KiB |
|
Before Width: | Height: | Size: 230 KiB After Width: | Height: | Size: 230 KiB |
|
Before Width: | Height: | Size: 165 KiB After Width: | Height: | Size: 165 KiB |
|
Before Width: | Height: | Size: 229 KiB After Width: | Height: | Size: 229 KiB |
|
Before Width: | Height: | Size: 255 KiB After Width: | Height: | Size: 255 KiB |
|
Before Width: | Height: | Size: 276 KiB After Width: | Height: | Size: 276 KiB |
|
Before Width: | Height: | Size: 255 KiB After Width: | Height: | Size: 255 KiB |
|
Before Width: | Height: | Size: 222 KiB After Width: | Height: | Size: 222 KiB |
|
Before Width: | Height: | Size: 390 KiB After Width: | Height: | Size: 390 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 581 KiB After Width: | Height: | Size: 581 KiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 362 KiB After Width: | Height: | Size: 362 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 551 KiB After Width: | Height: | Size: 551 KiB |
|
Before Width: | Height: | Size: 480 KiB After Width: | Height: | Size: 480 KiB |
|
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 170 KiB |
|
Before Width: | Height: | Size: 380 KiB After Width: | Height: | Size: 380 KiB |
|
Before Width: | Height: | Size: 676 KiB After Width: | Height: | Size: 676 KiB |
|
Before Width: | Height: | Size: 542 KiB After Width: | Height: | Size: 542 KiB |
|
Before Width: | Height: | Size: 384 KiB After Width: | Height: | Size: 384 KiB |
|
Before Width: | Height: | Size: 363 KiB After Width: | Height: | Size: 363 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 560 KiB After Width: | Height: | Size: 560 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 247 KiB After Width: | Height: | Size: 247 KiB |
|
Before Width: | Height: | Size: 632 KiB After Width: | Height: | Size: 632 KiB |
|
Before Width: | Height: | Size: 452 KiB After Width: | Height: | Size: 452 KiB |
|
Before Width: | Height: | Size: 374 KiB After Width: | Height: | Size: 374 KiB |
|
Before Width: | Height: | Size: 575 KiB After Width: | Height: | Size: 575 KiB |
|
Before Width: | Height: | Size: 410 KiB After Width: | Height: | Size: 410 KiB |
|
Before Width: | Height: | Size: 347 KiB After Width: | Height: | Size: 347 KiB |
|
Before Width: | Height: | Size: 357 KiB After Width: | Height: | Size: 357 KiB |
|
Before Width: | Height: | Size: 258 KiB After Width: | Height: | Size: 258 KiB |
|
Before Width: | Height: | Size: 837 KiB After Width: | Height: | Size: 837 KiB |
|
Before Width: | Height: | Size: 268 KiB After Width: | Height: | Size: 268 KiB |
|
Before Width: | Height: | Size: 323 KiB After Width: | Height: | Size: 323 KiB |
|
Before Width: | Height: | Size: 350 KiB After Width: | Height: | Size: 350 KiB |
|
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 212 KiB |
|
Before Width: | Height: | Size: 405 KiB After Width: | Height: | Size: 405 KiB |
|
Before Width: | Height: | Size: 283 KiB After Width: | Height: | Size: 283 KiB |
|
Before Width: | Height: | Size: 408 KiB After Width: | Height: | Size: 408 KiB |
|
Before Width: | Height: | Size: 765 KiB After Width: | Height: | Size: 765 KiB |
|
Before Width: | Height: | Size: 370 KiB After Width: | Height: | Size: 370 KiB |
|
Before Width: | Height: | Size: 439 KiB After Width: | Height: | Size: 439 KiB |
|
Before Width: | Height: | Size: 224 KiB After Width: | Height: | Size: 224 KiB |
|
Before Width: | Height: | Size: 531 KiB After Width: | Height: | Size: 531 KiB |
|
Before Width: | Height: | Size: 791 KiB After Width: | Height: | Size: 791 KiB |
|
Before Width: | Height: | Size: 408 KiB After Width: | Height: | Size: 408 KiB |
|
Before Width: | Height: | Size: 702 KiB After Width: | Height: | Size: 702 KiB |
|
Before Width: | Height: | Size: 551 KiB After Width: | Height: | Size: 551 KiB |
|
Before Width: | Height: | Size: 308 KiB After Width: | Height: | Size: 308 KiB |
|
Before Width: | Height: | Size: 196 KiB After Width: | Height: | Size: 196 KiB |
|
Before Width: | Height: | Size: 257 KiB After Width: | Height: | Size: 257 KiB |
|
Before Width: | Height: | Size: 300 KiB After Width: | Height: | Size: 300 KiB |
|
Before Width: | Height: | Size: 229 KiB After Width: | Height: | Size: 229 KiB |
|
Before Width: | Height: | Size: 294 KiB After Width: | Height: | Size: 294 KiB |
|
Before Width: | Height: | Size: 394 KiB After Width: | Height: | Size: 394 KiB |
|
Before Width: | Height: | Size: 397 KiB After Width: | Height: | Size: 397 KiB |
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
|
Before Width: | Height: | Size: 377 KiB After Width: | Height: | Size: 377 KiB |
|
Before Width: | Height: | Size: 230 KiB After Width: | Height: | Size: 230 KiB |
|
Before Width: | Height: | Size: 247 KiB After Width: | Height: | Size: 247 KiB |
|
Before Width: | Height: | Size: 256 KiB After Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 231 KiB After Width: | Height: | Size: 231 KiB |
|
Before Width: | Height: | Size: 939 KiB After Width: | Height: | Size: 939 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 365 KiB After Width: | Height: | Size: 365 KiB |
|
Before Width: | Height: | Size: 329 KiB After Width: | Height: | Size: 329 KiB |
|
Before Width: | Height: | Size: 489 KiB After Width: | Height: | Size: 489 KiB |
|
Before Width: | Height: | Size: 397 KiB After Width: | Height: | Size: 397 KiB |
|
Before Width: | Height: | Size: 654 KiB After Width: | Height: | Size: 654 KiB |
|
Before Width: | Height: | Size: 494 KiB After Width: | Height: | Size: 494 KiB |
|
Before Width: | Height: | Size: 413 KiB After Width: | Height: | Size: 413 KiB |
|
Before Width: | Height: | Size: 371 KiB After Width: | Height: | Size: 371 KiB |
|
Before Width: | Height: | Size: 476 KiB After Width: | Height: | Size: 476 KiB |
|
Before Width: | Height: | Size: 550 KiB After Width: | Height: | Size: 550 KiB |
|
Before Width: | Height: | Size: 639 KiB After Width: | Height: | Size: 639 KiB |
|
Before Width: | Height: | Size: 388 KiB After Width: | Height: | Size: 388 KiB |
|
Before Width: | Height: | Size: 400 KiB After Width: | Height: | Size: 400 KiB |
|
Before Width: | Height: | Size: 654 KiB After Width: | Height: | Size: 654 KiB |
|
Before Width: | Height: | Size: 611 KiB After Width: | Height: | Size: 611 KiB |
|
Before Width: | Height: | Size: 593 KiB After Width: | Height: | Size: 593 KiB |
|
Before Width: | Height: | Size: 149 KiB After Width: | Height: | Size: 149 KiB |
|
Before Width: | Height: | Size: 202 KiB After Width: | Height: | Size: 202 KiB |
|
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 162 KiB |
|
Before Width: | Height: | Size: 443 KiB After Width: | Height: | Size: 443 KiB |
|
Before Width: | Height: | Size: 393 KiB After Width: | Height: | Size: 393 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 284 KiB |
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 157 KiB |
|
Before Width: | Height: | Size: 203 KiB After Width: | Height: | Size: 203 KiB |
|
Before Width: | Height: | Size: 353 KiB After Width: | Height: | Size: 353 KiB |
|
Before Width: | Height: | Size: 400 KiB After Width: | Height: | Size: 400 KiB |