refactor(core): decouple applications to separate deployments and streamline core control plane
This commit restructures the homeserver repository to isolate the core gateway and management tools (Control Plane) from user applications (Data Plane). This allows applications to have independent lifecycles and CI/CD pipelines, preventing git history contamination.
- Relocated user applications (excalidraw, gitea, jellyfin, learning-hub, mermaid, ollama) to an external deployments directory.
- Moved homepage to the root directory as a core server component and removed the empty apps directory.
- Streamlined up.sh and down.sh to deploy and stop only core services and homepage, removing --infra-only parameters.
- Replaced all hardcoded domain names with a configurable global DOMAIN environment variable in docker-compose files.
- Used Authelia templating ({{ env "DOMAIN" }}) in configuration.yml to dynamically resolve SSO cookie domains and redirection URLs.
- Updated up.sh and down.sh helpers to explicitly pass env files via --env-file flags, resolving compose interpolation warnings.
- Created a declarative NixOS module (infra/nixos/dynu-ddns.nix) to orchestrate the Dynu DDNS update script.
- Created Authelia .env-example template for setup reproducibility.
- Refactored .gitignore to exclude obsolete app cache rules and keep it minimal to core secrets, volumes, and logs.
- Updated documentation (README, architecture, roadmap, usability) to document decoupled deployments and public/SSO service templates.
This commit is contained in:
1 parent
e559979434
commit
ef72e3ea0f
31 files changed
+289
-615
No files matched your search
+14
-28
@@ -1,41 +1,27 @@
|
||||
# Environments & Secrets
|
||||
.env
|
||||
.env.*
|
||||
**/letsencrypt/acme.json
|
||||
**/.env
|
||||
**/config/*.env
|
||||
**/config/users.yml
|
||||
**/.env
|
||||
|
||||
# Authelia Data
|
||||
**/authelia/config/db.sqlite3
|
||||
**/authelia/config/emails.txt
|
||||
|
||||
# Application Data (Persistent Volumes)
|
||||
**/data/
|
||||
**/ollama_data/
|
||||
**/portainer_data/
|
||||
|
||||
# Infrastructure Data
|
||||
infra/diun/data/
|
||||
infra/authelia/config/db.sqlite3
|
||||
|
||||
# Certificates
|
||||
# SSL / ACME Certificates & Keys
|
||||
**/letsencrypt/acme.json
|
||||
**/*.key
|
||||
**/*.crt
|
||||
**/*.pem
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
.venv/
|
||||
venv/
|
||||
# Authelia Databases & Mail Logs
|
||||
infra/authelia/config/db.sqlite3
|
||||
infra/authelia/config/emails.txt
|
||||
|
||||
# OS Metadata
|
||||
# Infrastructure Persistent Volumes & Logs
|
||||
**/portainer_data/
|
||||
infra/diun/data/
|
||||
homepage/config/logs/
|
||||
|
||||
# OS & Editor Metadata
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
apps/homepage/config/logs/
|
||||
|
||||
apps/learning/learning.db
|
||||
apps/jellyfin/cache
|
||||
apps/jellyfin/config
|
||||
.vscode/
|
||||
.idea/
|
||||
@@ -1,29 +1,25 @@
|
||||
# Hardened Private Cloud Hub
|
||||
|
||||
This repository contains a modular, secure, and self-documenting homeserver architecture based on the **Hardened Hub** model.
|
||||
This repository contains the core Control Plane for a modular, secure, and self-documenting homeserver architecture based on the **Hardened Hub** model.
|
||||
|
||||
## 🏗️ Architectural Overview
|
||||
|
||||
The system is split into two distinct layers to ensure stability and security:
|
||||
The system is split into two distinct planes to ensure stability, security, and a clean separation of concerns:
|
||||
|
||||
### 1. Control Plane (`infra/`)
|
||||
The "nervous system" of the server. These services handle security, routing, identity, and maintenance.
|
||||
### 1. Control Plane (`infra/` & `homepage/`)
|
||||
The "nervous system" of the server. These services handle security, edge routing, identity, maintenance, and portal visualization.
|
||||
|
||||
- **Core (`infra/core`):**
|
||||
- **Traefik (v3.6):** The front door. Handles HTTPS (Let's Encrypt), routing, and load balancing.
|
||||
- **Socket-Proxy:** The security wall. Decouples containers from the host's `/var/run/docker.sock`.
|
||||
- **Identity (`infra/authelia`):** Provides Single Sign-On (SSO) and 2FA protection for apps.
|
||||
- **Traefik (v3.6):** The entry gateway. Handles HTTPS (Let's Encrypt DNS-01 challenges), routing, and load balancing.
|
||||
- **Socket-Proxy:** The security boundary. Decouples core containers from the host's `/var/run/docker.sock`.
|
||||
- **Identity (`infra/authelia`):** Provides Single Sign-On (SSO) and 2FA protection for administrative tools and exposed applications.
|
||||
- **Management (`infra/portainer`):** Visual container and stack management.
|
||||
- **Monitoring (`infra/dozzle`):** Real-time log streaming for all containers (SSO Protected).
|
||||
- **Maintenance (`infra/watchtower`, `infra/diun`):** Automated image updates and notifications.
|
||||
- **Monitoring (`infra/dozzle`):** Real-time log streaming for core containers (SSO Protected).
|
||||
- **Maintenance (`infra/watchtower`, `infra/diun`):** Automated image updates and registry monitoring.
|
||||
- **Portal (`homepage/`):** Central landing dashboard at `arch-services.mywire.org` serving as the single entry point.
|
||||
|
||||
### 2. Data Plane (`apps/`)
|
||||
The consumer-facing applications.
|
||||
|
||||
- **Homepage:** Central dashboard at `arch-services.mywire.org`.
|
||||
- **Gitea:** Self-hosted Git service (SSO Protected).
|
||||
- **Ollama:** Local LLM runner with 3 replicas.
|
||||
- **Excalidraw & Mermaid:** Visual tools for whiteboarding and diagramming.
|
||||
### 2. Data Plane (Decoupled User Applications)
|
||||
User applications (such as Gitea, Jellyfin, or Kanban boards) are kept fully decoupled in separate directories outside this repository. They integrate with the Control Plane dynamically via the shared external Docker network (`proxy-net`) and Traefik routing labels.
|
||||
|
||||
---
|
||||
|
||||
@@ -45,21 +41,18 @@ Secrets are kept out of the configuration files and stored in `.env` files (git-
|
||||
```
|
||||
|
||||
### 2. Deployment
|
||||
Use the `up.sh` script to launch the stack. The script handles networks, permissions, and service sequencing.
|
||||
Use the `up.sh` script to launch the core stack. The script handles network creation, Let's Encrypt certificate file initialization, and starts all infrastructure services plus the Homepage portal.
|
||||
|
||||
```bash
|
||||
# Start everything (Infrastructure + Apps)
|
||||
# Start the entire Core Infrastructure + Homepage
|
||||
./up.sh
|
||||
|
||||
# Start ONLY the Control Plane
|
||||
./up.sh --infra-only
|
||||
```
|
||||
|
||||
### 3. Verification
|
||||
Once deployed, verify your services are reachable:
|
||||
- **Homepage:** `https://arch-services.mywire.org`
|
||||
- **Homepage Dashboard:** `https://arch-services.mywire.org`
|
||||
- **Auth Portal:** `https://auth.arch-services.mywire.org`
|
||||
- **Gitea:** `https://gitea.arch-services.mywire.org` (Redirects to Auth)
|
||||
- **Traefik Dashboard:** `https://traefik.arch-services.mywire.org` (Redirects to Auth)
|
||||
- **Logs:** `https://logs.arch-services.mywire.org` (Redirects to Auth)
|
||||
|
||||
---
|
||||
@@ -71,7 +64,7 @@ The system includes built-in tools for real-time monitoring and management:
|
||||
- **Traefik Dashboard**: `https://traefik.arch-services.mywire.org` — View routing, entrypoints, and certificate status (SSO Protected).
|
||||
- **Dozzle**: `https://logs.arch-services.mywire.org` — Real-time log streaming for all containers (SSO Protected).
|
||||
- **Portainer**: `https://portainer.arch-services.mywire.org` — Advanced container, volume, and stack management (SSO Protected).
|
||||
- **Homepage**: `https://arch-services.mywire.org` — The central "Single Pane of Glass" for all your services.
|
||||
- **Homepage**: `https://arch-services.mywire.org` — The central portal displaying status indicators for all services.
|
||||
|
||||
### Maintenance Scripts
|
||||
For rapid diagnostics and common fixes, use the included automation scripts:
|
||||
@@ -93,10 +86,11 @@ This policy is currently enabled on core infrastructure and is recommended for a
|
||||
---
|
||||
|
||||
## 🛡️ Security Features
|
||||
- **Socket Isolation:** No application container has access to the Docker socket. All management tools use the `socket-proxy`.
|
||||
- **SSO Integration:** Critical apps (Gitea, Dozzle, Portainer) are behind Authelia Forward Auth.
|
||||
- **Automatic TLS:** Traefik manages Let's Encrypt certificates via DNS-01 challenges with Dynu.
|
||||
- **Network Segmentation:** Services are isolated on `proxy-net` and `socket-net`.
|
||||
- **Socket Isolation:** No container has access to the host's raw Docker socket. All management tools communicate via the read/write-controlled `socket-proxy`.
|
||||
- **SSO Integration:** Critical management tools (Portainer, Dozzle) and sensitive user applications are behind Authelia Forward Auth.
|
||||
- **Automatic TLS:** Traefik automatically manages wildcard Let's Encrypt certificates via DNS-01 challenges with Dynu.
|
||||
- **Network Segmentation:** System traffic is isolated on `proxy-net` and `socket-net` networks.
|
||||
- **Decoupled Architecture:** Application stacks are isolated from the core repository config, preventing Git history contamination and permitting independent CI/CD pipelines.
|
||||
|
||||
---
|
||||
|
||||
@@ -105,9 +99,7 @@ This policy is currently enabled on core infrastructure and is recommended for a
|
||||
For more in-depth information, please refer to the following guides:
|
||||
|
||||
- **[Server Architecture](https://kiskaadee.github.io/arch-traefik-hub/architecture.html)**: Deep dive into the layered model, networking, and security posture.
|
||||
- **[Usability & Operations](https://kiskaadee.github.io/arch-traefik-hub/usability.html)**: How to use the hub, add new apps, and manage updates.
|
||||
- **[Usability & Operations](https://kiskaadee.github.io/arch-traefik-hub/usability.html)**: How to use the hub, expose new decoupled apps, and manage updates.
|
||||
- **[Troubleshooting](https://kiskaadee.github.io/arch-traefik-hub/troubleshooting.html)**: Solutions for common connectivity, SSL, and authentication issues.
|
||||
- **[Project Roadmap](https://kiskaadee.github.io/arch-traefik-hub/roadmap.html)**: Current status and future planned features.
|
||||
- **[Dynu IP Protocol](https://kiskaadee.github.io/arch-traefik-hub/dynu-ip-update-protocol.html)**: Technical details on the DDNS synchronization mechanism.
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
services:
|
||||
excalidraw:
|
||||
image: excalidraw/excalidraw:latest
|
||||
environment:
|
||||
- REACT_APP_BACKEND_V2_GET_URL=https://excalidraw.arch-services.mywire.org/api/v2
|
||||
- REACT_APP_BACKEND_V2_POST_URL=https://excalidraw.arch-services.mywire.org/api/v2
|
||||
- REACT_APP_WS_SERVER_URL=wss://excalidraw.arch-services.mywire.org/socket.io
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.excalidraw.rule=Host(`excalidraw.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.excalidraw.entrypoints=websecure"
|
||||
- "traefik.http.routers.excalidraw.tls=true"
|
||||
- "traefik.http.routers.excalidraw.tls.certresolver=myresolver"
|
||||
- "traefik.http.routers.excalidraw.service=excalidraw-svc"
|
||||
- "traefik.http.routers.excalidraw-red.rule=Host(`excalidraw.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.excalidraw-red.entrypoints=web"
|
||||
- "traefik.http.routers.excalidraw-red.middlewares=https-redirect@docker"
|
||||
|
||||
- "traefik.http.services.excalidraw-svc.loadbalancer.server.port=80"
|
||||
|
||||
excalidraw-room:
|
||||
image: excalidraw/excalidraw-room:latest
|
||||
restart: on-failure
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.excalidraw-room.rule=Host(`excalidraw.arch-services.mywire.org`) && PathPrefix(`/socket.io`)"
|
||||
- "traefik.http.routers.excalidraw-room.entrypoints=websecure"
|
||||
- "traefik.http.routers.excalidraw-room.tls=true"
|
||||
- "traefik.http.routers.excalidraw-room.tls.certresolver=myresolver"
|
||||
- "traefik.http.routers.excalidraw-room.service=excalidraw-room-svc"
|
||||
- "traefik.http.routers.excalidraw-room-red.rule=Host(`excalidraw.arch-services.mywire.org`) && PathPrefix(`/socket.io`)"
|
||||
- "traefik.http.routers.excalidraw-room-red.entrypoints=web"
|
||||
- "traefik.http.routers.excalidraw-room-red.middlewares=https-redirect@docker"
|
||||
|
||||
- "traefik.http.services.excalidraw-room-svc.loadbalancer.server.port=8080"
|
||||
|
||||
|
||||
networks:
|
||||
proxy-net:
|
||||
external: true
|
||||
@@ -1,30 +0,0 @@
|
||||
services:
|
||||
server:
|
||||
image: gitea/gitea:latest
|
||||
container_name: gitea
|
||||
environment:
|
||||
- USER_UID=1000
|
||||
- USER_GID=1000
|
||||
volumes:
|
||||
- ./data:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.gitea.rule=Host(`gitea.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.gitea.entrypoints=websecure"
|
||||
- "traefik.http.routers.gitea.tls=true"
|
||||
- "traefik.http.routers.gitea.middlewares=authelia-auth@docker"
|
||||
- "traefik.http.routers.gitea.service=gitea-svc"
|
||||
- "traefik.http.routers.gitea-red.rule=Host(`gitea.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.gitea-red.entrypoints=web"
|
||||
- "traefik.http.routers.gitea-red.middlewares=https-redirect@docker"
|
||||
|
||||
- "traefik.http.services.gitea-svc.loadbalancer.server.port=3000"
|
||||
|
||||
|
||||
networks:
|
||||
proxy-net:
|
||||
external: true
|
||||
@@ -1,35 +0,0 @@
|
||||
services:
|
||||
jellyfin:
|
||||
image: jellyfin/jellyfin:latest
|
||||
container_name: jellyfin
|
||||
user: 1000:1000 # Assuming standard user, change if needed
|
||||
volumes:
|
||||
- ./config:/config
|
||||
- ./cache:/cache
|
||||
- /home/kiskaadee/media:/media # Assuming a media path in home
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
# Public (HTTPS)
|
||||
- "traefik.http.routers.jellyfin.rule=Host(`jellyfin.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.jellyfin.entrypoints=websecure"
|
||||
- "traefik.http.routers.jellyfin.tls=true"
|
||||
- "traefik.http.routers.jellyfin.middlewares=jellyfin-ratelimit@docker"
|
||||
- "traefik.http.routers.jellyfin.service=jellyfin-svc"
|
||||
|
||||
# Middleware: Rate Limit for Jellyfin
|
||||
- "traefik.http.middlewares.jellyfin-ratelimit.ratelimit.average=100"
|
||||
- "traefik.http.middlewares.jellyfin-ratelimit.ratelimit.burst=50"
|
||||
|
||||
# Public (Redirect)
|
||||
- "traefik.http.routers.jellyfin-red.rule=Host(`jellyfin.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.jellyfin-red.entrypoints=web"
|
||||
- "traefik.http.routers.jellyfin-red.middlewares=https-redirect@docker"
|
||||
|
||||
- "traefik.http.services.jellyfin-svc.loadbalancer.server.port=8096"
|
||||
|
||||
networks:
|
||||
proxy-net:
|
||||
external: true
|
||||
@@ -1,12 +0,0 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
SQLALCHEMY_DATABASE_URL = "sqlite:///./learning.db"
|
||||
|
||||
engine = create_engine(
|
||||
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
|
||||
)
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
Base = declarative_base()
|
||||
@@ -1,185 +0,0 @@
|
||||
from fastapi import FastAPI, Depends, HTTPException
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import FileResponse
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List, Optional
|
||||
from pydantic import BaseModel
|
||||
import uvicorn
|
||||
import os
|
||||
import psutil
|
||||
import docker
|
||||
|
||||
from . import models, database
|
||||
|
||||
# Create tables
|
||||
models.Base.metadata.create_all(bind=database.engine)
|
||||
|
||||
app = FastAPI(title="Learning Hub API")
|
||||
|
||||
# Initialize Docker client
|
||||
try:
|
||||
docker_client = docker.from_env()
|
||||
except Exception:
|
||||
docker_client = None
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Dependency
|
||||
def get_db():
|
||||
db = database.SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
class CourseBase(BaseModel):
|
||||
title: str
|
||||
description: Optional[str] = None
|
||||
main_link: str
|
||||
last_link: Optional[str] = None
|
||||
status: str = "Planning"
|
||||
|
||||
class CourseCreate(CourseBase):
|
||||
pass
|
||||
|
||||
class Course(CourseBase):
|
||||
id: int
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
@app.get("/api/system-stats")
|
||||
def get_system_stats():
|
||||
cpu = psutil.cpu_percent(interval=None) # Use None for non-blocking if called frequently
|
||||
ram = psutil.virtual_memory()
|
||||
# Monitor /home partition
|
||||
disk_path = '/home' if os.path.exists('/home') else '/'
|
||||
disk = psutil.disk_usage(disk_path)
|
||||
return {
|
||||
"cpu": cpu,
|
||||
"ram_total": round(ram.total / (1024**3), 2),
|
||||
"ram_used": round(ram.used / (1024**3), 2),
|
||||
"ram_percent": ram.percent,
|
||||
"disk_total": round(disk.total / (1024**3), 2),
|
||||
"disk_used": round(disk.used / (1024**3), 2),
|
||||
"disk_percent": disk.percent
|
||||
}
|
||||
|
||||
@app.get("/api/services")
|
||||
def get_services():
|
||||
services_config = {
|
||||
"infrastructure": [
|
||||
{"name": "Traefik", "container": "traefik", "href": "https://traefik.arch-services.mywire.org"},
|
||||
{"name": "Authelia", "container": "authelia", "href": "https://auth.arch-services.mywire.org"},
|
||||
{"name": "Portainer", "container": "portainer", "href": "https://portainer.arch-services.mywire.org"},
|
||||
{"name": "Dozzle", "container": "dozzle", "href": "https://logs.arch-services.mywire.org"},
|
||||
],
|
||||
"applications": [
|
||||
{"name": "Gitea", "container": "gitea", "href": "https://gitea.arch-services.mywire.org"},
|
||||
{"name": "Ollama", "container": "ollama-ollama-1", "href": "https://ollama.arch-services.mywire.org"},
|
||||
{"name": "Excalidraw", "container": "excalidraw-excalidraw-1", "href": "https://excalidraw.arch-services.mywire.org"},
|
||||
{"name": "Mermaid", "container": "mermaid-live-editor", "href": "https://mermaid.arch-services.mywire.org"},
|
||||
{"name": "Jellyfin", "container": "jellyfin", "href": "https://jellyfin.arch-services.mywire.org"},
|
||||
]
|
||||
}
|
||||
|
||||
results = {"infrastructure": [], "applications": []}
|
||||
|
||||
if not docker_client:
|
||||
return services_config
|
||||
|
||||
for category in services_config:
|
||||
for s in services_config[category]:
|
||||
try:
|
||||
container = docker_client.containers.get(s["container"])
|
||||
status = container.status
|
||||
except Exception:
|
||||
status = "unknown"
|
||||
results[category].append({**s, "status": status})
|
||||
|
||||
return results
|
||||
|
||||
@app.get("/api/bookmarks")
|
||||
def get_bookmarks():
|
||||
return {
|
||||
"Developer": [{"name": "Github", "href": "https://github.com/"}],
|
||||
"Social": [{"name": "Reddit", "href": "https://reddit.com/"}],
|
||||
"Entertainment": [{"name": "YouTube", "href": "https://youtube.com/"}]
|
||||
}
|
||||
|
||||
@app.get("/api/courses", response_model=List[Course])
|
||||
def read_courses(db: Session = Depends(get_db)):
|
||||
return db.query(models.Course).all()
|
||||
|
||||
@app.post("/api/courses", response_model=Course)
|
||||
def create_course(course: CourseCreate, db: Session = Depends(get_db)):
|
||||
db_course = models.Course(**course.dict())
|
||||
db.add(db_course)
|
||||
db.commit()
|
||||
db.refresh(db_course)
|
||||
return db_course
|
||||
|
||||
@app.put("/api/courses/{course_id}", response_model=Course)
|
||||
def update_course(course_id: int, course: CourseCreate, db: Session = Depends(get_db)):
|
||||
db_course = db.query(models.Course).filter(models.Course.id == course_id).first()
|
||||
if not db_course:
|
||||
raise HTTPException(status_code=404, detail="Course not found")
|
||||
|
||||
for key, value in course.dict().items():
|
||||
setattr(db_course, key, value)
|
||||
|
||||
db.commit()
|
||||
db.refresh(db_course)
|
||||
return db_course
|
||||
|
||||
@app.delete("/api/courses/{course_id}")
|
||||
def delete_course(course_id: int, db: Session = Depends(get_db)):
|
||||
db_course = db.query(models.Course).filter(models.Course.id == course_id).first()
|
||||
if not db_course:
|
||||
raise HTTPException(status_code=404, detail="Course not found")
|
||||
db.delete(db_course)
|
||||
db.commit()
|
||||
return {"message": "Course deleted"}
|
||||
|
||||
# Seed initial data if empty
|
||||
@app.on_event("startup")
|
||||
def startup_event():
|
||||
db = database.SessionLocal()
|
||||
if db.query(models.Course).count() == 0:
|
||||
initial_courses = [
|
||||
models.Course(
|
||||
title="Desarrollo Backend con Python",
|
||||
description="Platzi Learning Path",
|
||||
main_link="https://platzi.com/mis-rutas/16609931/",
|
||||
status="WIP"
|
||||
),
|
||||
models.Course(
|
||||
title="Amazon Junior Software Developer",
|
||||
description="Coursera Professional Certificate",
|
||||
main_link="https://www.coursera.org/professional-certificates/amazon-junior-software-developer",
|
||||
status="WIP"
|
||||
),
|
||||
models.Course(
|
||||
title="Software Design and Architecture",
|
||||
description="Coursera Specialization",
|
||||
main_link="https://www.coursera.org/specializations/software-design-architecture",
|
||||
status="WIP"
|
||||
)
|
||||
]
|
||||
db.add_all(initial_courses)
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
# Deprecated standalone UI - Serving only API
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return {"message": "Learning Hub API is running. Use the main dashboard to access the Kanban board."}
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||
@@ -1,12 +0,0 @@
|
||||
from sqlalchemy import Column, Integer, String
|
||||
from .database import Base
|
||||
|
||||
class Course(Base):
|
||||
__tablename__ = "courses"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
title = Column(String)
|
||||
description = Column(String, nullable=True)
|
||||
main_link = Column(String)
|
||||
last_link = Column(String, nullable=True)
|
||||
status = Column(String, default="Planning") # WIP, Planning, Archive
|
||||
@@ -1,32 +0,0 @@
|
||||
services:
|
||||
learning-hub:
|
||||
image: python:3.11-slim
|
||||
container_name: learning-hub
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- .:/app
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /home:/home:ro
|
||||
command: >
|
||||
sh -c "pip install fastapi uvicorn sqlalchemy psutil docker && python -m app.main"
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
# Public (HTTPS)
|
||||
- "traefik.http.routers.learning.rule=Host(`learning.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.learning.entrypoints=websecure"
|
||||
- "traefik.http.routers.learning.tls=true"
|
||||
- "traefik.http.routers.learning.service=learning-svc"
|
||||
|
||||
# Public (Redirect)
|
||||
- "traefik.http.routers.learning-red.rule=Host(`learning.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.learning-red.entrypoints=web"
|
||||
- "traefik.http.routers.learning-red.middlewares=https-redirect@docker"
|
||||
|
||||
- "traefik.http.services.learning-svc.loadbalancer.server.port=8000"
|
||||
|
||||
|
||||
networks:
|
||||
proxy-net:
|
||||
external: true
|
||||
@@ -1,23 +0,0 @@
|
||||
services:
|
||||
mermaid:
|
||||
image: ghcr.io/mermaid-js/mermaid-live-editor:latest
|
||||
container_name: mermaid-live-editor
|
||||
restart: always
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.mermaid.rule=Host(`mermaid.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.mermaid.entrypoints=websecure"
|
||||
- "traefik.http.routers.mermaid.tls=true"
|
||||
- "traefik.http.routers.mermaid.service=mermaid-svc"
|
||||
- "traefik.http.routers.mermaid-red.rule=Host(`mermaid.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.mermaid-red.entrypoints=web"
|
||||
- "traefik.http.routers.mermaid-red.middlewares=https-redirect@docker"
|
||||
|
||||
- "traefik.http.services.mermaid-svc.loadbalancer.server.port=8080"
|
||||
|
||||
|
||||
networks:
|
||||
proxy-net:
|
||||
external: true
|
||||
@@ -1,56 +0,0 @@
|
||||
services:
|
||||
ollama:
|
||||
image: ollama/ollama:latest
|
||||
deploy:
|
||||
replicas: 3
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
environment:
|
||||
- OLLAMA_HOST=0.0.0.0
|
||||
- OLLAMA_ACCELERATE_SYSTEM=1
|
||||
devices:
|
||||
- /dev/dri:/dev/dri
|
||||
volumes:
|
||||
- ollama_data:/root/.ollama:rw
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
# Router 1: API/Automation (Token-based)
|
||||
- "traefik.http.routers.ollama-api.rule=Host(`ollama.arch-services.mywire.org`) && Header(`X-Ollama-Key`, `sk-ollama-hardened-hub-2026`)"
|
||||
- "traefik.http.routers.ollama-api.entrypoints=websecure"
|
||||
- "traefik.http.routers.ollama-api.tls=true"
|
||||
- "traefik.http.routers.ollama-api.priority=100"
|
||||
- "traefik.http.routers.ollama-api.service=ollama-svc"
|
||||
|
||||
- "traefik.http.routers.ollama-api-red.rule=Host(`ollama.arch-services.mywire.org`) && Header(`X-Ollama-Key`, `sk-ollama-hardened-hub-2026`)"
|
||||
- "traefik.http.routers.ollama-api-red.entrypoints=web"
|
||||
- "traefik.http.routers.ollama-api-red.middlewares=https-redirect@docker"
|
||||
- "traefik.http.routers.ollama-api-red.priority=100"
|
||||
|
||||
# Router 2: Browser/Standard (Authelia Protected)
|
||||
- "traefik.http.routers.ollama-browser.rule=Host(`ollama.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.ollama-browser.entrypoints=websecure"
|
||||
- "traefik.http.routers.ollama-browser.tls=true"
|
||||
- "traefik.http.routers.ollama-browser.middlewares=authelia-auth@docker"
|
||||
- "traefik.http.routers.ollama-browser.priority=50"
|
||||
- "traefik.http.routers.ollama-browser.service=ollama-svc"
|
||||
|
||||
- "traefik.http.routers.ollama-browser-red.rule=Host(`ollama.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.ollama-browser-red.entrypoints=web"
|
||||
- "traefik.http.routers.ollama-browser-red.middlewares=https-redirect@docker"
|
||||
- "traefik.http.routers.ollama-browser-red.priority=50"
|
||||
|
||||
# Shared Service
|
||||
- "traefik.http.services.ollama-svc.loadbalancer.server.port=11434"
|
||||
|
||||
- "traefik.http.services.ollama-svc.loadbalancer.healthcheck.path=/api/tags"
|
||||
- "traefik.http.services.ollama-svc.loadbalancer.healthcheck.interval=10s"
|
||||
|
||||
|
||||
volumes:
|
||||
ollama_data:
|
||||
|
||||
networks:
|
||||
proxy-net:
|
||||
external: true
|
||||
@@ -46,7 +46,7 @@
|
||||
<div class="grid">
|
||||
<article class="card">
|
||||
<h4>🌐 Edge Gateway</h4>
|
||||
<p><strong>Traefik v3:</strong> Reverse Proxy & SSL (DNS-01 Challenges). Routes subdomains like <code>gitea.*</code>.</p>
|
||||
<p><strong>Traefik v3:</strong> Reverse Proxy & SSL (DNS-01 Challenges). Routes subdomains for all core and user-deployed services.</p>
|
||||
</article>
|
||||
<article class="card">
|
||||
<h4>🔐 Identity</h4>
|
||||
@@ -68,10 +68,10 @@
|
||||
<p>Consumer-facing services isolated from the core infrastructure.</p>
|
||||
<div class="layer-box">
|
||||
<ul>
|
||||
<li><strong>Service Discovery:</strong> <em>Homepage</em> dashboard provides a unified portal.</li>
|
||||
<li><strong>Learning Hub:</strong> A dedicated Kanban board (FastAPI + SQLite) for tracking courses and milestones.</li>
|
||||
<li><strong>SSO Integration:</strong> Critical apps (Gitea, Dozzle, Learning) utilize Authelia Forward Auth.</li>
|
||||
<li><strong>Isolation:</strong> Services have no direct host access and communicate over internal networks.</li>
|
||||
<li><strong>Service Discovery:</strong> <em>Homepage</em> dashboard serves as a unified entry portal.</li>
|
||||
<li><strong>SSO Protection:</strong> Critical administration pages and external services utilize Authelia Forward Auth.</li>
|
||||
<li><strong>Decoupled Lifecycles:</strong> User applications run in separate containers outside this repository, keeping the core system clean and stable.</li>
|
||||
<li><strong>Isolation:</strong> Services have no direct host access and communicate strictly over dynamic internal networks.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
+12
-15
@@ -11,14 +11,14 @@
|
||||
<main>
|
||||
<header>
|
||||
<h1>🗺️ Project Roadmap</h1>
|
||||
<p>Current system maturity and future priorities.</p>
|
||||
<p>Current system maturity and future priorities for the core infrastructure.</p>
|
||||
</header>
|
||||
|
||||
<nav>
|
||||
<h4>Phases</h4>
|
||||
<ul>
|
||||
<li><a href="#phase1">Phase 1: Core</a></li>
|
||||
<li><a href="#phase2">Phase 2: Apps</a></li>
|
||||
<li><a href="#phase2">Phase 2: Observability</a></li>
|
||||
<li><a href="#phase3">Phase 3: Automation</a></li>
|
||||
<li><a href="#phase4">Phase 4: Optimization</a></li>
|
||||
</ul>
|
||||
@@ -30,22 +30,19 @@
|
||||
<ul class="status-list">
|
||||
<li class="status-item"><span>[x]</span> <strong>Dynamic DNS:</strong> Reliable IP synchronization via systemd-based Dynu updater.</li>
|
||||
<li class="status-item"><span>[x]</span> <strong>Edge Routing:</strong> Traefik v3 with Let's Encrypt (DNS-01) automation.</li>
|
||||
<li class="status-item"><span>[x]</span> <strong>Layered Architecture:</strong> Clear separation between <code>infra/</code> and <code>apps/</code>.</li>
|
||||
<li class="status-item"><span>[x]</span> <strong>Layered Architecture:</strong> Separation of control plane and decoupled data plane folders.</li>
|
||||
<li class="status-item"><span>[x]</span> <strong>Identity & SSO:</strong> Authelia integration with 2FA/OIDC support.</li>
|
||||
<li class="status-item"><span>[x]</span> <strong>Security Hardening:</strong> Docker socket proxy and internal network segmentation.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section id="phase2">
|
||||
<h2>🏗️ Phase 2: Application Ecosystem & Observability</h2>
|
||||
<p><span class="badge badge-warning">IN PROGRESS</span> Expand utility and improve monitoring.</p>
|
||||
<h2>🏗️ Phase 2: Observability & Portal Layer</h2>
|
||||
<p><span class="badge badge-warning">IN PROGRESS</span> Expand utility and improve system monitoring.</p>
|
||||
<ul class="status-list">
|
||||
<li class="status-item"><span>[x]</span> <strong>Service Discovery:</strong> 'Homepage' dashboard integration.</li>
|
||||
<li class="status-item"><span>[x]</span> <strong>Visual Tools:</strong> Excalidraw and Mermaid deployment.</li>
|
||||
<li class="status-item"><span>[x]</span> <strong>Development:</strong> Self-hosted Gitea with SSO.</li>
|
||||
<li class="status-item"><span>[x]</span> <strong>AI/ML:</strong> Scalable Ollama cluster with model management.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Unified Health:</strong> Integrate Traefik/Docker health checks into Homepage.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Resource Monitoring:</strong> Add lightweight metrics (Glances/Netdata).</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Unified Health:</strong> Integrate Traefik/Docker health checks into Homepage via socket-proxy.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Resource Monitoring:</strong> Add lightweight system metrics (Glances/Netdata) to the portal.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
@@ -53,9 +50,9 @@
|
||||
<h2>🚀 Phase 3: Automation & Resilience</h2>
|
||||
<ul class="status-list">
|
||||
<li class="status-item"><span>[x]</span> <strong>Automated Updates:</strong> Watchtower and Diun for image lifecycle.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Backup Strategy:</strong> Automated, encrypted off-site backups for persistent volumes.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Infrastructure as Code:</strong> Further modularization of deployment scripts.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Alerting:</strong> Push notifications (Gotify/Ntfy) for system failures.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Backup Strategy:</strong> Automated, encrypted off-site backups for persistent core volumes.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Infrastructure as Code:</strong> NixOS declarative system module mapping.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Alerting:</strong> Push notifications (Gotify/Ntfy) for core system failures.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
@@ -63,8 +60,8 @@
|
||||
<h2>🌐 Phase 4: Network Optimization</h2>
|
||||
<ul class="status-list">
|
||||
<li class="status-item"><span>[ ]</span> <strong>Local DNS:</strong> Ad-blocking DNS (Pi-hole/AdGuard Home) for LAN.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Hairpin NAT:</strong> Validation and optimization for internal traffic.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>VPN Integration:</strong> WireGuard-based remote access.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>Hairpin NAT:</strong> Validation and optimization for internal LAN routing.</li>
|
||||
<li class="status-item"><span>[ ]</span> <strong>VPN Integration:</strong> WireGuard-based secure remote access.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
||||
+102
-36
@@ -11,7 +11,7 @@
|
||||
<main>
|
||||
<header>
|
||||
<h1>🖱️ Usability & Operational Notes</h1>
|
||||
<p>A guide for interacting with the Hardened Hub once deployed.</p>
|
||||
<p>A guide for interacting with the Hardened Hub and exposing external services.</p>
|
||||
</header>
|
||||
|
||||
<nav>
|
||||
@@ -20,19 +20,18 @@
|
||||
<li><a href="#auth">Authentication</a></li>
|
||||
<li><a href="#nav">Navigation</a></li>
|
||||
<li><a href="#mgmt">Management</a></li>
|
||||
<li><a href="#add">Adding Apps</a></li>
|
||||
<li><a href="#ollama">Ollama API</a></li>
|
||||
<li><a href="#add">Exposing New Services</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<section id="auth">
|
||||
<h2>🔑 Authentication (SSO)</h2>
|
||||
<p>Most services are protected by <strong>Authelia</strong>.</p>
|
||||
<p>Critical core services and protected user applications are shielded by <strong>Authelia</strong>.</p>
|
||||
<ol>
|
||||
<li>Access a protected service (e.g., <code>gitea.*</code>).</li>
|
||||
<li>You will be redirected to the Auth Portal (<code>auth.*</code>).</li>
|
||||
<li>Access a protected URL (e.g., <code>https://portainer.arch-services.mywire.org</code>).</li>
|
||||
<li>You will be redirected to the Auth Portal (<code>https://auth.arch-services.mywire.org</code>).</li>
|
||||
<li>Log in with your credentials.</li>
|
||||
<li>Once authenticated, you have global access to all SSO-enabled services.</li>
|
||||
<li>Once authenticated, you obtain global session access to all SSO-protected services.</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
@@ -45,47 +44,114 @@
|
||||
</ul>
|
||||
<div class="layer-box">
|
||||
<h4>Local Access (Fast Lane)</h4>
|
||||
<p>To avoid traversing the public internet when you are on the same network as the server, we use a <strong>Public Domain + Local IP</strong> strategy (see <a href="adr-001-remove-localhost-routers.md">ADR 001</a>).</p>
|
||||
<p>Add the following to your machine's <code>/etc/hosts</code> file:</p>
|
||||
<pre><code>127.0.0.1 traefik.arch-services.mywire.org auth.arch-services.mywire.org jellyfin.arch-services.mywire.org gitea.arch-services.mywire.org excalidraw.arch-services.mywire.org homepage.arch-services.mywire.org mermaid.arch-services.mywire.org ollama.arch-services.mywire.org learning.arch-services.mywire.org logs.arch-services.mywire.org portainer.arch-services.mywire.org arch-services.mywire.org</code></pre>
|
||||
<p><em>Note: This ensures valid SSL and working SSO cookies for local sessions.</em></p>
|
||||
<p>To bypass traversing the public internet when you are on the same local network as the server, we use a **Public Domain + Local IP** mapping strategy (see <a href="adr-001-remove-localhost-routers.md">ADR 001</a>).</p>
|
||||
<p>Add the following mapping to your client machine's <code>/etc/hosts</code> file (using your server's local IP, e.g., <code>192.168.1.100</code> or <code>127.0.0.1</code> if testing locally):</p>
|
||||
<pre><code>127.0.0.1 arch-services.mywire.org traefik.arch-services.mywire.org auth.arch-services.mywire.org logs.arch-services.mywire.org portainer.arch-services.mywire.org [your-app-subdomain].arch-services.mywire.org</code></pre>
|
||||
<p><em>Note: This guarantees valid SSL handshakes and working SSO cookies for local LAN sessions.</em></p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<section id="mgmt">
|
||||
<h2>🛠️ Service Management</h2>
|
||||
<h3>Deployment Scripts</h3>
|
||||
<pre><code># Start everything
|
||||
<h2>🛠️ Core Infrastructure Management</h2>
|
||||
<p>Deploy the control plane stacks and homepage directly using the host scripts:</p>
|
||||
<pre><code># Start the Control Plane + Homepage Portal
|
||||
./up.sh
|
||||
|
||||
# Start ONLY the Control Plane
|
||||
./up.sh --infra-only
|
||||
|
||||
# Stop all services
|
||||
# Stop all Core services
|
||||
./down.sh</code></pre>
|
||||
</section>
|
||||
|
||||
<section id="add">
|
||||
<h2>➕ Adding a New Application</h2>
|
||||
<ol>
|
||||
<li>Create <code>apps/your-app/docker-compose.yml</code>.</li>
|
||||
<li>Connect to <code>proxy-net</code>.</li>
|
||||
<li>Add Traefik labels for routing and Authelia protection.</li>
|
||||
<li>Update <code>apps/homepage/config/services.yaml</code>.</li>
|
||||
</ol>
|
||||
</section>
|
||||
<h2>➕ Exposing a New Service (Decoupled Model)</h2>
|
||||
<p>User applications are fully decoupled from the core repository and managed in their own directories (e.g., <code>/home/kiskaadee/deployments/my-app</code>). We use Traefik labels to expose them under the <code>*.arch-services.mywire.org</code> wildcard domain.</p>
|
||||
|
||||
<p>Depending on your security and access needs, you can configure your stack for one of two scenarios:</p>
|
||||
|
||||
<section id="ollama">
|
||||
<h2>🤖 Ollama API & Automation</h2>
|
||||
<p>Uses a hybrid security model for browser and CLI access.</p>
|
||||
<div class="layer-box">
|
||||
<h4>API Key / Trusted Payload</h4>
|
||||
<p><strong>Header:</strong> <code>X-Ollama-Key: sk-ollama-hardened-hub-2026</code></p>
|
||||
<pre><code>curl https://ollama.arch-services.mywire.org/api/generate \
|
||||
-H "X-Ollama-Key: sk-ollama-hardened-hub-2026" \
|
||||
-d '{"model": "llama3", "prompt": "hi"}'</code></pre>
|
||||
<div class="grid">
|
||||
<article class="card">
|
||||
<h4>🔓 Scenario A: Public / Direct Access</h4>
|
||||
<p>Use this for applications that have their own built-in authentication (e.g., Jellyfin, Gitea) or public-facing projects (e.g., public web demos, portfolios).</p>
|
||||
</article>
|
||||
<article class="card">
|
||||
<h4>🔒 Scenario B: SSO-Protected</h4>
|
||||
<p>Use this for administrative tools, private databases, or custom internal apps that do not have native authentication and need to be secured behind Authelia.</p>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<h3>Scenario A: Public / Direct Access (Bypassing Authelia)</h3>
|
||||
<p>This configuration exposes your service directly to the internet. Authelia is bypassed, allowing anyone (or the app's own login manager) to handle access.</p>
|
||||
|
||||
<pre><code class="language-yaml">services:
|
||||
my-public-app:
|
||||
image: my-app-image:latest
|
||||
container_name: my-public-app
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
|
||||
# 1. Main HTTPS Route Rule
|
||||
- "traefik.http.routers.public-app.rule=Host(`demo.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.public-app.entrypoints=websecure"
|
||||
- "traefik.http.routers.public-app.tls=true"
|
||||
- "traefik.http.routers.public-app.service=public-app-svc"
|
||||
|
||||
# 2. HTTP to HTTPS Redirection Route
|
||||
- "traefik.http.routers.public-app-red.rule=Host(`demo.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.public-app-red.entrypoints=web"
|
||||
- "traefik.http.routers.public-app-red.middlewares=https-redirect@docker"
|
||||
|
||||
# 3. Port Mapping (Target port inside the container)
|
||||
- "traefik.http.services.public-app-svc.loadbalancer.server.port=8080"
|
||||
|
||||
networks:
|
||||
proxy-net:
|
||||
external: true</code></pre>
|
||||
|
||||
<h3>Scenario B: SSO-Protected (Secured by Authelia)</h3>
|
||||
<p>This configuration intercepts all incoming requests and redirects unauthenticated users to the Authelia portal first. Once logged in, users are returned to the service.</p>
|
||||
|
||||
<pre><code class="language-yaml">services:
|
||||
my-secure-app:
|
||||
image: my-app-image:latest
|
||||
container_name: my-secure-app
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
|
||||
# 1. Main HTTPS Route Rule
|
||||
- "traefik.http.routers.secure-app.rule=Host(`admin.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.secure-app.entrypoints=websecure"
|
||||
- "traefik.http.routers.secure-app.tls=true"
|
||||
- "traefik.http.routers.secure-app.service=secure-app-svc"
|
||||
|
||||
# 2. SSO Authentication Middleware (Crucial Line)
|
||||
- "traefik.http.routers.secure-app.middlewares=authelia-auth@docker"
|
||||
|
||||
# 3. HTTP to HTTPS Redirection Route
|
||||
- "traefik.http.routers.secure-app-red.rule=Host(`admin.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.secure-app-red.entrypoints=web"
|
||||
- "traefik.http.routers.secure-app-red.middlewares=https-redirect@docker"
|
||||
|
||||
# 4. Port Mapping (Target port inside the container)
|
||||
- "traefik.http.services.secure-app-svc.loadbalancer.server.port=3000"
|
||||
|
||||
networks:
|
||||
proxy-net:
|
||||
external: true</code></pre>
|
||||
|
||||
<h3>3. Register in Homepage Dashboard</h3>
|
||||
<p>To list your new service on the central dashboard, update <code>homepage/config/services.yaml</code> inside the core repository:</p>
|
||||
<pre><code class="language-yaml">- User Applications:
|
||||
- My Application:
|
||||
icon: custom-app-icon
|
||||
href: https://my-app.arch-services.mywire.org
|
||||
description: Custom exposed app description
|
||||
server: my-docker
|
||||
container: my-app # Must match container_name exactly</code></pre>
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
|
||||
@@ -2,23 +2,28 @@
|
||||
|
||||
stop_stack() {
|
||||
local stack_path=$1
|
||||
shift
|
||||
local env_flags=()
|
||||
for env_file in "$@"; do
|
||||
if [ -f "$env_file" ]; then
|
||||
env_flags+=("--env-file" "$env_file")
|
||||
fi
|
||||
done
|
||||
if [ -f "$stack_path/docker-compose.yml" ]; then
|
||||
echo "Stopping stack: $stack_path..."
|
||||
docker compose -f "$stack_path/docker-compose.yml" down
|
||||
docker compose -f "$stack_path/docker-compose.yml" "${env_flags[@]}" down
|
||||
fi
|
||||
}
|
||||
|
||||
echo "=== Stopping Application Layer ==="
|
||||
for app_dir in apps/*/; do
|
||||
stop_stack "${app_dir%/}"
|
||||
done
|
||||
echo "=== Stopping Portal Layer ==="
|
||||
stop_stack "homepage" "infra/core/.env"
|
||||
|
||||
echo "=== Stopping Infrastructure Layer ==="
|
||||
stop_stack "infra/dozzle"
|
||||
stop_stack "infra/diun"
|
||||
stop_stack "infra/watchtower"
|
||||
stop_stack "infra/portainer"
|
||||
stop_stack "infra/authelia"
|
||||
stop_stack "infra/core"
|
||||
stop_stack "infra/authelia" "infra/core/.env" "infra/authelia/.env"
|
||||
stop_stack "infra/core" "infra/core/.env"
|
||||
|
||||
echo "All services stopped."
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,31 +1,4 @@
|
||||
---
|
||||
# Infrastructure Group
|
||||
- Infrastructure:
|
||||
- Traefik:
|
||||
icon: traefik.png
|
||||
href: https://traefik.arch-services.mywire.org
|
||||
description: Edge Router & SSL
|
||||
server: my-docker
|
||||
container: traefik
|
||||
- Authelia:
|
||||
icon: authelia.png
|
||||
href: https://auth.arch-services.mywire.org
|
||||
description: Identity & SSO
|
||||
server: my-docker
|
||||
container: authelia
|
||||
# - Portainer:
|
||||
# icon: portainer.png
|
||||
# href: https://portainer.arch-services.mywire.org
|
||||
# description: Container Management
|
||||
# server: my-docker
|
||||
# container: portainer
|
||||
# - Dozzle:
|
||||
# icon: dozzle.png
|
||||
# href: https://logs.arch-services.mywire.org
|
||||
# description: Log Viewer
|
||||
# server: my-docker
|
||||
# container: dozzle
|
||||
|
||||
# Applications Group
|
||||
- Applications:
|
||||
# - Gitea:
|
||||
File renamed without changes.
File renamed without changes.
@@ -7,20 +7,20 @@ services:
|
||||
- ./config:/app/config
|
||||
- /home:/home:ro
|
||||
environment:
|
||||
- HOMEPAGE_ALLOWED_HOSTS=arch-services.mywire.org
|
||||
- HOMEPAGE_ALLOWED_HOSTS=${DOMAIN}
|
||||
networks:
|
||||
- proxy-net
|
||||
- socket-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
# Public (HTTPS)
|
||||
- "traefik.http.routers.homepage.rule=Host(`arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.homepage.rule=Host(`${DOMAIN}`)"
|
||||
- "traefik.http.routers.homepage.entrypoints=websecure"
|
||||
- "traefik.http.routers.homepage.tls=true"
|
||||
- "traefik.http.routers.homepage.service=homepage-svc"
|
||||
|
||||
# Public (Redirect)
|
||||
- "traefik.http.routers.homepage-red.rule=Host(`arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.homepage-red.rule=Host(`${DOMAIN}`)"
|
||||
- "traefik.http.routers.homepage-red.entrypoints=web"
|
||||
- "traefik.http.routers.homepage-red.middlewares=https-redirect@docker"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Authelia Configuration Environment Variables
|
||||
# Generate secure random secrets (e.g., openssl rand -hex 32) for these fields
|
||||
|
||||
AUTHELIA_SESSION_SECRET=
|
||||
AUTHELIA_STORAGE_ENCRYPTION_KEY=
|
||||
AUTHELIA_IDENTITY_VALIDATION_RESET_PASSWORD_JWT_SECRET=
|
||||
@@ -14,9 +14,9 @@ authentication_backend:
|
||||
access_control:
|
||||
default_policy: deny
|
||||
rules:
|
||||
- domain: "auth.arch-services.mywire.org"
|
||||
- domain: "auth.{{ env \"DOMAIN\" }}"
|
||||
policy: bypass
|
||||
- domain: "*.arch-services.mywire.org"
|
||||
- domain: "*.{{ env \"DOMAIN\" }}"
|
||||
policy: one_factor
|
||||
|
||||
session:
|
||||
@@ -26,8 +26,8 @@ session:
|
||||
inactivity: 300
|
||||
remember_me: 1M
|
||||
cookies:
|
||||
- domain: arch-services.mywire.org
|
||||
authelia_url: https://auth.arch-services.mywire.org
|
||||
- domain: "{{ env \"DOMAIN\" }}"
|
||||
authelia_url: "https://auth.{{ env \"DOMAIN\" }}"
|
||||
|
||||
identity_validation:
|
||||
reset_password:
|
||||
|
||||
@@ -5,17 +5,19 @@ services:
|
||||
restart: always
|
||||
volumes:
|
||||
- ./config:/config
|
||||
environment:
|
||||
- DOMAIN=${DOMAIN}
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
# Public (HTTPS)
|
||||
- "traefik.http.routers.authelia.rule=Host(`auth.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.authelia.rule=Host(`auth.${DOMAIN}`)"
|
||||
- "traefik.http.routers.authelia.entrypoints=websecure"
|
||||
- "traefik.http.routers.authelia.tls=true"
|
||||
|
||||
# Public (Redirect)
|
||||
- "traefik.http.routers.authelia-red.rule=Host(`auth.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.authelia-red.rule=Host(`auth.${DOMAIN}`)"
|
||||
- "traefik.http.routers.authelia-red.entrypoints=web"
|
||||
- "traefik.http.routers.authelia-red.middlewares=https-redirect@docker"
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ services:
|
||||
- "--entrypoints.websecure.address=:443"
|
||||
# Global TLS defaults for websecure
|
||||
- "--entrypoints.websecure.http.tls.certResolver=myresolver"
|
||||
- "--entrypoints.websecure.http.tls.domains[0].main=arch-services.mywire.org"
|
||||
- "--entrypoints.websecure.http.tls.domains[0].sans=*.arch-services.mywire.org"
|
||||
- "--entrypoints.websecure.http.tls.domains[0].main=${DOMAIN}"
|
||||
- "--entrypoints.websecure.http.tls.domains[0].sans=*.${DOMAIN}"
|
||||
# SSL Setup
|
||||
- "--certificatesresolvers.myresolver.acme.dnschallenge=true"
|
||||
- "--certificatesresolvers.myresolver.acme.dnschallenge.provider=dynu"
|
||||
@@ -74,19 +74,19 @@ services:
|
||||
- "traefik.http.middlewares.https-redirect.redirectscheme.permanent=true"
|
||||
|
||||
# Middleware: Authelia Guard
|
||||
- "traefik.http.middlewares.authelia-auth.forwardauth.address=http://authelia:9091/api/verify?rd=https://auth.arch-services.mywire.org/"
|
||||
- "traefik.http.middlewares.authelia-auth.forwardauth.address=http://authelia:9091/api/verify?rd=https://auth.${DOMAIN}/"
|
||||
- "traefik.http.middlewares.authelia-auth.forwardauth.trustForwardHeader=true"
|
||||
- "traefik.http.middlewares.authelia-auth.forwardauth.authResponseHeaders=Remote-User,Remote-Groups,Remote-Name,Remote-Email"
|
||||
|
||||
# Dashboard - Public (HTTPS)
|
||||
- "traefik.http.routers.traefik-dash.rule=Host(`traefik.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.traefik-dash.rule=Host(`traefik.${DOMAIN}`)"
|
||||
- "traefik.http.routers.traefik-dash.entrypoints=websecure"
|
||||
- "traefik.http.routers.traefik-dash.tls=true"
|
||||
- "traefik.http.routers.traefik-dash.service=api@internal"
|
||||
- "traefik.http.routers.traefik-dash.middlewares=authelia-auth@docker"
|
||||
|
||||
# Dashboard - Public (Redirect)
|
||||
- "traefik.http.routers.traefik-dash-red.rule=Host(`traefik.arch-services.mywire.org`)"
|
||||
- "traefik.http.routers.traefik-dash-red.rule=Host(`traefik.${DOMAIN}`)"
|
||||
- "traefik.http.routers.traefik-dash-red.entrypoints=web"
|
||||
- "traefik.http.routers.traefik-dash-red.middlewares=https-redirect@docker"
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.dynu-ddns;
|
||||
in {
|
||||
options.services.dynu-ddns = {
|
||||
enable = mkEnableOption "Dynu DDNS IP monitor and updater service";
|
||||
|
||||
scriptPath = mkOption {
|
||||
type = types.path;
|
||||
default = ../../scripts/dynu/ip-monitor.sh;
|
||||
description = "Path to the ip-monitor.sh script.";
|
||||
};
|
||||
|
||||
environmentFile = mkOption {
|
||||
type = types.path;
|
||||
default = /etc/conf.d/dynu-environment;
|
||||
description = ''
|
||||
Path to the environment file containing the Dynu credentials.
|
||||
The file must define:
|
||||
DYNU_HOST=your-domain.mywire.org
|
||||
DYNU_USER=your-dynu-username
|
||||
DYNU_PASSWORD=your-dynu-password
|
||||
'';
|
||||
};
|
||||
|
||||
interval = mkOption {
|
||||
type = types.str;
|
||||
default = "5min";
|
||||
description = "Interval at which to run the updater service.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.dynu-ddns = {
|
||||
description = "Dynu IP Monitor & Updater";
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
path = with pkgs; [
|
||||
bash
|
||||
curl
|
||||
coreutils
|
||||
dnsutils # provides dig
|
||||
util-linux # provides flock
|
||||
gawk
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "root";
|
||||
Group = "root";
|
||||
StateDirectory = "dynu";
|
||||
EnvironmentFile = cfg.environmentFile;
|
||||
ExecStart = "${pkgs.bash}/bin/bash ${cfg.scriptPath}";
|
||||
TimeoutSec = 30;
|
||||
|
||||
# Hardening
|
||||
NoNewPrivileges = true;
|
||||
PrivateTmp = true;
|
||||
ProtectSystem = "strict";
|
||||
ProtectHome = true;
|
||||
ReadWritePaths = "/var/lib/dynu";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.timers.dynu-ddns = {
|
||||
description = "Run Dynu updater periodically";
|
||||
timerConfig = {
|
||||
OnBootSec = "30s";
|
||||
OnUnitActiveSec = cfg.interval;
|
||||
AccuracySec = "10s";
|
||||
Persistent = true;
|
||||
};
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -5,45 +5,43 @@ docker network inspect proxy-net >/dev/null 2>&1 || docker network create proxy-
|
||||
docker network inspect socket-net >/dev/null 2>&1 || docker network create socket-net
|
||||
|
||||
# SSL Permissions (Moved to infra/core)
|
||||
sudo mkdir -p infra/core/letsencrypt
|
||||
sudo touch infra/core/letsencrypt/acme.json
|
||||
sudo chmod 600 infra/core/letsencrypt/acme.json
|
||||
sudo chown root:root infra/core/letsencrypt/acme.json
|
||||
if [ ! -f infra/core/letsencrypt/acme.json ]; then
|
||||
echo "Initializing letsencrypt/acme.json..."
|
||||
sudo mkdir -p infra/core/letsencrypt
|
||||
sudo touch infra/core/letsencrypt/acme.json
|
||||
sudo chmod 600 infra/core/letsencrypt/acme.json
|
||||
sudo chown root:root infra/core/letsencrypt/acme.json
|
||||
fi
|
||||
|
||||
# --- 2. HELPER FUNCTIONS ---
|
||||
start_stack() {
|
||||
local stack_path=$1
|
||||
shift
|
||||
local env_flags=()
|
||||
for env_file in "$@"; do
|
||||
if [ -f "$env_file" ]; then
|
||||
env_flags+=("--env-file" "$env_file")
|
||||
fi
|
||||
done
|
||||
if [ -f "$stack_path/docker-compose.yml" ]; then
|
||||
echo "Starting stack: $stack_path..."
|
||||
docker compose -f "$stack_path/docker-compose.yml" up -d
|
||||
docker compose -f "$stack_path/docker-compose.yml" "${env_flags[@]}" up -d
|
||||
else
|
||||
echo "Warning: No docker-compose.yml found in $stack_path"
|
||||
fi
|
||||
}
|
||||
|
||||
# --- 3. INFRASTRUCTURE LAYER (Control Plane) ---
|
||||
echo "=== Deploying Infrastructure Layer ==="
|
||||
start_stack "infra/core"
|
||||
start_stack "infra/authelia"
|
||||
# --- 3. DEPLOY CONTROL PLANE & PORTAL ---
|
||||
echo "=== Deploying Control Plane ==="
|
||||
start_stack "infra/core" "infra/core/.env"
|
||||
start_stack "infra/authelia" "infra/core/.env" "infra/authelia/.env"
|
||||
start_stack "infra/portainer"
|
||||
start_stack "infra/watchtower"
|
||||
start_stack "infra/diun"
|
||||
start_stack "infra/dozzle"
|
||||
echo "Infrastructure is ready."
|
||||
echo ""
|
||||
|
||||
# --- 4. APPLICATION LAYER (Data Plane) ---
|
||||
if [[ "$1" == "--infra-only" ]]; then
|
||||
echo "Skipping Application Layer as requested."
|
||||
else
|
||||
echo "=== Deploying Application Layer ==="
|
||||
# Dynamically start all apps in the apps/ directory
|
||||
for app_dir in apps/*/; do
|
||||
start_stack "${app_dir%/}"
|
||||
done
|
||||
echo "Applications are ready."
|
||||
fi
|
||||
echo "=== Deploying Homepage Portal ==="
|
||||
start_stack "homepage" "infra/core/.env"
|
||||
|
||||
echo ""
|
||||
echo "Hardened Private Cloud Deployment Complete."
|
||||
echo "Usage: ./up.sh [--infra-only]"
|
||||
Reference in new issue
Block a user