diff --git a/docs/git-pages-nginx-arkkitehtuuri.md b/docs/git-pages-nginx-arkkitehtuuri.md index 89654b1..d471d62 100644 --- a/docs/git-pages-nginx-arkkitehtuuri.md +++ b/docs/git-pages-nginx-arkkitehtuuri.md @@ -67,7 +67,7 @@ Browser → GET → Traefik | 1 | `Chart.yaml` | description, poista appVersion | | 2 | `values.yaml` | Poista git-pages-keyt, lisää nginx/sidecar | | 3 | `dev-values.yaml` | Matchaa uusi values-rakenne | -| 4 | `templates/configmap.yaml` | `nginx.conf` + `upload.sh` (CGI) | +| 4 | `templates/configmap.yaml` | `default.conf` (nginx) + `upload.cgi` | | 5 | `templates/deployment.yaml` | 2 konttia: nginx:alpine (8080) + busybox httpd (8081) | | 6 | `templates/ingressroute.yaml` | Backend: PATCH/PUT → upload:8081, GET/HEAD → nginx:8080 | | 7 | `templates/service.yaml` | 2 porttia: http-read(8080), http-write(8081) | @@ -96,13 +96,50 @@ Browser → GET → Traefik | `docs/design-rationale.md` | Päivitys | | `files/retention-*.sh` | Lue PV:tä suoraan, ei git-pages API:a | -## Nginx-konfiguraatio (ydin) +## Upload CGI + +Busybox httpd välittää CGI-skriptille tiedot ympäristömuuttujissa (`REQUEST_METHOD`, `PATH_INFO`, `CONTENT_LENGTH`). Skripti on tiedosto `/cgi/upload.cgi` — `.cgi`-pääte laukaisee CGI-execution. + +```bash +#!/bin/sh +# REQUEST_METHOD, PATH_INFO, etc. asettaa busybox httpd automaattisesti + +if [ "$REQUEST_METHOD" = "PUT" ]; then + dest="/app/data${PATH_INFO%/}" + mkdir -p "$dest" + cat - | tar -xzf - -C "$dest" + echo "Status: 201 Created" + echo "" +fi +``` + +**PUT `https://{host}/{owner}/{repo}/{branch}/{sha8}/{suite}/`** → CGI purkaa: +- `PATH_INFO` = `/{owner}/{repo}/{branch}/{sha8}/{suite}/` +- `dest` = `/app/data/{owner}/{repo}/{branch}/{sha8}/{suite}` +- Tarin tiedostot puretaan tähän + +**Huomio:** Skripti käyttää tar.gz-pakkausta. Jos tar on raaka (ilman gzip:ia), vaihda `-xzf` → `-xf`. + +### CGI-kutsu + +Busybox httpd käynnistetään: + +```bash +busybox httpd -f -p 8081 -h /cgi +``` + +`-h /cgi` on docroot. Skriptitiedoston pääte `.cgi` (esim. `/cgi/upload.cgi`) käynnistää CGI-execution automaattisesti. + +## Nginx-konfiguraatio ```nginx +client_max_body_size 100M; # nousevat raportit; oletus 1M on liian pieni + server { listen 8080; root /app/data; autoindex on; + client_max_body_size 100M; location / { try_files $uri $uri/ $uri/index.html =404; @@ -110,21 +147,7 @@ server { } ``` -## Upload CGI (ydin) - -```bash -#!/bin/sh -read -r method uri _ -case "$method" in - PUT) - dest="/app/data${uri%/*}" # strip filename - mkdir -p "$dest" - cat - | tar -xzf - -C "$dest" - echo "Status: 201 Created" - echo "" - ;; -esac -``` +Alpine-nginx lukee configit `/etc/nginx/http.d/default.conf`. ConfigMap mountataan tähän polkuun. ## Deployment (kontit) @@ -137,12 +160,19 @@ containers: name: http-read volumeMounts: - name: nginx-conf - mountPath: /etc/nginx/conf.d + mountPath: /etc/nginx/http.d - name: data mountPath: /app/data - name: upload image: alpine:latest - command: ["busybox", "httpd", "-f", "-p", "8081", "-h", "/cgi"] + command: + - busybox + - httpd + - -f + - -p + - "8081" + - -h + - /cgi ports: - containerPort: 8081 name: http-write @@ -154,6 +184,66 @@ containers: mountPath: /app/data ``` +## values.yaml-rakenne + +```yaml +# git-pages → Nginx + upload-sidecar + +nameOverride: "" +fullnameOverride: "" + +nginx: + image: nginx + tag: alpine + port: 8080 + bodySize: 100M + +upload: + image: alpine + tag: latest + port: 8081 + +service: + type: ClusterIP + +persistence: + enabled: true + accessMode: ReadWriteOnce + storageClass: "" + size: 5Gi + +ingress: + enabled: true + host: ci-reports.helm-dev.keskikuja.site + entryPoints: + websecure: websecure + web: web + +certificate: + enabled: true + issuerRef: + name: letsencrypt-prod + kind: ClusterIssuer + +publishAuth: + create: false + htpasswdUsers: "" + +retention: + enabled: false + mode: cronjob + schedule: "0 3 * * *" + image: + repository: debian + tag: bookworm-slim + giteaApiUrl: "" + rules: + branches: + default: + maxAgeDays: 90 + keepMin: 5 +``` + ## CI-julkaisu (publish-skripti) ### Muutokset nykyiseen @@ -200,19 +290,23 @@ mkdir -p "$WORK/$SUITE" cp -a "$SUITE/." "$WORK/$SUITE/" # Generoi index.html (sama logiikka kuin nykyään) -cd "$WORK" -if [ ! -f "$SUITE/index.html" ]; then +cd "$WORK/$SUITE" +if [ ! -f "index.html" ]; then # identtinen item-listaus kuin nykyisessä skriptissä … fi # .meta tiedosto retentionia varten -cat > "$SUITE/.meta" < ".meta" <