Richte das Tsumugu-Deployment nach dem Kansho-Mechanismus ein.
Der Pi-Runner veröffentlicht develop nach tsumugu-dev und main nach tsumugu. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
544c44ca04
17 files changed
+662
No files matched your search
@@ -0,0 +1,26 @@
|
|||||||
|
# Compose-Secrets auf dem Pi. Kopieren nach:
|
||||||
|
# /home/lars/docker/tsumugu/.env
|
||||||
|
# /home/lars/docker/tsumugu-dev/.env
|
||||||
|
# Die gefüllte Datei nie committen.
|
||||||
|
# Fehlt die Datei beim ersten Lauf, legt der jeweilige Deploy-Workflow sie an.
|
||||||
|
# Das Prod-Passwort wird dabei nur auf dem Pi erzeugt und nicht geloggt.
|
||||||
|
|
||||||
|
# ─── DEV (docker-compose.dev-env.yml) ────────────────────────────────────────
|
||||||
|
# DB_NAME=tsumugu_dev
|
||||||
|
# DB_USER=tsumugu_dev
|
||||||
|
# DB_PASSWORD=dev_password_change_me
|
||||||
|
# APP_URL=https://dev.tsumugu.jinkendo.de
|
||||||
|
# ALLOWED_ORIGINS=https://dev.tsumugu.jinkendo.de,http://192.168.2.49:3095
|
||||||
|
# TSUMUGU_ENV=development
|
||||||
|
# TSUMUGU_FRONTEND_PORT=3095
|
||||||
|
# TSUMUGU_BACKEND_PORT=8095
|
||||||
|
|
||||||
|
# ─── PROD (docker-compose.yml) ───────────────────────────────────────────────
|
||||||
|
DB_NAME=tsumugu
|
||||||
|
DB_USER=tsumugu
|
||||||
|
DB_PASSWORD=CHANGE_ME_SECURE_PASSWORD
|
||||||
|
APP_URL=https://tsumugu.jinkendo.de
|
||||||
|
ALLOWED_ORIGINS=https://tsumugu.jinkendo.de
|
||||||
|
TSUMUGU_ENV=production
|
||||||
|
TSUMUGU_FRONTEND_PORT=3007
|
||||||
|
TSUMUGU_BACKEND_PORT=8006
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
name: Deploy Development
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [develop]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Deploy Tsumugu to development
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
echo "=== Deploying Tsumugu to DEVELOPMENT ==="
|
||||||
|
REPO="http://192.168.2.144:3000/Lars/tsumugu.git"
|
||||||
|
TARGET="/home/lars/docker/tsumugu-dev"
|
||||||
|
mkdir -p "$TARGET"
|
||||||
|
cd "$TARGET"
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
git clone -b develop "$REPO" .
|
||||||
|
else
|
||||||
|
git fetch origin develop
|
||||||
|
git checkout develop
|
||||||
|
git reset --hard origin/develop
|
||||||
|
fi
|
||||||
|
if [ ! -f .env ]; then
|
||||||
|
umask 077
|
||||||
|
printf '%s\n' \
|
||||||
|
'DB_NAME=tsumugu_dev' \
|
||||||
|
'DB_USER=tsumugu_dev' \
|
||||||
|
'DB_PASSWORD=dev_password_change_me' \
|
||||||
|
'APP_URL=https://dev.tsumugu.jinkendo.de' \
|
||||||
|
'ALLOWED_ORIGINS=https://dev.tsumugu.jinkendo.de,http://192.168.2.49:3095' \
|
||||||
|
'TSUMUGU_ENV=development' \
|
||||||
|
'TSUMUGU_FRONTEND_PORT=3095' \
|
||||||
|
'TSUMUGU_BACKEND_PORT=8095' \
|
||||||
|
> .env
|
||||||
|
echo "created $TARGET/.env from dev defaults"
|
||||||
|
umask 022
|
||||||
|
fi
|
||||||
|
docker compose -f docker-compose.dev-env.yml build --no-cache backend frontend
|
||||||
|
if ! docker compose -f docker-compose.dev-env.yml up -d --wait; then
|
||||||
|
echo "compose up --wait failed — backend logs:"
|
||||||
|
docker compose -f docker-compose.dev-env.yml logs backend --tail 150 || true
|
||||||
|
docker compose -f docker-compose.dev-env.yml ps || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! curl -sf http://localhost:8095/api/health; then
|
||||||
|
echo "DEV API not reachable — backend logs:"
|
||||||
|
docker compose -f docker-compose.dev-env.yml logs backend --tail 150 || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "DEV API /api/health OK"
|
||||||
|
curl -sf http://localhost:3095/api/health && echo "DEV frontend proxy /api/health OK"
|
||||||
|
echo "=== Tsumugu DEV deploy complete ==="
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
name: Deploy Production
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Deploy Tsumugu to production
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
echo "=== Deploying Tsumugu to PRODUCTION ==="
|
||||||
|
REPO="http://192.168.2.144:3000/Lars/tsumugu.git"
|
||||||
|
TARGET="/home/lars/docker/tsumugu"
|
||||||
|
mkdir -p "$TARGET"
|
||||||
|
cd "$TARGET"
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
git clone -b main "$REPO" .
|
||||||
|
else
|
||||||
|
git fetch origin main
|
||||||
|
git checkout main
|
||||||
|
git reset --hard origin/main
|
||||||
|
fi
|
||||||
|
if [ ! -f .env ]; then
|
||||||
|
umask 077
|
||||||
|
PASS="$(od -An -N24 -tx1 /dev/urandom | tr -d ' \n')"
|
||||||
|
printf '%s\n' \
|
||||||
|
'DB_NAME=tsumugu' \
|
||||||
|
'DB_USER=tsumugu' \
|
||||||
|
"DB_PASSWORD=${PASS}" \
|
||||||
|
'APP_URL=https://tsumugu.jinkendo.de' \
|
||||||
|
'ALLOWED_ORIGINS=https://tsumugu.jinkendo.de' \
|
||||||
|
'TSUMUGU_ENV=production' \
|
||||||
|
'TSUMUGU_FRONTEND_PORT=3007' \
|
||||||
|
'TSUMUGU_BACKEND_PORT=8006' \
|
||||||
|
> .env
|
||||||
|
unset PASS
|
||||||
|
echo "created $TARGET/.env (password not logged)"
|
||||||
|
umask 022
|
||||||
|
fi
|
||||||
|
docker compose build --no-cache backend frontend
|
||||||
|
if ! docker compose up -d --wait; then
|
||||||
|
echo "compose up --wait failed — backend logs:"
|
||||||
|
docker compose logs backend --tail 150 || true
|
||||||
|
docker compose ps || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! curl -sf http://localhost:8006/api/health; then
|
||||||
|
echo "PROD API not reachable — backend logs:"
|
||||||
|
docker compose logs backend --tail 150 || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "PROD API /api/health OK"
|
||||||
|
curl -sf http://localhost:3007/api/health && echo "PROD frontend proxy /api/health OK"
|
||||||
|
echo "=== Tsumugu PROD deploy complete ==="
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
# Dependencies
|
||||||
|
node_modules/
|
||||||
|
.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# Build / cache
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
.vite/
|
||||||
|
.turbo/
|
||||||
|
.cache/
|
||||||
|
coverage/
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Environment and secrets
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
*.pem
|
||||||
|
*.key
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
|
||||||
|
# OS / editor
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
*.swp
|
||||||
|
.idea/
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
# Python
|
||||||
|
.venv/
|
||||||
|
**/__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Local data
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
|
data/local/
|
||||||
|
*.db
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Tsumugu
|
||||||
|
|
||||||
|
Neues Projekt der Jinkendo-Familie, neben Mitai, Shinkan, Kairo und Kanshō.
|
||||||
|
|
||||||
|
Remote: `http://192.168.2.144:3000/Lars/tsumugu.git`
|
||||||
|
|
||||||
|
## Stand
|
||||||
|
|
||||||
|
Das Repository enthält das Deploy-Gerüst. Ein Push auf `develop` baut und startet Development, ein Merge von `develop` nach `main` die Produktion. Der Gitea-Runner auf dem Raspberry Pi (`192.168.2.49`) übernimmt Build und Deploy.
|
||||||
|
|
||||||
|
| | Development | Production |
|
||||||
|
|---|---|---|
|
||||||
|
| Branch | `develop` | `main` |
|
||||||
|
| Verzeichnis | `/home/lars/docker/tsumugu-dev` | `/home/lars/docker/tsumugu` |
|
||||||
|
| LAN | http://192.168.2.49:3095 | http://192.168.2.49:3007 |
|
||||||
|
| Öffentlich | https://dev.tsumugu.jinkendo.de | https://tsumugu.jinkendo.de |
|
||||||
|
|
||||||
|
Details, Ports und der Synology-Reverse-Proxy: `docs/DEPLOYMENT.md`.
|
||||||
|
|
||||||
|
Backend und Frontend sind bewusst schmal: `/api/health` prüft Postgres, das Frontend reicht `/api/` an das Backend durch. Die Anwendung selbst ist noch nicht begonnen.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY main.py .
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
"""Tsumugu — schmales Startgerüst, damit der Pi-Deploy einen Health-Check hat."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
import psycopg2
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
|
app = FastAPI(title="Tsumugu", docs_url=None, redoc_url=None)
|
||||||
|
|
||||||
|
|
||||||
|
def _database_status() -> str:
|
||||||
|
try:
|
||||||
|
connection = psycopg2.connect(
|
||||||
|
host=os.environ.get("DB_HOST", "postgres"),
|
||||||
|
port=os.environ.get("DB_PORT", "5432"),
|
||||||
|
dbname=os.environ.get("DB_NAME", "tsumugu"),
|
||||||
|
user=os.environ.get("DB_USER", "tsumugu"),
|
||||||
|
password=os.environ.get("DB_PASSWORD", ""),
|
||||||
|
connect_timeout=3,
|
||||||
|
)
|
||||||
|
connection.close()
|
||||||
|
except Exception:
|
||||||
|
return "error"
|
||||||
|
return "ok"
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/api/health")
|
||||||
|
def api_health():
|
||||||
|
database = _database_status()
|
||||||
|
status = "ok" if database == "ok" else "degraded"
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=200 if database == "ok" else 503,
|
||||||
|
content={
|
||||||
|
"status": status,
|
||||||
|
"app": "tsumugu",
|
||||||
|
"env": os.environ.get("TSUMUGU_ENV", "development"),
|
||||||
|
"db": database,
|
||||||
|
},
|
||||||
|
)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fastapi==0.115.6
|
||||||
|
uvicorn[standard]==0.34.0
|
||||||
|
psycopg2-binary==2.9.10
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# Server development stack: /home/lars/docker/tsumugu-dev
|
||||||
|
# No fixed container_name — Compose prefixes with the project name.
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: "${DB_NAME:-tsumugu_dev}"
|
||||||
|
POSTGRES_USER: "${DB_USER:-tsumugu_dev}"
|
||||||
|
POSTGRES_PASSWORD: "${DB_PASSWORD:-dev_password_change_me}"
|
||||||
|
volumes:
|
||||||
|
- dev-tsumugu-db-data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-tsumugu_dev} -d ${DB_NAME:-tsumugu_dev}"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- dev-tsumugu-network
|
||||||
|
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
environment:
|
||||||
|
TSUMUGU_ENV: "${TSUMUGU_ENV:-development}"
|
||||||
|
DB_HOST: postgres
|
||||||
|
DB_PORT: "5432"
|
||||||
|
DB_NAME: "${DB_NAME:-tsumugu_dev}"
|
||||||
|
DB_USER: "${DB_USER:-tsumugu_dev}"
|
||||||
|
DB_PASSWORD: "${DB_PASSWORD:-dev_password_change_me}"
|
||||||
|
APP_URL: "${APP_URL:-https://dev.tsumugu.jinkendo.de}"
|
||||||
|
ALLOWED_ORIGINS: "${ALLOWED_ORIGINS:-https://dev.tsumugu.jinkendo.de,http://192.168.2.49:3095,http://localhost:3095}"
|
||||||
|
ports:
|
||||||
|
- "${TSUMUGU_BACKEND_PORT:-8095}:8000"
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
[
|
||||||
|
"CMD",
|
||||||
|
"python",
|
||||||
|
"-c",
|
||||||
|
"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/api/health')",
|
||||||
|
]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 12
|
||||||
|
start_period: 20s
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- dev-tsumugu-network
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: ./frontend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "${TSUMUGU_FRONTEND_PORT:-3095}:80"
|
||||||
|
depends_on:
|
||||||
|
backend:
|
||||||
|
condition: service_healthy
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- dev-tsumugu-network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
dev-tsumugu-db-data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
dev-tsumugu-network:
|
||||||
|
driver: bridge
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# Production stack on the Raspberry Pi: /home/lars/docker/tsumugu
|
||||||
|
# Secrets live in the host .env next to this file, never in Git.
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
container_name: tsumugu-db-prod
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: "${DB_NAME:-tsumugu}"
|
||||||
|
POSTGRES_USER: "${DB_USER:-tsumugu}"
|
||||||
|
POSTGRES_PASSWORD: "${DB_PASSWORD:?set DB_PASSWORD in .env}"
|
||||||
|
volumes:
|
||||||
|
- tsumugu-db-data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-tsumugu} -d ${DB_NAME:-tsumugu}"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- tsumugu-network
|
||||||
|
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: tsumugu-api
|
||||||
|
environment:
|
||||||
|
TSUMUGU_ENV: "${TSUMUGU_ENV:-production}"
|
||||||
|
DB_HOST: postgres
|
||||||
|
DB_PORT: "5432"
|
||||||
|
DB_NAME: "${DB_NAME:-tsumugu}"
|
||||||
|
DB_USER: "${DB_USER:-tsumugu}"
|
||||||
|
DB_PASSWORD: "${DB_PASSWORD:?set DB_PASSWORD in .env}"
|
||||||
|
APP_URL: "${APP_URL:-https://tsumugu.jinkendo.de}"
|
||||||
|
ALLOWED_ORIGINS: "${ALLOWED_ORIGINS:-https://tsumugu.jinkendo.de}"
|
||||||
|
ports:
|
||||||
|
- "${TSUMUGU_BACKEND_PORT:-8006}:8000"
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
[
|
||||||
|
"CMD",
|
||||||
|
"python",
|
||||||
|
"-c",
|
||||||
|
"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/api/health')",
|
||||||
|
]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 12
|
||||||
|
start_period: 20s
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- tsumugu-network
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: ./frontend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: tsumugu-ui
|
||||||
|
ports:
|
||||||
|
- "${TSUMUGU_FRONTEND_PORT:-3007}:80"
|
||||||
|
depends_on:
|
||||||
|
backend:
|
||||||
|
condition: service_healthy
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- tsumugu-network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
tsumugu-db-data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
tsumugu-network:
|
||||||
|
driver: bridge
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# Deployment – Tsumugu
|
||||||
|
|
||||||
|
**Stand:** 2026-10-15
|
||||||
|
**Server:** Raspberry Pi (`192.168.2.49`) — gleicher Host wie Mitai, Shinkan, Kairo und Kanshō, **eigenes** Compose-Projekt
|
||||||
|
**Runner:** Gitea Actions (`/home/lars/gitea-runner/`), Label `ubuntu-latest`
|
||||||
|
**Repo:** `http://192.168.2.144:3000/Lars/tsumugu.git`
|
||||||
|
|
||||||
|
Der Mechanismus ist von Kanshō übernommen: der Runner auf dem Pi checkt den Branch in ein festes Verzeichnis aus, baut die Images und startet Compose. Watchtower bleibt aus.
|
||||||
|
|
||||||
|
Unter `/home/lars/docker/` legt der Lauf nur diese zwei Verzeichnisse an:
|
||||||
|
|
||||||
|
| | Production | Development |
|
||||||
|
|---|------------|-------------|
|
||||||
|
| **Git-Branch** | `main` | `develop` |
|
||||||
|
| **Server-Verzeichnis** | `/home/lars/docker/tsumugu` | `/home/lars/docker/tsumugu-dev` |
|
||||||
|
| **Frontend-Port** | 3007 | 3095 |
|
||||||
|
| **Backend-Port** | 8006 | 8095 |
|
||||||
|
| **PostgreSQL** | nur Compose-Netz, DB `tsumugu` | nur Compose-Netz, DB `tsumugu_dev` |
|
||||||
|
| **Domain** | tsumugu.jinkendo.de | dev.tsumugu.jinkendo.de |
|
||||||
|
| **Öffentliche URL** | https://tsumugu.jinkendo.de | https://dev.tsumugu.jinkendo.de |
|
||||||
|
| **Compose** | `docker-compose.yml` | `docker-compose.dev-env.yml` |
|
||||||
|
|
||||||
|
3005 ist auf dem Pi durch Bookstack belegt, 3006/8005 und 3096/8096 durch Kanshō. 3002–3004 und 3097–3099 gehören Mitai, Shinkan und Kairo. Tsumugu nimmt deshalb 3007/8006 und 3095/8095.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Gitea Actions
|
||||||
|
|
||||||
|
| Workflow | Trigger | Zweck |
|
||||||
|
|----------|---------|--------|
|
||||||
|
| `deploy-dev.yml` | Push `develop` | Deploy nach `/home/lars/docker/tsumugu-dev`, Health `localhost:8095` und `localhost:3095` |
|
||||||
|
| `deploy-prod.yml` | Push `main` | Deploy nach `/home/lars/docker/tsumugu`, Health `localhost:8006` und `localhost:3007` |
|
||||||
|
|
||||||
|
Gearbeitet wird auf `develop`. Production entsteht nur durch einen Merge-Commit `develop` → `main` (`git merge --no-ff develop` auf `main`) und den anschließenden Push von `main`. Kein Fast-Forward, kein direkter Commit auf `main`, kein manuelles `git pull` auf dem Prod-Checkout. Gitea (`deploy-prod.yml`) ist der einzige Prod-Schreibpfad für Code.
|
||||||
|
|
||||||
|
Fehlt beim ersten Lauf die Host-`.env`, legt der Workflow sie an. Development bekommt die dokumentierten Dev-Defaults. Production bekommt ein zufälliges `DB_PASSWORD`, das nur in `/home/lars/docker/tsumugu/.env` steht und nicht ins Log geschrieben wird. Spätere Läufe überschreiben eine vorhandene `.env` nicht. `git reset --hard` lässt die Datei liegen, weil sie nicht im Repo ist.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Erreichbarkeit von außen
|
||||||
|
|
||||||
|
TLS endet wie bei Kanshō auf dem Synology-NAS `192.168.2.63` (DSM Reverse Proxy), nicht auf dem Pi.
|
||||||
|
|
||||||
|
| Domain | Ziel |
|
||||||
|
|--------|------|
|
||||||
|
| `dev.tsumugu.jinkendo.de` | `http://192.168.2.49:3095` |
|
||||||
|
| `tsumugu.jinkendo.de` | `http://192.168.2.49:3007` |
|
||||||
|
|
||||||
|
DNS bzw. AdGuard-Rewrite für beide Namen auf `192.168.2.63`. Im DSM-Reverse-Proxy Lese- und Sende-Timeout auf 600s setzen. Bis die Regeln stehen, bleibt der LAN-Zugriff über die Publish-Ports:
|
||||||
|
|
||||||
|
- Development: `http://192.168.2.49:3095`
|
||||||
|
- Production: `http://192.168.2.49:3007`
|
||||||
|
|
||||||
|
`nginx/tsumugu.conf` und `nginx/tsumugu-dev.conf` sind die Host-nginx-Variante, falls TLS später auf dem Pi endet. Sie sind nicht der aktuelle Pfad.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Manuelles Deploy
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Development
|
||||||
|
cd /home/lars/docker/tsumugu-dev
|
||||||
|
git fetch origin develop && git reset --hard origin/develop
|
||||||
|
docker compose -f docker-compose.dev-env.yml build --no-cache backend frontend
|
||||||
|
docker compose -f docker-compose.dev-env.yml up -d --wait
|
||||||
|
curl -sf http://localhost:8095/api/health
|
||||||
|
|
||||||
|
# Production
|
||||||
|
cd /home/lars/docker/tsumugu
|
||||||
|
git fetch origin main && git reset --hard origin/main
|
||||||
|
docker compose build --no-cache backend frontend
|
||||||
|
docker compose up -d --wait
|
||||||
|
curl -sf http://localhost:8006/api/health
|
||||||
|
```
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY index.html /usr/share/nginx/html/index.html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Tsumugu</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
font-family: Georgia, "Times New Roman", serif;
|
||||||
|
background: #f4f1ea;
|
||||||
|
color: #1c1915;
|
||||||
|
}
|
||||||
|
main {
|
||||||
|
max-width: 28rem;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<h1>Tsumugu</h1>
|
||||||
|
<p>Das Deploy-Gerüst der Jinkendo-Familie läuft. Die Anwendung selbst folgt.</p>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||||
|
|
||||||
|
location ^~ /api/ {
|
||||||
|
set $docker_backend_svc backend;
|
||||||
|
proxy_pass http://$docker_backend_svc:8000$request_uri;
|
||||||
|
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_read_timeout 600s;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# Tsumugu development vhost. Install as /etc/nginx/sites-available/tsumugu-dev.
|
||||||
|
# Live TLS terminates on the Synology Reverse Proxy at 192.168.2.63.
|
||||||
|
# Point dev.tsumugu.jinkendo.de at http://192.168.2.49:3095.
|
||||||
|
# Set DSM proxy read/send timeout to 600s.
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name dev.tsumugu.jinkendo.de;
|
||||||
|
|
||||||
|
location /.well-known/acme-challenge/ {
|
||||||
|
root /var/www/certbot;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl http2;
|
||||||
|
server_name dev.tsumugu.jinkendo.de;
|
||||||
|
|
||||||
|
ssl_certificate /etc/letsencrypt/live/dev.tsumugu.jinkendo.de/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/dev.tsumugu.jinkendo.de/privkey.pem;
|
||||||
|
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||||
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||||
|
|
||||||
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||||
|
|
||||||
|
client_max_body_size 80m;
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://127.0.0.1:8095;
|
||||||
|
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_read_timeout 600s;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:3095;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
proxy_read_timeout 600s;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
# Tsumugu – Host nginx (outside Compose)
|
||||||
|
# Install as /etc/nginx/sites-available/tsumugu and symlink into sites-enabled.
|
||||||
|
# Live TLS for the Jinkendo family terminates on the Synology Reverse Proxy
|
||||||
|
# at 192.168.2.63. Point tsumugu.jinkendo.de at http://192.168.2.49:3007.
|
||||||
|
# Set DSM proxy read/send timeout to 600s.
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name tsumugu.jinkendo.de;
|
||||||
|
|
||||||
|
location /.well-known/acme-challenge/ {
|
||||||
|
root /var/www/certbot;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl http2;
|
||||||
|
server_name tsumugu.jinkendo.de;
|
||||||
|
|
||||||
|
ssl_certificate /etc/letsencrypt/live/tsumugu.jinkendo.de/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/tsumugu.jinkendo.de/privkey.pem;
|
||||||
|
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||||
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||||
|
|
||||||
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||||
|
|
||||||
|
client_max_body_size 80m;
|
||||||
|
gzip on;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://127.0.0.1:8006;
|
||||||
|
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_read_timeout 600s;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:3007;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
proxy_read_timeout 600s;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user