From d7832a3bc0c002f0e3978c63d4ed63427d4e0dd8 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Wed, 18 Nov 2026 20:23:33 -0500 Subject: [PATCH] fix(workloads): address code-review rework items across keepers and docs - Fail fast in armonia/Dockerfile.dashboard when DASHBOARD_REPO_URL is empty - Add armonia/.env-example documenting required build, image, and runtime env vars - Standardize restart: unless-stopped in gitea and snappymail compose files - Align jellyfin/docker-compose.yml with proxy-net, myresolver, SERVICE_NAME, and HTTPS_REDIRECT_MIDDLEWARE defaults - Update root README.md to reflect deployments.yaml and the 5 keeper workloads --- README.md | 50 +++++++++-------------------------- armonia/.env-example | 36 +++++++++++++++++++++++++ armonia/Dockerfile.dashboard | 3 ++- gitea/docker-compose.yml | 2 +- jellyfin/docker-compose.yml | 28 ++++++++++---------- snappymail/docker-compose.yml | 2 +- 6 files changed, 66 insertions(+), 55 deletions(-) create mode 100644 armonia/.env-example diff --git a/README.md b/README.md index 442254a..65cff3f 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,32 @@ -# ๐ŸŒ Unified Traefik Deployments +# ๐ŸŒ Canopy Workloads -This repository contains a unified, decoupled, and portable suite of self-hosted application stacks designed to run behind a **Traefik Reverse Proxy** in a containerized homelab environment. +This repository contains the decoupled, portable application stacks managed by the Canopy homelab platform behind a **Traefik Reverse Proxy** and the `nixos-core` `appctl` / `gitops_dispatcher` control plane. --- ## ๐Ÿ—๏ธ Architectural Concept -Unlike core infrastructure systems, these applications run independently in their own directories. They integrate with the host's edge router dynamically via a shared external Docker network (`proxy-net`) and Traefik routing labels. +Each workload lives in its own top-level directory with a declarative `app.yaml` manifest (`schemaVersion: "1.0"`) and a `docker-compose.yml` baseline. Workloads attach to the shared external Docker network (`proxy-net`) and expose Traefik routing labels parameterized via runtime environment variables. -### ๐ŸŒŸ Host-Agnostic & Portable Design -All service definitions inside this repository are **standard, vanilla Docker Compose configurations**. While configured to read credentials from the environment, they can be deployed on **any Linux distribution** running Docker. +The root [`deployments.yaml`](deployments.yaml) serves as the authoritative workload admission registry, mapping each workload identity and its legacy webhook aliases to `~/Workloads/`. --- ## ๐Ÿ”‘ Environment Variable Injection -To prevent secret leakage and configuration duplication, services do not hardcode environment variables or depend on static, plaintext `.env` files in git. Instead, they expect configuration keys (e.g., `PROXY_NETWORK`, `MONGO_ROOT_PASSWORD`, `JELLYFIN_DOMAIN`) to be injected into the shell environment at runtime. +To prevent secret leakage and hardcoded host configuration, compose baselines do not embed personal domains, UIDs, or host-specific paths. Runtime values (`SERVICE_DOMAIN`, `PROXY_NETWORK`, `CERT_RESOLVER`, secrets, and app-specific overrides) are injected at execution time by the host control plane (`sops-nix` rendered environment + `appctl`) or a local `.env` file for standalone portability: -You can manage and inject these variables using several strategies depending on your host OS: - -### 1. Environment Managers (e.g., Mozilla SOPS / sops-nix) -* **Our Native Setup**: On NixOS, secrets are securely managed using `sops-nix`. At boot, SOPS decrypts the keys and renders a complete `.env` template to a secure RAM-backed filesystem (`/run/secrets/rendered/traefik-deployments.env`). -* **The CLI Wrapper**: We use the local `appctl` CLI tool to automatically source this decrypted file and export its values before running the docker compose commands. - -### 2. Standard Plaintext `.env` Files (Portable Fallback) -For standard Linux environments (Ubuntu, Debian, Arch, etc.), you can create a single unified `.env` file at the root of this repository and pass it during launch: ```bash -docker compose --env-file ../.env up -d +docker compose --env-file .env up -d ``` --- -## ๐Ÿ› ๏ธ CLI Wrapper (`appctl`) - -To simplify service management across the homelab, a lightweight Bash utility named `appctl` is located at the root of this repository. - -### Commands -* **`appctl list` / `status`**: Lists all unified services and their active runtime states. -* **`appctl up `**: Sources secrets, injects configurations, and spins up the container stack. -* **`appctl down `**: Stops and cleans up the container resources. -* **`appctl restart `**: Restarts the selected service. -* **`appctl logs `**: Streams real-time logs from the selected service. -* **`appctl config `**: Prints the active environment variables injected for a service. - ---- - ## ๐Ÿ“ Repository Structure -* **`excalidraw/`**: Collaborative whiteboarding tool. -* **`jellyfin/`**: Media server for movies, shows, and music. -* **`learning/`**: Local learning hub dashboard connected to a Turso/SQLite database and docker socket proxy. -* **`mermaid/`**: Live diagramming editor. -* **`minecraft/`**: Minecraft Java Edition server. -* **`mongo-docker/`**: MongoDB instance with replica sets initialized. -* **`pgsql/`**: PostgreSQL database container. -* **`ollama/`**: Local Large Language Model API server. -* **`appctl`**: Custom Bash management CLI. +* **`deployments.yaml`**: Authoritative workload admission registry (`schemaVersion: "1.0"`). +* **`gitea/`**: Self-hosted Git service and code repository. +* **`gitea_runner/`**: Standalone Gitea Actions CI/CD runner (`act_runner`). +* **`snappymail/`**: Lightweight webmail client. +* **`jellyfin/`**: Media server and streaming hub. +* **`armonia/`**: Armonรญa del Ser API and operator dashboard. diff --git a/armonia/.env-example b/armonia/.env-example new file mode 100644 index 0000000..7acdd61 --- /dev/null +++ b/armonia/.env-example @@ -0,0 +1,36 @@ +# --- Required Build & Image Resolution --- +# Upstream Git repository URL for building armonia-dashboard (required for compose_build) +DASHBOARD_REPO_URL=https://git.example.com/org/armonia-dashboard.git +DASHBOARD_REF=main +# Pre-built container image reference for armonia-api +ARMONIA_API_IMAGE=armonia-api:latest + +# --- Runtime & Database --- +ENVIRONMENT=production +APP_ENV=production +AUTH_PROVIDER=proxy_headers +DATABASE_URL=file:/data/armonia.db +DATABASE_AUTH_TOKEN= + +# --- Domain & Proxy Configuration (injected by host runtime / appctl) --- +SERVICE_DOMAIN=armonia.example.com +PROXY_NETWORK=proxy-net +HTTP_ENTRYPOINT=web +HTTPS_ENTRYPOINT=websecure +CERT_RESOLVER=myresolver +AUTH_MIDDLEWARE=authelia-auth@docker +HTTPS_REDIRECT_MIDDLEWARE=https-redirect@docker + +# --- User/Group IDs --- +PUID=1000 +PGID=1000 + +# --- Application Settings --- +THERAPIST_NAME= +BUSINESS_NAME=Armonรญa del Ser +WHATSAPP_PHONE= +SPEI_CLABE= +SPEI_BANK= +SPEI_BENEFICIARY= +GCAL_CALENDAR_ID=primary +GOOGLE_SERVICE_ACCOUNT_JSON= diff --git a/armonia/Dockerfile.dashboard b/armonia/Dockerfile.dashboard index febde88..2d189b1 100644 --- a/armonia/Dockerfile.dashboard +++ b/armonia/Dockerfile.dashboard @@ -16,7 +16,8 @@ ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} WORKDIR /app -RUN git clone --depth 1 --branch "${DASHBOARD_REF}" "${DASHBOARD_REPO_URL}" . && \ +RUN test -n "${DASHBOARD_REPO_URL}" || { echo "ERROR: DASHBOARD_REPO_URL build arg is required" >&2; exit 1; } && \ + git clone --depth 1 --branch "${DASHBOARD_REF}" "${DASHBOARD_REPO_URL}" . && \ pnpm install --frozen-lockfile && \ pnpm run build diff --git a/gitea/docker-compose.yml b/gitea/docker-compose.yml index 48371fc..328a0b0 100644 --- a/gitea/docker-compose.yml +++ b/gitea/docker-compose.yml @@ -2,7 +2,7 @@ services: gitea: image: gitea/gitea:${GITEA_VERSION:-latest} container_name: ${CONTAINER_NAME:-gitea} - restart: always + restart: unless-stopped environment: - USER_UID=${USER_UID:-1000} - USER_GID=${USER_GID:-1000} diff --git a/jellyfin/docker-compose.yml b/jellyfin/docker-compose.yml index 4858529..96ee462 100644 --- a/jellyfin/docker-compose.yml +++ b/jellyfin/docker-compose.yml @@ -11,30 +11,30 @@ services: - ./media:/media:ro restart: unless-stopped networks: - - proxy + - proxy-net labels: - "traefik.enable=true" # HTTPS Router - - "traefik.http.routers.${SERVICE_NAME}.rule=Host(`${SERVICE_DOMAIN}`)" - - "traefik.http.routers.${SERVICE_NAME}.entrypoints=${HTTPS_ENTRYPOINT:-websecure}" - - "traefik.http.routers.${SERVICE_NAME}.tls=true" - - "traefik.http.routers.${SERVICE_NAME}.tls.certresolver=${CERT_RESOLVER:-letsencrypt}" - - "traefik.http.routers.${SERVICE_NAME}.middlewares=${SERVICE_NAME}-ratelimit@docker" - - "traefik.http.routers.${SERVICE_NAME}.service=${SERVICE_NAME}-svc" + - "traefik.http.routers.${SERVICE_NAME:-jellyfin}.rule=Host(`${SERVICE_DOMAIN}`)" + - "traefik.http.routers.${SERVICE_NAME:-jellyfin}.entrypoints=${HTTPS_ENTRYPOINT:-websecure}" + - "traefik.http.routers.${SERVICE_NAME:-jellyfin}.tls=true" + - "traefik.http.routers.${SERVICE_NAME:-jellyfin}.tls.certresolver=${CERT_RESOLVER:-myresolver}" + - "traefik.http.routers.${SERVICE_NAME:-jellyfin}.middlewares=${SERVICE_NAME:-jellyfin}-ratelimit@docker" + - "traefik.http.routers.${SERVICE_NAME:-jellyfin}.service=${SERVICE_NAME:-jellyfin}-svc" # Rate Limit Middleware - - "traefik.http.middlewares.${SERVICE_NAME}-ratelimit.ratelimit.average=${RATE_LIMIT_AVG:-100}" - - "traefik.http.middlewares.${SERVICE_NAME}-ratelimit.ratelimit.burst=${RATE_LIMIT_BURST:-50}" + - "traefik.http.middlewares.${SERVICE_NAME:-jellyfin}-ratelimit.ratelimit.average=${RATE_LIMIT_AVG:-100}" + - "traefik.http.middlewares.${SERVICE_NAME:-jellyfin}-ratelimit.ratelimit.burst=${RATE_LIMIT_BURST:-50}" # HTTP to HTTPS Redirect - - "traefik.http.routers.${SERVICE_NAME}-red.rule=Host(`${SERVICE_DOMAIN}`)" - - "traefik.http.routers.${SERVICE_NAME}-red.entrypoints=${HTTP_ENTRYPOINT:-web}" - - "traefik.http.routers.${SERVICE_NAME}-red.middlewares=https-redirect@docker" + - "traefik.http.routers.${SERVICE_NAME:-jellyfin}-red.rule=Host(`${SERVICE_DOMAIN}`)" + - "traefik.http.routers.${SERVICE_NAME:-jellyfin}-red.entrypoints=${HTTP_ENTRYPOINT:-web}" + - "traefik.http.routers.${SERVICE_NAME:-jellyfin}-red.middlewares=${HTTPS_REDIRECT_MIDDLEWARE:-https-redirect@docker}" # Service definition - - "traefik.http.services.${SERVICE_NAME}-svc.loadbalancer.server.port=8096" + - "traefik.http.services.${SERVICE_NAME:-jellyfin}-svc.loadbalancer.server.port=8096" networks: - proxy: + proxy-net: name: ${PROXY_NETWORK:-proxy-net} external: true diff --git a/snappymail/docker-compose.yml b/snappymail/docker-compose.yml index aea7db5..770984a 100644 --- a/snappymail/docker-compose.yml +++ b/snappymail/docker-compose.yml @@ -2,7 +2,7 @@ services: snappymail: image: ghcr.io/the-djmaze/snappymail:${SNAPPYMAIL_VERSION:-latest} container_name: ${CONTAINER_NAME:-snappymail} - restart: always + restart: unless-stopped volumes: - ./data:/var/lib/snappymail/_data_ networks: