feat(sites): add Homelab Sites orchestration for Armonía del Ser
- Add Schema v1.0 app.yaml manifest for armonia.roadtotech.me - Add multistage Dockerfile.dashboard (Node 22 pnpm -> Nginx 1.27 Alpine) and nginx.conf with /api/ proxy and Authelia header forwarding - Configure docker-compose.yml with Traefik public/protected routers, /api prefix stripping, and SQLite volume persistance - Document environment variables and Turso driver normalization tracking (armonia-api#11) Refs: armonia-del-ser/.profile#2
This commit is contained in:
1 parent
69f8f3f94f
commit
75dc033448
7 files changed
+284
-2
No files matched your search
@@ -0,0 +1,36 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# Armonía del Ser — Homelab Sites Environment Configuration
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# Routing & Platform
|
||||||
|
SERVICE_DOMAIN=armonia.roadtotech.me
|
||||||
|
PROXY_NETWORK=proxy-net
|
||||||
|
|
||||||
|
# Runtime & Auth Strategy
|
||||||
|
# AUTH_PROVIDER="proxy_headers" trusts Authelia ForwardAuth headers (Remote-Email, Remote-Groups)
|
||||||
|
# mapping LLDAP groups: armonia-owner -> OWNER, armonia-assistant -> ASSISTANT
|
||||||
|
APP_ENV=production
|
||||||
|
ENVIRONMENT=production
|
||||||
|
AUTH_PROVIDER=proxy_headers
|
||||||
|
|
||||||
|
# Database Configuration
|
||||||
|
# Active: Local SQLite volume mount at ./data/armonia.db (mounted to /data/armonia.db in container)
|
||||||
|
DATABASE_URL=file:/data/armonia.db
|
||||||
|
DATABASE_AUTH_TOKEN=
|
||||||
|
|
||||||
|
# Deferred Turso Cloud Configuration (tracked in armonia-del-ser/armonia-api#11):
|
||||||
|
# TURSO_URL=libsql://armonia-db-kiskaadee.aws-us-east-2.turso.io
|
||||||
|
# DATABASE_URL=sqlite+libsql://armonia-db-kiskaadee.aws-us-east-2.turso.io?authToken=<YOUR_TURSO_TOKEN>&secure=true
|
||||||
|
# DATABASE_AUTH_TOKEN=<YOUR_TURSO_TOKEN>
|
||||||
|
|
||||||
|
# Business Profile
|
||||||
|
THERAPIST_NAME="Jasmin"
|
||||||
|
BUSINESS_NAME="Armonía del Ser"
|
||||||
|
WHATSAPP_PHONE="527751487912"
|
||||||
|
SPEI_CLABE="012345678901234567"
|
||||||
|
SPEI_BANK="BBVA"
|
||||||
|
SPEI_BENEFICIARY="Jasmin"
|
||||||
|
|
||||||
|
# Optional Google Calendar Integration
|
||||||
|
GCAL_CALENDAR_ID=primary
|
||||||
|
GOOGLE_SERVICE_ACCOUNT_JSON=
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.env
|
||||||
|
app.env
|
||||||
|
data/
|
||||||
|
*.db
|
||||||
|
*.db-journal
|
||||||
|
*.db-wal
|
||||||
|
*.db-shm
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
# Multi-stage production container build for armonia-dashboard (Vite SPA -> Nginx Alpine)
|
||||||
|
|
||||||
|
# Stage 1: Clone and build static SPA bundle from upstream Gitea repository
|
||||||
|
FROM node:22-alpine AS builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache git && \
|
||||||
|
corepack enable && \
|
||||||
|
corepack prepare pnpm@latest --activate
|
||||||
|
|
||||||
|
ARG DASHBOARD_REPO_URL=https://gitea.roadtotech.me/armonia-del-ser/armonia-dashboard.git
|
||||||
|
ARG DASHBOARD_REF=main
|
||||||
|
ARG VITE_API_BASE_URL=/api
|
||||||
|
|
||||||
|
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN git clone --depth 1 --branch "${DASHBOARD_REF}" "${DASHBOARD_REPO_URL}" . && \
|
||||||
|
pnpm install --frozen-lockfile && \
|
||||||
|
pnpm run build
|
||||||
|
|
||||||
|
|
||||||
|
# Stage 2: Lightweight Nginx Alpine runtime serving static assets and proxying /api
|
||||||
|
FROM nginx:1.27-alpine AS runtime
|
||||||
|
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||||
|
CMD wget -q -O /dev/null http://127.0.0.1:80/ || exit 1
|
||||||
@@ -1,3 +1,47 @@
|
|||||||
# homelab-armonia
|
# 🪷 Armonía del Ser — Homelab Sites Deployment (`armonia`)
|
||||||
|
|
||||||
Homelab Sites Deployment & Orchestration for Armonía del Ser
|
Containerized Homelab Sites orchestration for **Armonía del Ser**, uniting the FastAPI backend ([`armonia-api`](https://gitea.roadtotech.me/armonia-del-ser/armonia-api)) and the mobile-first operator dashboard ([`armonia-dashboard`](https://gitea.roadtotech.me/armonia-del-ser/armonia-dashboard)) behind Traefik, Authelia ForwardAuth, and LLDAP role mapping.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🏛️ Architecture & Routing Topology
|
||||||
|
|
||||||
|
- **Domain**: `https://armonia.roadtotech.me`
|
||||||
|
- **External Network**: `proxy-net`
|
||||||
|
- **Traefik Routers**:
|
||||||
|
1. `armonia-api-public` (Priority `30`, Public): Matches `PathPrefix('/api/public') || PathPrefix('/api/health') || PathPrefix('/api/availability') || PathPrefix('/api/services')`, strips `/api/public` or `/api` via `armonia-api-strip@docker`, and routes directly to `armonia-api:8000` without authentication.
|
||||||
|
2. `armonia-api` (Priority `20`, Protected): Matches `PathPrefix('/api')`, enforces `authelia-auth@docker` (injecting `Remote-Email`, `Remote-User`, `Remote-Name`, and `Remote-Groups`), strips `/api`, and routes to `armonia-api:8000`.
|
||||||
|
3. `armonia-dashboard` (Priority `10`, Protected): Matches `PathPrefix('/')`, enforces `authelia-auth@docker`, and serves the static Vite SPA on `armonia-dashboard:80` (with an internal Nginx `/api/` proxy fallback).
|
||||||
|
- **Decoupled Identity & JIT Role Mapping (`AUTH_PROVIDER=proxy_headers`)**:
|
||||||
|
- `armonia-owner` $\rightarrow$ `OWNER`
|
||||||
|
- `armonia-admin` $\rightarrow$ `ADMIN`
|
||||||
|
- `armonia-assistant` $\rightarrow$ `ASSISTANT`
|
||||||
|
- On state-mutating requests, `armonia-api` automatically mirrors the authenticated operator into `admin_allowlist` to preserve foreign-key integrity on `admin_audit_log`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🗄️ Database Persistence
|
||||||
|
|
||||||
|
- **Active Configuration (Local SQLite Volume)**:
|
||||||
|
- `DATABASE_URL=file:/data/armonia.db`
|
||||||
|
- Bind-mounted from `./data:/data` (owned by UID `1000`).
|
||||||
|
- Automatically initializes schema and seeds the service catalog on container startup via FastAPI lifespan (`app.db.init_db`).
|
||||||
|
- **Turso Cloud (`armonia-db`)**:
|
||||||
|
- Provisioned at `libsql://armonia-db-kiskaadee.aws-us-east-2.turso.io`.
|
||||||
|
- Dual-driver URL normalization (`libsql_client` vs. `sqlalchemy-libsql`) is tracked in [`armonia-del-ser/armonia-api#11`](https://gitea.roadtotech.me/armonia-del-ser/armonia-api/issues/11).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Operations (`appctl`)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Validate manifest & rendered Docker Compose config
|
||||||
|
appctl config armonia
|
||||||
|
|
||||||
|
# Build and start containers
|
||||||
|
appctl up armonia
|
||||||
|
|
||||||
|
# Inspect two-axis status & logs
|
||||||
|
appctl info armonia
|
||||||
|
appctl logs armonia
|
||||||
|
```
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
schema_version: "1.0"
|
||||||
|
name: "armonia"
|
||||||
|
aliases:
|
||||||
|
- "armonia-del-ser"
|
||||||
|
- "jasmin"
|
||||||
|
domain: "armonia.roadtotech.me"
|
||||||
|
description: "Armonía del Ser — Holistic Consultation & Operator Dashboard"
|
||||||
|
visible: true
|
||||||
|
auth: true
|
||||||
|
networks:
|
||||||
|
- proxy-net
|
||||||
|
source:
|
||||||
|
url: "https://gitea.roadtotech.me/armonia-del-ser/armonia-api.git"
|
||||||
|
ref: "main"
|
||||||
|
env:
|
||||||
|
ENVIRONMENT: "production"
|
||||||
|
AUTH_PROVIDER: "proxy_headers"
|
||||||
|
DATABASE_URL: "file:/data/armonia.db"
|
||||||
|
deployment:
|
||||||
|
branch: "main"
|
||||||
|
strategy: "compose"
|
||||||
|
actions:
|
||||||
|
- git_pull
|
||||||
|
- compose_build
|
||||||
|
- compose_up
|
||||||
|
homepage:
|
||||||
|
title: "Armonía del Ser"
|
||||||
|
group: "Applications"
|
||||||
|
icon: "calendar.png"
|
||||||
|
container: "armonia-dashboard"
|
||||||
|
weight: 20
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
services:
|
||||||
|
armonia-api:
|
||||||
|
build:
|
||||||
|
context: ${ARMONIA_API_BUILD_CONTEXT:-https://gitea.roadtotech.me/armonia-del-ser/armonia-api.git#main}
|
||||||
|
container_name: armonia-api
|
||||||
|
user: "1000:100"
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ./data:/data
|
||||||
|
environment:
|
||||||
|
- ENVIRONMENT=${ENVIRONMENT:-production}
|
||||||
|
- APP_ENV=${APP_ENV:-production}
|
||||||
|
- AUTH_PROVIDER=${AUTH_PROVIDER:-proxy_headers}
|
||||||
|
- DATABASE_URL=${DATABASE_URL:-file:/data/armonia.db}
|
||||||
|
- DATABASE_AUTH_TOKEN=${DATABASE_AUTH_TOKEN:-}
|
||||||
|
- DASHBOARD_ORIGIN_URL=https://${SERVICE_DOMAIN:-armonia.roadtotech.me}
|
||||||
|
- CORS_ORIGINS=["https://${SERVICE_DOMAIN:-armonia.roadtotech.me}","https://armonia-landing.pages.dev"]
|
||||||
|
- THERAPIST_NAME=${THERAPIST_NAME:-Jasmin}
|
||||||
|
- BUSINESS_NAME=${BUSINESS_NAME:-Armonía del Ser}
|
||||||
|
- WHATSAPP_PHONE=${WHATSAPP_PHONE:-527751487912}
|
||||||
|
- SPEI_CLABE=${SPEI_CLABE:-012345678901234567}
|
||||||
|
- SPEI_BANK=${SPEI_BANK:-BBVA}
|
||||||
|
- SPEI_BENEFICIARY=${SPEI_BENEFICIARY:-Jasmin}
|
||||||
|
- GCAL_CALENDAR_ID=${GCAL_CALENDAR_ID:-primary}
|
||||||
|
- GOOGLE_SERVICE_ACCOUNT_JSON=${GOOGLE_SERVICE_ACCOUNT_JSON:-}
|
||||||
|
networks:
|
||||||
|
- proxy-net
|
||||||
|
labels:
|
||||||
|
- "diun.enable=false"
|
||||||
|
- "traefik.enable=true"
|
||||||
|
|
||||||
|
# Middleware: Strip /api prefix before forwarding to FastAPI (which serves at /)
|
||||||
|
- "traefik.http.middlewares.armonia-api-strip.stripprefix.prefixes=/api/public,/api"
|
||||||
|
|
||||||
|
# 1. Public API & Health Router (Priority 30 — bypasses Authelia forward-auth)
|
||||||
|
- "traefik.http.routers.armonia-api-public.rule=Host(`${SERVICE_DOMAIN:-armonia.roadtotech.me}`) && (PathPrefix(`/api/public`) || PathPrefix(`/api/health`) || PathPrefix(`/api/availability`) || PathPrefix(`/api/services`))"
|
||||||
|
- "traefik.http.routers.armonia-api-public.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.armonia-api-public.tls=true"
|
||||||
|
- "traefik.http.routers.armonia-api-public.priority=30"
|
||||||
|
- "traefik.http.routers.armonia-api-public.middlewares=armonia-api-strip@docker"
|
||||||
|
- "traefik.http.routers.armonia-api-public.service=armonia-api-svc"
|
||||||
|
|
||||||
|
# 2. Protected Operator API Router (Priority 20 — guarded by Authelia + LLDAP role mapping)
|
||||||
|
- "traefik.http.routers.armonia-api.rule=Host(`${SERVICE_DOMAIN:-armonia.roadtotech.me}`) && PathPrefix(`/api`)"
|
||||||
|
- "traefik.http.routers.armonia-api.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.armonia-api.tls=true"
|
||||||
|
- "traefik.http.routers.armonia-api.priority=20"
|
||||||
|
- "traefik.http.routers.armonia-api.middlewares=authelia-auth@docker,armonia-api-strip@docker"
|
||||||
|
- "traefik.http.routers.armonia-api.service=armonia-api-svc"
|
||||||
|
|
||||||
|
# Service Target
|
||||||
|
- "traefik.http.services.armonia-api-svc.loadbalancer.server.port=8000"
|
||||||
|
|
||||||
|
armonia-dashboard:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.dashboard
|
||||||
|
args:
|
||||||
|
DASHBOARD_REPO_URL: ${DASHBOARD_REPO_URL:-https://gitea.roadtotech.me/armonia-del-ser/armonia-dashboard.git}
|
||||||
|
DASHBOARD_REF: ${DASHBOARD_REF:-main}
|
||||||
|
VITE_API_BASE_URL: /api
|
||||||
|
container_name: armonia-dashboard
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
armonia-api:
|
||||||
|
condition: service_healthy
|
||||||
|
networks:
|
||||||
|
- proxy-net
|
||||||
|
labels:
|
||||||
|
- "diun.enable=false"
|
||||||
|
- "traefik.enable=true"
|
||||||
|
|
||||||
|
# 3. Protected Operator Dashboard UI Router (Priority 10 — guarded by Authelia)
|
||||||
|
- "traefik.http.routers.armonia-dashboard.rule=Host(`${SERVICE_DOMAIN:-armonia.roadtotech.me}`) && PathPrefix(`/`)"
|
||||||
|
- "traefik.http.routers.armonia-dashboard.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.armonia-dashboard.tls=true"
|
||||||
|
- "traefik.http.routers.armonia-dashboard.priority=10"
|
||||||
|
- "traefik.http.routers.armonia-dashboard.middlewares=authelia-auth@docker"
|
||||||
|
- "traefik.http.routers.armonia-dashboard.service=armonia-dashboard-svc"
|
||||||
|
|
||||||
|
# 4. HTTP to HTTPS Redirect
|
||||||
|
- "traefik.http.routers.armonia-red.rule=Host(`${SERVICE_DOMAIN:-armonia.roadtotech.me}`)"
|
||||||
|
- "traefik.http.routers.armonia-red.entrypoints=web"
|
||||||
|
- "traefik.http.routers.armonia-red.middlewares=https-redirect@docker"
|
||||||
|
|
||||||
|
# Service Target
|
||||||
|
- "traefik.http.services.armonia-dashboard-svc.loadbalancer.server.port=80"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
proxy-net:
|
||||||
|
name: ${PROXY_NETWORK:-proxy-net}
|
||||||
|
external: true
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Compression for static assets
|
||||||
|
gzip on;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml;
|
||||||
|
gzip_min_length 256;
|
||||||
|
|
||||||
|
# Internal reverse proxy fallback for /api/* -> armonia-api:8000/*
|
||||||
|
# Preserves Authelia ForwardAuth headers (Remote-Email, Remote-User, Remote-Groups, Remote-Name)
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://armonia-api:8000/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header Remote-User $http_remote_user;
|
||||||
|
proxy_set_header Remote-Email $http_remote_email;
|
||||||
|
proxy_set_header Remote-Name $http_remote_name;
|
||||||
|
proxy_set_header Remote-Groups $http_remote_groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
#Immutable Vite hashed assets
|
||||||
|
location /assets/ {
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
try_files $uri =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
# SPA fallback routing
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user