From 9dd62999bda75b64e2cb1669bed43399d0a85b74 Mon Sep 17 00:00:00 2001 From: smueller Date: Tue, 7 Jul 2026 14:47:25 +0200 Subject: [PATCH 1/2] Remove diagnostic steps for registry login from Docker build workflow - Eliminate previous checks for registry login credentials, including Basic-Auth and token request diagnostics. - Streamline the workflow by focusing on essential steps for Gitea Container Registry login. --- .gitea/workflows/docker-build.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index 6541e97..dfac39e 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -28,36 +28,6 @@ jobs: - name: Docker Buildx einrichten uses: docker/setup-buildx-action@v3 - - name: Registry-Anmeldung prüfen (Diagnose) - env: - REG_USER: ${{ secrets.REGISTRY_USER || github.repository_owner }} - REG_TOKEN: ${{ secrets.REGISTRY_TOKEN }} - run: | - IMAGE_LOWER=$(echo "${IMAGE_NAME}" | tr '[:upper:]' '[:lower:]') - echo "Registry: ${REGISTRY}" - echo "Username: '${REG_USER}' (Laenge: ${#REG_USER})" - echo "Token gesetzt: $([ -n "${REG_TOKEN}" ] && echo ja || echo NEIN) (Laenge: ${#REG_TOKEN})" - echo "Image (lower): ${IMAGE_LOWER}" - - echo "--- API-Test: /api/v1/user (Basic-Auth gueltig?) ---" - curl -s -o /dev/null -w "HTTP %{http_code}\n" -u "${REG_USER}:${REG_TOKEN}" "https://${REGISTRY}/api/v1/user" - - echo "--- /v2/ Challenge (WWW-Authenticate) ---" - HDR=$(curl -s -D - -o /dev/null "https://${REGISTRY}/v2/") - AUTH=$(printf '%s' "$HDR" | tr -d '\r' | grep -i '^www-authenticate:' || true) - echo "${AUTH:-(keine WWW-Authenticate Zeile)}" - REALM=$(printf '%s' "$AUTH" | sed -n 's/.*realm="\([^"]*\)".*/\1/p') - SERVICE=$(printf '%s' "$AUTH" | sed -n 's/.*service="\([^"]*\)".*/\1/p') - echo "realm='${REALM}' service='${SERVICE}'" - - if [ -n "${REALM}" ]; then - echo "--- Token-Request am echten realm ---" - CODE=$(curl -s -o /tmp/tok.json -w "%{http_code}" -u "${REG_USER}:${REG_TOKEN}" \ - "${REALM}?service=${SERVICE}&scope=repository:${IMAGE_LOWER}:pull,push") - echo "HTTP ${CODE}" - echo "Antwort (gekuerzt): $(head -c 300 /tmp/tok.json)" - fi - - name: An Gitea Container Registry anmelden uses: docker/login-action@v3 with: From 8b813c7e2038292d81fedb1249857a2ce01baae9 Mon Sep 17 00:00:00 2001 From: smueller Date: Tue, 7 Jul 2026 14:50:14 +0200 Subject: [PATCH 2/2] Update README.md to reflect new Docker image publishing and CI/CD workflow - Enhance documentation with details on automatic image builds and pushes to Gitea Container Registry. - Add instructions for pulling and running the container image, including usage in docker-compose. - Include information on the CI/CD workflow for building and pushing images based on version tags. --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2c82177..f4f1f5f 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ Produktionsnahes internes Tool zur Erstellung von Thomas-Krenn.AG Newslettern au - Login und Benutzerverwaltung mit RBAC (`admin`, `editor`, `reader`) - Verpflichtender CSRF-Schutz auf allen POST-Formularen - Filter in der Web-UI: - - Zeitraum in Tagen - - Nur bearbeitete Artikel + - Zeitraum in Tagen oder „Letzter Monat“ + - Artikel-Auswahl: alle, nur neue oder nur bearbeitete Artikel - Kategorie - Redaktioneller Feinschliff pro Ausgabe: - **Redaktionsnotiz** – optionaler Hinweistext, der als eigene Box im Newsletter erscheint @@ -25,7 +25,7 @@ Produktionsnahes internes Tool zur Erstellung von Thomas-Krenn.AG Newslettern au - Verteilerlisten - tägliche Zeitplanung - Versandprotokoll -- Docker/Compose Betrieb +- Docker/Compose Betrieb, inkl. automatischem Image-Build & Push in die Gitea Container Registry (per Versions-Tag) ## Start mit Docker @@ -50,6 +50,57 @@ Produktionsnahes internes Tool zur Erstellung von Thomas-Krenn.AG Newslettern au 4. Zugriff: - [http://localhost:8080/login](http://localhost:8080/login) (oder dein `HOST_PORT`) +## Container-Image (Gitea Packages) + +Fertige Images werden automatisch in die Gitea Container Registry veröffentlicht: + +``` +git.hexahost.dev/smueller/tk-wiki-newsletter +``` + +Verfügbare Tags: `latest`, die Version (`X.Y.Z`, `X.Y`, `X`) sowie der kurze Commit-SHA. + +Image ziehen und mit vorhandener `.env` starten: + +```bash +docker login git.hexahost.dev +docker pull git.hexahost.dev/smueller/tk-wiki-newsletter:latest +docker run -d --name tk-newsletter-admin \ + --env-file .env \ + -p 8080:8000 \ + -v newsletter_data:/app/data \ + git.hexahost.dev/smueller/tk-wiki-newsletter:latest +``` + +Alternativ in `docker-compose.yml` statt `build: .` das Image referenzieren: + +```yaml +services: + newsletter-admin: + image: git.hexahost.dev/smueller/tk-wiki-newsletter:latest + # build: . # <- nicht mehr nötig, wenn das fertige Image genutzt wird +``` + +### Automatischer Build (CI/CD) + +Der Workflow `.gitea/workflows/docker-build.yml` baut und pusht das Image über Gitea Actions. + +- **Auslöser**: nur beim Setzen eines Versions-Tags `v*` (kein Build bei normalen Pushes auf `dev`/`main`). +- **Release-Ablauf** (Build bei Merge `dev` → `main` mit Version): + + ```bash + git checkout main + git merge --no-ff dev + git push origin main + git tag v1.0.0 + git push origin v1.0.0 # <- startet Build & Push + ``` + +- **Benötigte Repo-Secrets** (Settings → Actions → Secrets): + - `REGISTRY_TOKEN`: Gitea Access-Token mit Scope **Package: Read and write** + - `REGISTRY_USER` (optional): Registry-Benutzername, falls abweichend vom Repo-Owner +- **Optionale Repo-Variable**: `REGISTRY`, um den Registry-Host zu überschreiben (Default `git.hexahost.dev`). + ## Sicherheits-Hinweise für Produktion - Reverse Proxy (z. B. Nginx/Traefik) mit TLS vor den Container setzen.