docs(core): comprehensive architecture documentation, appctl guide, and Unlicense
This commit is contained in:
1 parent
6c8ab60682
commit
c1030cb887
3 files changed
+233
-117
No files matched your search
@@ -0,0 +1,24 @@
|
|||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
For more information, please refer to <https://unlicense.org>
|
||||||
@@ -1,52 +1,178 @@
|
|||||||
# Traefik Homelab Core
|
# 🌐 Traefik Homelab Core
|
||||||
|
|
||||||
This repository contains the core Control Plane for a modular, secure, and self-documenting homeserver architecture based on the **Hardened Hub** model.
|
Welcome to the **Traefik Homelab Core Control Plane** — the central orchestrator, security perimeter, and edge gateway for the `roadtotech.me` homelab cluster.
|
||||||
|
|
||||||
It consolidates all routing, authentication, and core panel management into a single, unified Docker Compose stack, optimized for secure credentials management via `sops-nix`.
|
This repository implements a **Hardened Hub** architecture where routing, SSL termination, identity management, container isolation, and orchestration are managed centrally, while user applications live in independent repositories in `~/Sites`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🏗️ Architectural Overview
|
## 🏗️ Architectural Overview & Component Roles
|
||||||
|
|
||||||
The system is split into two distinct planes to ensure stability, security, and a clean separation of concerns:
|
The infrastructure is strictly divided into two operational tiers:
|
||||||
|
|
||||||
### 1. Control Plane (This Repository)
|
```
|
||||||
The "nervous system" of the server. These services handle security, edge routing, identity, maintenance, and portal visualization. All services are defined in a single, root-level `docker-compose.yml` and state configurations are stored in `./config/`:
|
Internet (roadtotech.me)
|
||||||
|
│
|
||||||
* **`traefik` (v3.6):** The edge gateway. Handles wildcard HTTPS (Let's Encrypt DNS-01 challenges via Dynu), reverse routing, and load balancing.
|
▼
|
||||||
* **`socket-proxy`:** Security boundary. Decouples containers from the host's `/var/run/docker.sock`.
|
┌───────────────────────────────┐
|
||||||
* **`authelia`:** Provides Single Sign-On (SSO) and 2FA protection for administrative tools and exposed applications.
|
│ Traefik Edge Proxy (:443) │
|
||||||
* **`portainer`:** Visual container and stack management.
|
│ (Wildcard Let's Encrypt TLS) │
|
||||||
* **`dozzle`:** Real-time log streaming for core containers (SSO Protected).
|
└───────┬───────────────┬───────┘
|
||||||
* **`watchtower` & `diun`:** Automated image updates and registry monitoring.
|
│ │
|
||||||
* **`homepage`:** Central landing dashboard at the root domain (`arch-services.mywire.org`) serving as the entry portal.
|
Public Traffic │ │ Auth Guarded
|
||||||
|
▼ ▼
|
||||||
### 2. Data Plane (Decoupled User Applications)
|
[ Landing / Public ] [ Authelia SSO / 2FA ]
|
||||||
User applications (such as Gitea, Jellyfin, or Kanban boards) live in separate directories outside this repository (e.g. `/home/kiskaadee/Deployments/traefik-deployments`). They integrate with the Control Plane dynamically via the shared external Docker network (`proxy-net`) and Traefik routing labels.
|
│ │
|
||||||
|
│ ▼
|
||||||
---
|
└───────► [ Data Plane Apps ]
|
||||||
|
(Sites: jellyfin, docs, etc.)
|
||||||
## 🚀 Getting Started
|
|
||||||
|
|
||||||
All instructions on deployment, structure, and secrets management have been updated for this release:
|
|
||||||
|
|
||||||
👉 **See the [Setup & Secrets Management Guide](docs/setup_guide.md)**
|
|
||||||
|
|
||||||
### Quick Start (NixOS systemd Service)
|
|
||||||
If you are deploying on NixOS with the matching configuration, the service is managed declaratively. To check status or read logs:
|
|
||||||
```bash
|
|
||||||
systemctl status homeserver-core
|
|
||||||
journalctl -u homeserver-core -f
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Manual Verification
|
### 1. Control Plane Components (`~/Core`)
|
||||||
If running manually (or troubleshooting config edits):
|
* **`Traefik` (v3.6):** The edge reverse proxy and SSL terminator. Automatically obtains and maintains Let's Encrypt wildcard certificates (`*.roadtotech.me`, `roadtotech.me`) using the Dynu DNS-01 challenge. Routes incoming HTTP/HTTPS traffic to internal Docker containers over `proxy-net`.
|
||||||
|
* **`socket-proxy` (tecnativa):** Security barrier. Prevents Traefik and other containers from having direct access to `/var/run/docker.sock`, restricting access exclusively to safe container read operations via TCP (`socket-net`).
|
||||||
|
* **`Authelia`:** Single Sign-On (SSO) and Multi-Factor Authentication (2FA) identity gateway. Provides ForwardAuth middleware (`authelia-auth@docker`) that gates administrative dashboards and sensitive applications before traffic touches them.
|
||||||
|
* **`Portainer CE`:** Visual GUI for container inspection, stack lifecycle management, and log tracking.
|
||||||
|
* **`Dozzle`:** Lightweight real-time log viewer for all running containers, protected by Authelia SSO.
|
||||||
|
* **`Watchtower` & `Diun`:** Background daemons responsible for container image update notifications and automated updates.
|
||||||
|
|
||||||
|
### 2. Data Plane Applications (`~/Sites`)
|
||||||
|
User and service applications (e.g. `dashboard`, `docs`, `jellyfin`, `excalidraw`, `gitea`, `mermaid`, `minecraft`, `ollama`, `pgsql`, `mongodb`) live in isolated, dedicated git repositories under `~/Sites`. They integrate with the Core control plane dynamically via the `proxy-net` Docker network and Traefik container labels.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔒 Security Model & Secrets Architecture
|
||||||
|
|
||||||
|
The security model is built on zero hardcoded secrets and defense-in-depth:
|
||||||
|
|
||||||
|
```
|
||||||
|
[~/Config/hosts/desktop/secrets.yaml] (Encrypted with SOPS + age keys)
|
||||||
|
│
|
||||||
|
▼ (Decrypted at boot by sops-nix using SSH host key)
|
||||||
|
[/run/secrets/rendered/homeserver.env] & [/run/secrets/rendered/traefik-deployments.env]
|
||||||
|
│
|
||||||
|
▼ (Fed via --env-file and appctl)
|
||||||
|
[Core & Sites Containers]
|
||||||
|
```
|
||||||
|
|
||||||
|
1. **SOPS & sops-nix Integration:** All sensitive tokens (Dynu API key, Authelia session secrets, JWT keys, database passwords) are encrypted in `~/Config/hosts/desktop/secrets.yaml` and decrypted by NixOS at runtime into in-memory `/run/secrets/rendered/`.
|
||||||
|
2. **Edge TLS & HSTS:** All external traffic is forced over HTTPS using Let's Encrypt wildcard certificates with strict redirect schemes (`https-redirect@docker`).
|
||||||
|
3. **Authelia ForwardAuth:** Applications that require authentication declare `traefik.http.routers.<name>.middlewares=authelia-auth@docker`, delegating identity verification to Authelia.
|
||||||
|
4. **Socket Isolation:** Direct Docker daemon sockets are completely hidden behind `socket-proxy`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Orchestration with `appctl`
|
||||||
|
|
||||||
|
Applications in `~/Sites` are managed using the custom `appctl` CLI tool located in `scripts/appctl`.
|
||||||
|
|
||||||
|
### Key Commands:
|
||||||
```bash
|
```bash
|
||||||
docker compose --env-file /run/secrets/rendered/homeserver.env up -d --remove-orphans
|
# List all application stacks with status, domain, and paths
|
||||||
|
appctl list
|
||||||
|
|
||||||
|
# List all applications AND core infrastructure services
|
||||||
|
appctl list --core
|
||||||
|
|
||||||
|
# Display comprehensive metadata, routing, and card info for an app
|
||||||
|
appctl info docs
|
||||||
|
appctl info jellyfin
|
||||||
|
|
||||||
|
# Start, stop, or restart an application stack
|
||||||
|
appctl up docs
|
||||||
|
appctl down jellyfin
|
||||||
|
appctl restart dash
|
||||||
|
|
||||||
|
# Validate resolved docker compose configuration
|
||||||
|
appctl config docs
|
||||||
|
|
||||||
|
# Synchronize Homepage dashboard services.yaml from app.yaml manifests
|
||||||
|
appctl sync
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📚 Documentation
|
## 📦 Adding a New Application Stack
|
||||||
* **[Setup & Secrets Guide](docs/setup_guide.md)**: Detailed configuration, systemd service, and SOPS secret integration.
|
|
||||||
* **[Legacy Documentation](docs/legacy/)**: Archive of old setup files and html pages.
|
Adding a new application to the homelab is completely decentralized:
|
||||||
|
|
||||||
|
### 1. Create the App Directory
|
||||||
|
```bash
|
||||||
|
mkdir -p ~/Sites/homelab-myapp
|
||||||
|
cd ~/Sites/homelab-myapp
|
||||||
|
git init
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Create `app.yaml` Manifest
|
||||||
|
Define the application metadata:
|
||||||
|
```yaml
|
||||||
|
name: "myapp"
|
||||||
|
aliases:
|
||||||
|
- "app"
|
||||||
|
domain: "myapp.roadtotech.me"
|
||||||
|
description: "My Awesome New Homelab App"
|
||||||
|
visible: true
|
||||||
|
auth: false
|
||||||
|
networks:
|
||||||
|
- proxy-net
|
||||||
|
env:
|
||||||
|
CUSTOM_VAR: "value"
|
||||||
|
homepage:
|
||||||
|
title: "My App"
|
||||||
|
group: "Knowledge & Notes"
|
||||||
|
icon: "custom.png"
|
||||||
|
container: "myapp"
|
||||||
|
weight: 50
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Create `docker-compose.yml`
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
myapp:
|
||||||
|
image: myapp/image:latest
|
||||||
|
container_name: ${CONTAINER_NAME:-myapp}
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- proxy-net
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
# HTTPS Router
|
||||||
|
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.rule=Host(`${SERVICE_DOMAIN}`)"
|
||||||
|
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.tls=true"
|
||||||
|
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.service=${CONTAINER_NAME:-myapp}-svc"
|
||||||
|
# HTTP to HTTPS Redirect
|
||||||
|
- "traefik.http.routers.${CONTAINER_NAME:-myapp}-red.rule=Host(`${SERVICE_DOMAIN}`)"
|
||||||
|
- "traefik.http.routers.${CONTAINER_NAME:-myapp}-red.entrypoints=web"
|
||||||
|
- "traefik.http.routers.${CONTAINER_NAME:-myapp}-red.middlewares=https-redirect@docker"
|
||||||
|
# Service Target Port
|
||||||
|
- "traefik.http.services.${CONTAINER_NAME:-myapp}-svc.loadbalancer.server.port=8080"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
proxy-net:
|
||||||
|
name: ${PROXY_NETWORK:-proxy-net}
|
||||||
|
external: true
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Deploy and Sync
|
||||||
|
```bash
|
||||||
|
appctl up myapp
|
||||||
|
```
|
||||||
|
`appctl` will start the container, inject standard environment variables, and automatically recompile [`homelab-dashboard/config/services.yaml`](file:///home/kiskaadee/Sites/homelab-dashboard/config/services.yaml).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ⚙️ NixOS Service Management
|
||||||
|
|
||||||
|
The Core Control Plane runs as a native systemd unit managed declaratively by NixOS:
|
||||||
|
|
||||||
|
* **Service Unit:** `homeserver-core.service`
|
||||||
|
* **Nix Module:** [`~/Config/hosts/desktop/homeserver.nix`](file:///home/kiskaadee/Config/hosts/desktop/homeserver.nix)
|
||||||
|
* **Status Inspection:** `systemctl status homeserver-core`
|
||||||
|
* **Logs:** `journalctl -u homeserver-core -f`
|
||||||
|
* **Restart:** `sudo systemctl restart homeserver-core`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📄 License
|
||||||
|
This repository is released into the public domain under the [Unlicense](LICENSE).
|
||||||
+45
-79
@@ -1,80 +1,80 @@
|
|||||||
# Setup & Secrets Management Guide (Traefik Homelab)
|
# Setup & Secrets Management Guide (Traefik Homelab)
|
||||||
|
|
||||||
This document provides a guide for deploying, managing, and securing the consolidated homeserver core stack.
|
This document provides an exhaustive operational guide for configuring, deploying, securing, and maintaining the **Traefik Homelab Core Control Plane** on NixOS.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🏗️ Architectural Overview
|
## 🏗️ Architectural Overview
|
||||||
|
|
||||||
The core infrastructure is organized as a single, unified Docker Compose stack:
|
The core infrastructure runs as a consolidated Docker Compose stack in [`/home/kiskaadee/Core`](file:///home/kiskaadee/Core):
|
||||||
|
|
||||||
* **/docker-compose.yml**: Root orchestrator defining all core services (`traefik`, `authelia`, `portainer`, `dozzle`, `watchtower`, `diun`, `homepage`, `socket-proxy`).
|
* **[`docker-compose.yml`](file:///home/kiskaadee/Core/docker-compose.yml)**: Root compose specification defining all control plane services (`traefik`, `authelia`, `portainer`, `dozzle`, `watchtower`, `diun`, `socket-proxy`).
|
||||||
* **/config/**: Holds the configuration directories and sqlite databases for all services:
|
* **[`config/`](file:///home/kiskaadee/Core/config/)**: Persistent state directories:
|
||||||
* `config/letsencrypt/`: Contains SSL certificate state (`acme.json`).
|
* `config/letsencrypt/`: Contains SSL certificate storage (`acme.json`).
|
||||||
* `config/authelia/`: Contains single sign-on configs (`configuration.yml`, `users.yml`) and database (`db.sqlite3`).
|
* `config/authelia/`: Contains configuration (`configuration.yml`, `users.yml`) and authentication database (`db.sqlite3`).
|
||||||
* `config/homepage/`: Contains dashboard layout files (`services.yaml`, `bookmarks.yaml`, etc.).
|
* `config/diun/`: Diun container update tracking database (`diun.db`).
|
||||||
* `config/diun/`: Diun registry monitoring database (`diun.db`).
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🔒 Credentials & Secrets Management
|
## 🔒 Secrets Architecture & SOPS Flow
|
||||||
|
|
||||||
Secrets are managed declaratively using **`sops-nix`** (Mozilla SOPS + age keys) inside your system configuration repository (`~/Config`). This keeps all private credentials completely out of Git in an encrypted format.
|
All sensitive tokens, encryption keys, and credentials are encrypted using **`sops-nix`** (Mozilla SOPS with age keys derived from the host SSH key). No plaintext secrets exist in any git repository.
|
||||||
|
|
||||||
### How Secrets Flow:
|
### Secrets Lifecycle:
|
||||||
|
|
||||||
```
|
```
|
||||||
[~/Config/hosts/desktop/secrets.yaml] (Encrypted)
|
[~/Config/hosts/desktop/secrets.yaml] (Encrypted with Age)
|
||||||
│
|
│
|
||||||
▼ (Decrypted at boot by sops-nix using SSH host key)
|
▼ (Decrypted at boot by sops-nix daemon)
|
||||||
[/run/secrets/rendered/homeserver.env] (Runtime Environment File)
|
1. [/run/secrets/rendered/homeserver.env] --> Fed to Core Compose Stack
|
||||||
|
2. [/run/secrets/rendered/traefik-deployments.env] --> Fed to appctl & App Stacks
|
||||||
│
|
│
|
||||||
▼ (Fed via --env-file flag into Docker Compose)
|
▼
|
||||||
[Docker Containers] (Active environment variables)
|
[Active Docker Containers]
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🔑 Adding/Editing Secrets
|
## 🔑 Modifying and Adding Secrets
|
||||||
|
|
||||||
To add or modify credentials (e.g. changing your Dynu API key or updating Authelia users):
|
To update credentials (e.g. changing your Dynu API key or updating Authelia user passwords):
|
||||||
|
|
||||||
1. Navigate to your system configuration repository:
|
1. Navigate to your NixOS configuration repository:
|
||||||
```bash
|
```bash
|
||||||
cd ~/Config
|
cd ~/Config
|
||||||
```
|
```
|
||||||
2. Decrypt and open the secrets file in your editor using SOPS:
|
2. Decrypt and open the secrets file in your editor:
|
||||||
```bash
|
```bash
|
||||||
nix-shell -p sops --run "sops hosts/desktop/secrets.yaml"
|
nix-shell -p sops --run "sops hosts/desktop/secrets.yaml"
|
||||||
```
|
```
|
||||||
3. Append or edit the required keys under the root block:
|
3. Update or append keys under the root block:
|
||||||
```yaml
|
```yaml
|
||||||
dynu_api_key: "your_dynu_api_key"
|
dynu_api_key: "your_dynu_api_key"
|
||||||
acme_email: "your_email@provider.com"
|
acme_email: "your_email@domain.com"
|
||||||
authelia_session_secret: "secure_64_character_hex_string"
|
authelia_session_secret: "secure_64_char_secret"
|
||||||
authelia_storage_encryption_key: "secure_64_character_hex_string"
|
authelia_storage_encryption_key: "secure_64_char_key"
|
||||||
authelia_identity_validation_reset_password_jwt_secret: "secure_64_character_hex_string"
|
authelia_identity_validation_reset_password_jwt_secret: "secure_64_char_jwt_secret"
|
||||||
|
|
||||||
# Hashed password for the default admin user
|
|
||||||
authelia_user_kiskaadee_password_hash: "$argon2id$v=19$m=65536..."
|
authelia_user_kiskaadee_password_hash: "$argon2id$v=19$m=65536..."
|
||||||
```
|
```
|
||||||
*To generate an Argon2 password hash securely, run:*
|
*To generate an Argon2 password hash securely, run:*
|
||||||
`docker run --rm -it authelia/authelia:latest authelia crypto hash generate argon2`
|
```bash
|
||||||
4. Save and close the editor. SOPS will automatically encrypt the file and write it back to disk.
|
docker run --rm -it authelia/authelia:latest authelia crypto hash generate argon2
|
||||||
|
```
|
||||||
|
4. Save and close. SOPS will automatically encrypt the modified file before saving.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## ⚙️ NixOS Integration
|
## ⚙️ Declarative NixOS Modules
|
||||||
|
|
||||||
The stack is managed as a declarative systemd service inside `/home/kiskaadee/Config/hosts/desktop/homeserver.nix`:
|
The Core stack and deployment environments are defined declaratively in `~/Config`:
|
||||||
|
|
||||||
### 1. Secret Environment Template
|
### 1. Control Plane Module ([`hosts/desktop/homeserver.nix`](file:///home/kiskaadee/Config/hosts/desktop/homeserver.nix))
|
||||||
The module defines a SOPS template to gather all secrets and structure them as key-value pairs at `/run/secrets/rendered/homeserver.env`:
|
Generates `/run/secrets/rendered/homeserver.env` and manages the `homeserver-core.service` systemd daemon:
|
||||||
```nix
|
```nix
|
||||||
sops.templates."homeserver.env" = {
|
sops.templates."homeserver.env" = {
|
||||||
owner = "kiskaadee";
|
owner = "kiskaadee";
|
||||||
content = lib.generators.toKeyValue {} {
|
content = lib.generators.toKeyValue {} {
|
||||||
DOMAIN = "arch-services.mywire.org";
|
DOMAIN = "roadtotech.me";
|
||||||
DOCKER_API_VERSION = "1.40";
|
DOCKER_API_VERSION = "1.40";
|
||||||
DYNU_API_KEY = config.sops.placeholder.dynu_api_key;
|
DYNU_API_KEY = config.sops.placeholder.dynu_api_key;
|
||||||
ACME_EMAIL = config.sops.placeholder.acme_email;
|
ACME_EMAIL = config.sops.placeholder.acme_email;
|
||||||
@@ -83,59 +83,25 @@ sops.templates."homeserver.env" = {
|
|||||||
AUTHELIA_IDENTITY_VALIDATION_RESET_PASSWORD_JWT_SECRET = config.sops.placeholder.authelia_identity_validation_reset_password_jwt_secret;
|
AUTHELIA_IDENTITY_VALIDATION_RESET_PASSWORD_JWT_SECRET = config.sops.placeholder.authelia_identity_validation_reset_password_jwt_secret;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# 2. Declarative User Database Template
|
|
||||||
We also generate Authelia's `users.yml` file from the decrypted Argon2 hash:
|
|
||||||
```nix
|
|
||||||
sops.templates."users.yml" = {
|
|
||||||
owner = "kiskaadee";
|
|
||||||
content = ''
|
|
||||||
users:
|
|
||||||
kiskaadee:
|
|
||||||
displayname: "Kiskaadee"
|
|
||||||
password: "${config.sops.placeholder.authelia_user_kiskaadee_password_hash}"
|
|
||||||
email: "fcortesbio@gmail.com"
|
|
||||||
groups:
|
|
||||||
- admins
|
|
||||||
- dev
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. systemd Lifecycle Daemon
|
### 2. Applications Secret Module ([`hosts/desktop/traefik-deployments.nix`](file:///home/kiskaadee/Config/hosts/desktop/traefik-deployments.nix))
|
||||||
The service starts and stops the compose stack automatically:
|
Generates `/run/secrets/rendered/traefik-deployments.env` consumed by `appctl`.
|
||||||
```nix
|
|
||||||
systemd.services.homeserver-core = {
|
|
||||||
description = "Homeserver Core Stack";
|
|
||||||
after = [ "network-online.target" "docker.service" ];
|
|
||||||
wants = [ "network-online.target" ];
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
WorkingDirectory = "/home/kiskaadee/Deployments/homeserver";
|
|
||||||
ExecStart = "${pkgs.docker-compose}/bin/docker-compose --env-file ${config.sops.templates."homeserver.env".path} up -d --remove-orphans";
|
|
||||||
ExecStop = "${pkgs.docker-compose}/bin/docker-compose down";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🚀 Running and Managing the Stack
|
## 🚀 Running and Managing the Stack
|
||||||
|
|
||||||
Because the systemd service manages the containers, standard `systemctl` commands can be used:
|
### Standard Systemd Operations:
|
||||||
|
* **Start:** `sudo systemctl start homeserver-core`
|
||||||
|
* **Stop:** `sudo systemctl stop homeserver-core`
|
||||||
|
* **Restart:** `sudo systemctl restart homeserver-core`
|
||||||
|
* **Status:** `systemctl status homeserver-core`
|
||||||
|
* **Live Logs:** `journalctl -u homeserver-core -f`
|
||||||
|
|
||||||
* **Start the stack**: `sudo systemctl start homeserver-core`
|
### Dynamic Tweaks without Rebuilding NixOS:
|
||||||
* **Stop the stack**: `sudo systemctl stop homeserver-core`
|
When making configuration adjustments to `docker-compose.yml` (e.g. tuning Traefik middlewares):
|
||||||
* **Check service status**: `systemctl status homeserver-core`
|
|
||||||
* **Check logs**: `journalctl -u homeserver-core`
|
|
||||||
|
|
||||||
### Dynamic Configuration Tweaks (Non-Nix Workflow)
|
|
||||||
If you modify `docker-compose.yml` (e.g. adding a new Traefik routing label), you do **not** need to rebuild NixOS! You can apply it instantly:
|
|
||||||
```bash
|
```bash
|
||||||
cd /home/kiskaadee/Deployments/homeserver
|
cd ~/Core
|
||||||
docker compose --env-file /run/secrets/rendered/homeserver.env up -d --remove-orphans
|
docker compose --env-file /run/secrets/rendered/homeserver.env up -d --remove-orphans
|
||||||
```
|
```
|
||||||
This preserves the extreme agility of Docker Compose while keeping your system configuration and secrets declaratively managed.
|
|
||||||
Reference in new issue
Block a user