Gitea Runner CI/CD fuer Raspberry Pi 5 (deploy-dev & deploy-prod) nach Tsumugu-Vorbild
This commit is contained in:
1 parent
53aec82f7d
commit
5f212e7338
9 files changed
+384
-22
No files matched your search
@@ -4,3 +4,4 @@
|
|||||||
*.png binary
|
*.png binary
|
||||||
*.jpg binary
|
*.jpg binary
|
||||||
*.gif binary
|
*.gif binary
|
||||||
|
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
name: Deploy Development
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [develop]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Deploy Karatewiki to development (Raspberry Pi 5)
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
echo "=== Deploying Karatewiki to DEVELOPMENT ==="
|
||||||
|
REPO="http://192.168.2.144:3000/Lars/karatewiki.git"
|
||||||
|
TARGET="/home/lars/docker/karatewiki-dev"
|
||||||
|
mkdir -p "$TARGET/backups/db-init"
|
||||||
|
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
|
||||||
|
SECRET="$(od -An -N32 -tx1 /dev/urandom | tr -d ' \n')"
|
||||||
|
UPGRADE="$(od -An -N8 -tx1 /dev/urandom | tr -d ' \n')"
|
||||||
|
printf '%s\n' \
|
||||||
|
'MW_ENV=development' \
|
||||||
|
'MW_PORT=3093' \
|
||||||
|
'MW_SERVER=http://192.168.2.49:3093' \
|
||||||
|
'MW_SITENAME=Karate (DEV)' \
|
||||||
|
'MW_DB_NAME=karatewiki_dev' \
|
||||||
|
'MW_DB_USER=karatewiki_dev' \
|
||||||
|
'MW_DB_PASSWORD=dev_password_change_me' \
|
||||||
|
'MW_DB_ROOT_PASSWORD=dev_root_change_me' \
|
||||||
|
'MW_DB_PREFIX=Karate_' \
|
||||||
|
"MW_SECRET_KEY=${SECRET}" \
|
||||||
|
"MW_UPGRADE_KEY=${UPGRADE}" \
|
||||||
|
> .env
|
||||||
|
echo "created $TARGET/.env from dev defaults"
|
||||||
|
umask 022
|
||||||
|
fi
|
||||||
|
docker compose -f docker-compose.dev-env.yml build --no-cache mediawiki
|
||||||
|
docker compose -f docker-compose.dev-env.yml up -d db
|
||||||
|
# Warte auf MariaDB und initialisiere Schema falls DB noch leer ist
|
||||||
|
for i in $(seq 1 20); do
|
||||||
|
if docker compose -f docker-compose.dev-env.yml exec -T db healthcheck.sh --connect --innodb_initialized >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
docker compose -f docker-compose.dev-env.yml run --rm --no-deps mediawiki php /usr/local/bin/ensure-db-schema.php
|
||||||
|
docker compose -f docker-compose.dev-env.yml run --rm --no-deps mediawiki php maintenance/run.php update --quick
|
||||||
|
if ! docker compose -f docker-compose.dev-env.yml up -d --wait; then
|
||||||
|
echo "compose up --wait failed — mediawiki logs:"
|
||||||
|
docker compose -f docker-compose.dev-env.yml logs mediawiki --tail 150 || true
|
||||||
|
docker compose -f docker-compose.dev-env.yml ps || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! curl -sf "http://localhost:3093/api.php?action=query&meta=siteinfo&format=json" >/dev/null; then
|
||||||
|
echo "DEV MediaWiki API not reachable — logs:"
|
||||||
|
docker compose -f docker-compose.dev-env.yml logs mediawiki --tail 150 || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "DEV MediaWiki API OK (http://192.168.2.49:3093)"
|
||||||
|
echo "=== Karatewiki DEV deploy complete ==="
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
name: Deploy Production
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Deploy Karatewiki to production standby (Raspberry Pi 5)
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
echo "=== Deploying Karatewiki to PRODUCTION (Pi Standby) ==="
|
||||||
|
REPO="http://192.168.2.144:3000/Lars/karatewiki.git"
|
||||||
|
TARGET="/home/lars/docker/karatewiki"
|
||||||
|
mkdir -p "$TARGET/backups/db-init"
|
||||||
|
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')"
|
||||||
|
ROOTPASS="$(od -An -N24 -tx1 /dev/urandom | tr -d ' \n')"
|
||||||
|
SECRET="$(od -An -N32 -tx1 /dev/urandom | tr -d ' \n')"
|
||||||
|
UPGRADE="$(od -An -N8 -tx1 /dev/urandom | tr -d ' \n')"
|
||||||
|
printf '%s\n' \
|
||||||
|
'MW_ENV=production' \
|
||||||
|
'MW_PORT=3008' \
|
||||||
|
'MW_SERVER=http://192.168.2.49:3008' \
|
||||||
|
'MW_SITENAME=Karate' \
|
||||||
|
'MW_DB_NAME=dbs1754262' \
|
||||||
|
'MW_DB_USER=dbu1061679' \
|
||||||
|
"MW_DB_PASSWORD=${PASS}" \
|
||||||
|
"MW_DB_ROOT_PASSWORD=${ROOTPASS}" \
|
||||||
|
'MW_DB_PREFIX=Karate_' \
|
||||||
|
"MW_SECRET_KEY=${SECRET}" \
|
||||||
|
"MW_UPGRADE_KEY=${UPGRADE}" \
|
||||||
|
> .env
|
||||||
|
unset PASS ROOTPASS SECRET UPGRADE
|
||||||
|
echo "created $TARGET/.env (passwords not logged)"
|
||||||
|
umask 022
|
||||||
|
fi
|
||||||
|
docker compose build --no-cache mediawiki
|
||||||
|
docker compose up -d db
|
||||||
|
for i in $(seq 1 20); do
|
||||||
|
if docker compose exec -T db healthcheck.sh --connect --innodb_initialized >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
docker compose run --rm --no-deps mediawiki php /usr/local/bin/ensure-db-schema.php
|
||||||
|
docker compose run --rm --no-deps mediawiki php maintenance/run.php update --quick
|
||||||
|
if ! docker compose up -d --wait; then
|
||||||
|
echo "compose up --wait failed — mediawiki logs:"
|
||||||
|
docker compose logs mediawiki --tail 150 || true
|
||||||
|
docker compose ps || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! curl -sf "http://localhost:3008/api.php?action=query&meta=siteinfo&format=json" >/dev/null; then
|
||||||
|
echo "PROD MediaWiki API not reachable — logs:"
|
||||||
|
docker compose logs mediawiki --tail 150 || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "PROD MediaWiki API OK (http://192.168.2.49:3008)"
|
||||||
|
echo "=== Karatewiki PROD deploy complete ==="
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Karatewiki (Goju-Kai Dojo)
|
||||||
|
|
||||||
|
Dieses Repository verwaltet die MediaWiki-Konfiguration (`config/LocalSettings.php`), das Docker-Setup (MediaWiki 1.43 LTS + MariaDB 11.8) und unsere eigenen Erweiterungen (`extensions-custom/KarateMedia`) für das Vereins-Wiki des Goju-Kai Dojo (`https://www.gojukai-dojo.de`).
|
||||||
|
|
||||||
|
## Wichtige Regeln für Agenten
|
||||||
|
|
||||||
|
1. **Strato-Produktivsystem niemals ungefragt verändern:** Auf `51539426.ssh.w1.strato.hosting` (`Karate_Wiki_135`) darf ohne ausdrückliche Freigabe nur **lesend** zugegriffen werden.
|
||||||
|
2. **Kein MediaWiki-Core und keine Mediendateien ins Git:** Weder der MediaWiki-Core noch Datenbank-Dumps (`*.sql`) oder der `images/`-Ordner (8,3 GB Videos) gehören in dieses Repository.
|
||||||
|
3. **Branch- & Deployment-Modell (`docs/DEPLOYMENT.md`):**
|
||||||
|
- Gearbeitet wird auf `develop`. Ein Push auf `develop` startet über den Gitea-Runner automatisch das Deployment auf dem Raspberry Pi 5 (`/home/lars/docker/karatewiki-dev`, Port `3093`).
|
||||||
|
- Ein Merge nach `main` startet das Production-/Standby-Deployment (`/home/lars/docker/karatewiki`, Port `3008`).
|
||||||
+4
-2
@@ -1,7 +1,6 @@
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Karate-Wiki Dockerfile
|
# Karate-Wiki Dockerfile (Multi-Arch: laeuft nativ auf Raspberry Pi 5 ARM64)
|
||||||
# Standardmaessig auf MediaWiki 1.43 LTS (kompatibel mit PHP 8.3 / 8.4)
|
# Standardmaessig auf MediaWiki 1.43 LTS (kompatibel mit PHP 8.3 / 8.4)
|
||||||
# Kann zum Testen des Altsystems auch mit --build-arg MW_VERSION=1.39 gebaut werden
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
ARG MW_VERSION=1.43
|
ARG MW_VERSION=1.43
|
||||||
FROM mediawiki:${MW_VERSION}
|
FROM mediawiki:${MW_VERSION}
|
||||||
@@ -19,5 +18,8 @@ COPY config/php-uploads.ini /usr/local/etc/php/conf.d/zz-karate-uploads.ini
|
|||||||
# Vereins-Logo ins Image kopieren
|
# Vereins-Logo ins Image kopieren
|
||||||
COPY assets/logo_goju-kai_Bleistift.png /var/www/html/resources/assets/logo_goju-kai_Bleistift.png
|
COPY assets/logo_goju-kai_Bleistift.png /var/www/html/resources/assets/logo_goju-kai_Bleistift.png
|
||||||
|
|
||||||
|
# DB-Initialisierungshilfe fuer Erst-Deployments auf dem Raspberry Pi
|
||||||
|
COPY scripts/ensure-db-schema.php /usr/local/bin/ensure-db-schema.php
|
||||||
|
|
||||||
# Unsere eigene, wartungsfreie Video-Extension (ersetzt Html5mediator & EmbedVideo)
|
# Unsere eigene, wartungsfreie Video-Extension (ersetzt Html5mediator & EmbedVideo)
|
||||||
COPY extensions-custom/KarateMedia /var/www/html/extensions/KarateMedia
|
COPY extensions-custom/KarateMedia /var/www/html/extensions/KarateMedia
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
# Server development stack: /home/lars/docker/karatewiki-dev
|
||||||
|
# No fixed container_name — Compose prefixes with the project name.
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: mariadb:11.8
|
||||||
|
environment:
|
||||||
|
MARIADB_DATABASE: "${MW_DB_NAME:-karatewiki_dev}"
|
||||||
|
MARIADB_USER: "${MW_DB_USER:-karatewiki_dev}"
|
||||||
|
MARIADB_PASSWORD: "${MW_DB_PASSWORD:-dev_password_change_me}"
|
||||||
|
MARIADB_ROOT_PASSWORD: "${MW_DB_ROOT_PASSWORD:-dev_root_change_me}"
|
||||||
|
volumes:
|
||||||
|
- dev-karatewiki-db-data:/var/lib/mysql
|
||||||
|
- ./backups/db-init:/docker-entrypoint-initdb.d:ro
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "healthcheck.sh --connect --innodb_initialized"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 20
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- dev-karatewiki-network
|
||||||
|
|
||||||
|
mediawiki:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
MW_VERSION: "1.43"
|
||||||
|
environment:
|
||||||
|
MW_ENV: "development"
|
||||||
|
MW_SERVER: "${MW_SERVER:-http://192.168.2.49:3093}"
|
||||||
|
MW_SITENAME: "${MW_SITENAME:-Karate (DEV)}"
|
||||||
|
MW_DB_HOST: "db"
|
||||||
|
MW_DB_NAME: "${MW_DB_NAME:-karatewiki_dev}"
|
||||||
|
MW_DB_USER: "${MW_DB_USER:-karatewiki_dev}"
|
||||||
|
MW_DB_PASSWORD: "${MW_DB_PASSWORD:-dev_password_change_me}"
|
||||||
|
MW_DB_PREFIX: "${MW_DB_PREFIX:-Karate_}"
|
||||||
|
MW_SECRET_KEY: "${MW_SECRET_KEY:-dev_secret_key_0123456789abcdef0123456789abcdef0123456789abcdef}"
|
||||||
|
MW_UPGRADE_KEY: "${MW_UPGRADE_KEY:-dev_upgrade_key_012345}"
|
||||||
|
volumes:
|
||||||
|
- ./config/LocalSettings.php:/var/www/html/LocalSettings.php:ro
|
||||||
|
- ./config/php-uploads.ini:/usr/local/etc/php/conf.d/zz-karate-uploads.ini:ro
|
||||||
|
- ./assets/logo_goju-kai_Bleistift.png:/var/www/html/resources/assets/logo_goju-kai_Bleistift.png:ro
|
||||||
|
- ./extensions-custom/KarateMedia:/var/www/html/extensions/KarateMedia:ro
|
||||||
|
- dev-karatewiki-images:/var/www/html/images
|
||||||
|
ports:
|
||||||
|
- "${MW_PORT:-3093}:80"
|
||||||
|
depends_on:
|
||||||
|
db:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:80/api.php?action=query&meta=siteinfo&format=json >/dev/null || exit 1"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 12
|
||||||
|
start_period: 20s
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- dev-karatewiki-network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
dev-karatewiki-db-data:
|
||||||
|
dev-karatewiki-images:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
dev-karatewiki-network:
|
||||||
|
driver: bridge
|
||||||
+55
-20
@@ -1,34 +1,69 @@
|
|||||||
|
# Server production / standby stack: /home/lars/docker/karatewiki
|
||||||
|
# No fixed container_name — Compose prefixes with the project name.
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
db:
|
||||||
|
image: mariadb:11.8
|
||||||
|
environment:
|
||||||
|
MARIADB_DATABASE: "${MW_DB_NAME:-dbs1754262}"
|
||||||
|
MARIADB_USER: "${MW_DB_USER:-dbu1061679}"
|
||||||
|
MARIADB_PASSWORD: "${MW_DB_PASSWORD}"
|
||||||
|
MARIADB_ROOT_PASSWORD: "${MW_DB_ROOT_PASSWORD}"
|
||||||
|
volumes:
|
||||||
|
- karatewiki-db-data:/var/lib/mysql
|
||||||
|
- ./backups/db-init:/docker-entrypoint-initdb.d:ro
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "healthcheck.sh --connect --innodb_initialized"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 20
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- karatewiki-network
|
||||||
|
|
||||||
mediawiki:
|
mediawiki:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
args:
|
||||||
MW_VERSION: "1.43"
|
MW_VERSION: "1.43"
|
||||||
container_name: karatewiki-web
|
environment:
|
||||||
restart: unless-stopped
|
MW_ENV: "production"
|
||||||
ports:
|
MW_SERVER: "${MW_SERVER:-http://192.168.2.49:3008}"
|
||||||
- "${MW_PORT:-8080}:80"
|
MW_SITENAME: "${MW_SITENAME:-Karate}"
|
||||||
env_file:
|
MW_DB_HOST: "db"
|
||||||
- .env
|
MW_DB_NAME: "${MW_DB_NAME:-dbs1754262}"
|
||||||
|
MW_DB_USER: "${MW_DB_USER:-dbu1061679}"
|
||||||
|
MW_DB_PASSWORD: "${MW_DB_PASSWORD}"
|
||||||
|
MW_DB_PREFIX: "${MW_DB_PREFIX:-Karate_}"
|
||||||
|
MW_SECRET_KEY: "${MW_SECRET_KEY}"
|
||||||
|
MW_UPGRADE_KEY: "${MW_UPGRADE_KEY}"
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/LocalSettings.php:/var/www/html/LocalSettings.php:ro
|
- ./config/LocalSettings.php:/var/www/html/LocalSettings.php:ro
|
||||||
|
- ./config/php-uploads.ini:/var/www/html/config-php-uploads.ini:ro
|
||||||
- ./config/php-uploads.ini:/usr/local/etc/php/conf.d/zz-karate-uploads.ini:ro
|
- ./config/php-uploads.ini:/usr/local/etc/php/conf.d/zz-karate-uploads.ini:ro
|
||||||
- ./assets/logo_goju-kai_Bleistift.png:/var/www/html/resources/assets/logo_goju-kai_Bleistift.png:ro
|
- ./assets/logo_goju-kai_Bleistift.png:/var/www/html/resources/assets/logo_goju-kai_Bleistift.png:ro
|
||||||
- ./extensions-custom/KarateMedia:/var/www/html/extensions/KarateMedia:ro
|
- ./extensions-custom/KarateMedia:/var/www/html/extensions/KarateMedia:ro
|
||||||
- ./data/images:/var/www/html/images
|
- karatewiki-images:/var/www/html/images
|
||||||
|
ports:
|
||||||
|
- "${MW_PORT:-3008}:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
db:
|
||||||
|
condition: service_healthy
|
||||||
db:
|
healthcheck:
|
||||||
image: mariadb:10.11
|
test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:80/api.php?action=query&meta=siteinfo&format=json >/dev/null || exit 1"]
|
||||||
container_name: karatewiki-db
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 12
|
||||||
|
start_period: 20s
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
networks:
|
||||||
MYSQL_DATABASE: ${MW_DB_NAME:-dbs1754262}
|
- karatewiki-network
|
||||||
MYSQL_USER: ${MW_DB_USER:-dbu1061679}
|
|
||||||
MYSQL_PASSWORD: ${MW_DB_PASSWORD}
|
volumes:
|
||||||
MYSQL_ROOT_PASSWORD: ${MW_DB_ROOT_PASSWORD}
|
karatewiki-db-data:
|
||||||
volumes:
|
karatewiki-images:
|
||||||
- ./data/mariadb:/var/lib/mysql
|
|
||||||
- ./backups/db-init:/docker-entrypoint-initdb.d:ro
|
networks:
|
||||||
|
karatewiki-network:
|
||||||
|
driver: bridge
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# Deployment – Karatewiki (Goju-Kai Dojo)
|
||||||
|
|
||||||
|
**Stand:** 2026-10-24
|
||||||
|
**Server:** Raspberry Pi 5 (`192.168.2.49`) — gleicher Host wie Mitai, Shinkan, Kairo, Kanshō und Tsumugu, **eigenes** Compose-Projekt
|
||||||
|
**Runner:** Gitea Actions (`/home/lars/gitea-runner/`), Label `ubuntu-latest`
|
||||||
|
**Repo (intern):** `http://192.168.2.144:3000/Lars/karatewiki.git`
|
||||||
|
**Repo (extern):** `https://gitea.stommer.de/Lars/karatewiki.git`
|
||||||
|
**Strato-Produktivsystem:** `51539426.ssh.w1.strato.hosting` (`/Karate_Wiki_135`, Domain `https://www.gojukai-dojo.de`)
|
||||||
|
|
||||||
|
Unter `/home/lars/docker/` legt der Gitea-Runner auf dem Raspberry Pi 5 diese zwei Verzeichnisse an:
|
||||||
|
|
||||||
|
| | Production / Pi-Standby | Development |
|
||||||
|
|---|------------|-------------|
|
||||||
|
| **Git-Branch** | `main` | `develop` |
|
||||||
|
| **Server-Verzeichnis** | `/home/lars/docker/karatewiki` | `/home/lars/docker/karatewiki-dev` |
|
||||||
|
| **Web-Port (Pi)** | `3008` (`http://192.168.2.49:3008`) | `3093` (`http://192.168.2.49:3093`) |
|
||||||
|
| **MariaDB 11.8** | nur Compose-Netz, DB `dbs1754262` | nur Compose-Netz, DB `karatewiki_dev` |
|
||||||
|
| **Images-Volume** | `karatewiki-images` | `dev-karatewiki-images` |
|
||||||
|
| **Compose** | `docker-compose.yml` | `docker-compose.dev-env.yml` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Gitea Actions
|
||||||
|
|
||||||
|
| Workflow | Trigger | Zweck |
|
||||||
|
|----------|---------|--------|
|
||||||
|
| `deploy-dev.yml` | Push `develop` | Deploy nach `/home/lars/docker/karatewiki-dev`, Schema-Check/Update, Healthcheck `localhost:3093/api.php` |
|
||||||
|
| `deploy-prod.yml` | Push `main` | Deploy nach `/home/lars/docker/karatewiki`, Schema-Check/Update, Healthcheck `localhost:3008/api.php` |
|
||||||
|
|
||||||
|
Gearbeitet wird auf `develop`. Ein Push auf `develop` baut automatisch den Development-Container auf dem Raspberry Pi 5 (`http://192.168.2.49:3093`).
|
||||||
|
Ein Merge-Commit `develop` → `main` (`git merge --no-ff develop` auf `main`) und anschließender Push von `main` aktualisiert die Production-/Standby-Instanz (`http://192.168.2.49:3008`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Live-Daten von Strato in die Pi-Container spiegeln (rein lesend auf Strato)
|
||||||
|
|
||||||
|
Um den aktuellen Datenbank-Stand und die Videos (`images/`, ca. 8,3 GB) von Strato in die Development- oder Standby-Umgebung auf dem Raspberry Pi zu laden:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Auf dem Raspberry Pi (z.B. fuer Development):
|
||||||
|
cd /home/lars/docker/karatewiki-dev
|
||||||
|
./scripts/sync-from-strato.sh
|
||||||
|
|
||||||
|
# Datenbank-Dump in den laufenden MariaDB-Container einspielen:
|
||||||
|
docker compose -f docker-compose.dev-env.yml exec -T db \
|
||||||
|
mariadb -u karatewiki_dev -pdev_password_change_me karatewiki_dev < backups/db-init/01-karatewiki.sql
|
||||||
|
|
||||||
|
# MediaWiki Schema-Migration (1.35 -> 1.43 LTS) ausfuehren:
|
||||||
|
docker compose -f docker-compose.dev-env.yml exec -T mediawiki \
|
||||||
|
php maintenance/run.php update --quick
|
||||||
|
```
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Stellt sicher, dass die MediaWiki-Datenbanktabellen (z.B. Karate_page) existieren,
|
||||||
|
* bevor maintenance/run.php update oder der Healthcheck laeuft.
|
||||||
|
* Falls die Datenbank komplett leer ist (erster Start ohne Strato-Dump),
|
||||||
|
* wird das Basis-Schema aus maintenance/tables-generated.sql angelegt.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$host = getenv( 'MW_DB_HOST' ) ?: 'db';
|
||||||
|
$name = getenv( 'MW_DB_NAME' ) ?: 'karatewiki_dev';
|
||||||
|
$user = getenv( 'MW_DB_USER' ) ?: 'karatewiki_dev';
|
||||||
|
$pass = getenv( 'MW_DB_PASSWORD' ) ?: '';
|
||||||
|
$prefix = getenv( 'MW_DB_PREFIX' ) ?: 'Karate_';
|
||||||
|
|
||||||
|
$db = new mysqli( $host, $user, $pass, $name );
|
||||||
|
if ( $db->connect_error ) {
|
||||||
|
fwrite( STDERR, "DB connection failed: {$db->connect_error}\n" );
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
$check = $db->query( "SHOW TABLES LIKE '" . $db->real_escape_string( $prefix . 'page' ) . "'" );
|
||||||
|
if ( $check && $check->num_rows > 0 ) {
|
||||||
|
echo "ensure-db-schema: Tabelle {$prefix}page existiert bereits.\n";
|
||||||
|
exit( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "ensure-db-schema: Leere Datenbank erkannt – initialisiere Basis-Tabellen mit Praefix '{$prefix}'...\n";
|
||||||
|
|
||||||
|
$sqlFiles = [
|
||||||
|
'/var/www/html/maintenance/tables-generated.sql',
|
||||||
|
'/var/www/html/maintenance/tables.sql',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ( $sqlFiles as $file ) {
|
||||||
|
if ( !file_exists( $file ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$sql = file_get_contents( $file );
|
||||||
|
$sql = str_replace( '/*_*/', $prefix, $sql );
|
||||||
|
$sql = str_replace( '/*i*/', $prefix, $sql );
|
||||||
|
$sql = str_replace( '/*$wgDBTableOptions*/', 'ENGINE=InnoDB, DEFAULT CHARSET=binary', $sql );
|
||||||
|
|
||||||
|
if ( !$db->multi_query( $sql ) ) {
|
||||||
|
fwrite( STDERR, "Error in {$file}: {$db->error}\n" );
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
if ( $res = $db->store_result() ) {
|
||||||
|
$res->free();
|
||||||
|
}
|
||||||
|
} while ( $db->more_results() && $db->next_result() );
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "ensure-db-schema: Basis-Schema erfolgreich angelegt.\n";
|
||||||
Reference in new issue
Block a user