commit 54f7f59fd5e9f236403bd96708a869d1cdd894b7 Author: Gunnar Magholder Date: Thu Mar 5 15:57:52 2026 +0100 Initial diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e723ecf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +# Beispiel Dockerfile für eine einfache Web-App +# Ersetze dies mit deinem eigenen Dockerfile + +FROM nginx:alpine + +# Statische Dateien kopieren +COPY public/ /usr/share/nginx/html/ + +EXPOSE 80 diff --git a/README.md b/README.md new file mode 100644 index 0000000..3acb5d9 --- /dev/null +++ b/README.md @@ -0,0 +1,112 @@ +# Example App - Forgejo CI/CD Template + +Diese Vorlage zeigt, wie du eine Anwendung mit Forgejo Actions automatisch auf deinen Server deployst. + +## Quick Start + +### 1. Neues Repository in Forgejo erstellen + +Gehe zu https://git.magholder.click und erstelle ein neues Repository. + +### 2. Diese Dateien kopieren + +```bash +# In dein Projektverzeichnis kopieren +cp -r templates/example-app/* mein-projekt/ +cd mein-projekt +git init +git remote add origin git@git.magholder.click:USERNAME/mein-projekt.git +``` + +### 3. Repository-Variablen setzen + +In Forgejo: **Repository Settings → Actions → Variables** + +| Variable | Wert | Beschreibung | +|----------|------|--------------| +| `APP_NAME` | `mein-projekt` | Name der App (für Container und Pfade) | +| `DOMAIN` | `mein-projekt.magholder.click` | Domain für Traefik | + +### 4. SSH-Key als Secret hinzufügen + +In Forgejo: **Repository Settings → Actions → Secrets** + +| Secret | Wert | +|--------|------| +| `SSH_PRIVATE_KEY` | Inhalt deines SSH Private Keys | + +**SSH-Key generieren (falls nicht vorhanden):** + +```bash +ssh-keygen -t ed25519 -f ~/.ssh/forgejo-deploy -N "" + +# Public Key auf Server kopieren +ssh-copy-id -i ~/.ssh/forgejo-deploy.pub root@194.163.164.113 + +# Private Key als Secret verwenden +cat ~/.ssh/forgejo-deploy +``` + +### 5. Pushen und deployen + +```bash +git add . +git commit -m "Initial commit" +git push -u origin main +``` + +Die Action wird automatisch gestartet und deployt deine App! + +## Anpassen + +### Eigenes Dockerfile + +Ersetze das `Dockerfile` mit deinem eigenen Build-Prozess. + +### Andere Ports + +Wenn deine App nicht auf Port 80 läuft, füge in `docker-compose.yml` hinzu: + +```yaml +labels: + - "traefik.http.services.${APP_NAME}.loadbalancer.server.port=3000" +``` + +### Umgebungsvariablen + +Füge in `docker-compose.yml` hinzu: + +```yaml +services: + app: + environment: + - DATABASE_URL=${DATABASE_URL} +``` + +Und setze `DATABASE_URL` als Secret in Forgejo. + +## Workflow-Datei + +Die CI/CD Pipeline ist in `.forgejo/workflows/deploy.yml` definiert: + +1. **Checkout** - Code auschecken +2. **SSH Setup** - SSH-Key für Server-Zugang einrichten +3. **Deploy** - Dateien kopieren und `docker compose up -d` + +## Troubleshooting + +### Action läuft nicht + +- Ist der Runner aktiv? Prüfe unter **Site Administration → Actions → Runners** +- Sind `runs-on: docker` Labels korrekt? + +### SSH-Fehler + +- Ist der Public Key auf dem Server in `~/.ssh/authorized_keys`? +- Stimmt der Private Key im Secret? + +### Container startet nicht + +```bash +ssh root@194.163.164.113 "docker logs APP_NAME" +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a172499 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +# Docker Compose für Traefik Deployment +# APP_NAME und DOMAIN werden über Forgejo Repository-Variablen gesetzt + +services: + app: + build: . + # Oder: image: dein-image:latest + container_name: ${APP_NAME:-example-app} + restart: unless-stopped + networks: + - traefik-public + labels: + - "traefik.enable=true" + - "traefik.http.routers.${APP_NAME:-example-app}.rule=Host(`${DOMAIN:-example.magholder.click}`)" + - "traefik.http.routers.${APP_NAME:-example-app}.entrypoints=websecure" + - "traefik.http.routers.${APP_NAME:-example-app}.tls.certresolver=letsencrypt" + +networks: + traefik-public: + external: true diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..0d34211 --- /dev/null +++ b/public/index.html @@ -0,0 +1,42 @@ + + + + + + Example App + + + +
+

Example App

+

Erfolgreich deployed via Forgejo Actions!

+
+ Push auf main → Automatisches Deployment +
+
+ +