diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4fe4e55 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +# Tekstbestanden altijd met LF, op elke machine en in de CI-runner. Prettier +# eist LF; zonder dit zet Git op Windows CRLF neer bij een checkout en faalt +# `pnpm check` op de opmaak. +* text=auto eol=lf + +# Binaire bestanden nooit aanpassen +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.webp binary +*.ico binary +*.woff binary +*.woff2 binary +*.pdf binary diff --git a/.gitea/workflows/continuous_integration.yaml b/.gitea/workflows/continuous_integration.yaml new file mode 100644 index 0000000..e18ac8c --- /dev/null +++ b/.gitea/workflows/continuous_integration.yaml @@ -0,0 +1,239 @@ +name: Continuous Integration + +# Branchstrategie (zie aidlc-docs/.../operations/deployment/deployment-plan.md): +# - Pull request → controles, geen deploy +# - Merge/push naar master → controles + automatisch naar test +# - Handmatig, elke branch → controles + naar test als 'Deploy to Test' aan staat +# - Handmatig, release/* → controles + naar productie als 'Deploy to Production' aan staat +on: + workflow_dispatch: + inputs: + deploy_test: + description: 'Deploy to Test' + type: boolean + default: false + deploy_production: + description: 'Deploy to Production (alleen vanaf een release/*-branch)' + type: boolean + default: false + pull_request: + types: [opened, synchronize, reopened] + push: + branches: [master] + +# Alleen bij pull requests een verouderde run afbreken; een deploy wordt nooit +# halverwege gestopt. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +env: + NODE_VERSION: '24' + # Vaste Playwright-versie: levert Chromium voor linux-arm64 (er bestaat geen + # officiële Chrome voor ARM64, en Ubuntu's chromium is een snap die niet in + # een container werkt) + PLAYWRIGHT_VERSION: '1.55.0' + +defaults: + run: + working-directory: web + +jobs: + # lint, opmaak, tests (incl. property-based en axe), build en audit + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + # pnpm-versie komt uit "packageManager" in web/package.json + - uses: pnpm/action-setup@v4 + with: + package_json_file: web/package.json + + - name: Get pnpm store directory + id: pnpm-store + run: echo "path=$(pnpm store path)" >> "$GITHUB_OUTPUT" + + - name: Cache pnpm store + uses: actions/cache@v4 + with: + path: ${{ steps.pnpm-store.outputs.path }} + key: pnpm-${{ hashFiles('web/pnpm-lock.yaml') }} + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Lint + run: pnpm lint + + - name: Format + run: pnpm format:check + + # Logt de fast-check-seed; opnieuw afspelen met FC_SEED= pnpm test + - name: Tests + run: pnpm test + + - name: Build + run: pnpm build + + - name: Audit (productiepakketten, blokkerend) + run: pnpm audit:deps + + - name: Audit (ontwikkeltools, alleen melden) + run: pnpm audit:dev + + - name: Upload build artifact + uses: actions/upload-artifact@v3 + with: + name: dist + path: web/dist/ + retention-days: 7 + + # Lighthouse tegen de gebouwde site (mobiel en desktop) + lighthouse: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + - uses: pnpm/action-setup@v4 + with: + package_json_file: web/package.json + + - name: Get pnpm store directory + id: pnpm-store + run: echo "path=$(pnpm store path)" >> "$GITHUB_OUTPUT" + + - name: Restore pnpm store + uses: actions/cache@v4 + with: + path: ${{ steps.pnpm-store.outputs.path }} + key: pnpm-${{ hashFiles('web/pnpm-lock.yaml') }} + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Download build artifact + uses: actions/download-artifact@v3 + with: + name: dist + path: web/dist + + - name: Install Chromium + run: | + pnpm dlx playwright@${{ env.PLAYWRIGHT_VERSION }} install --with-deps chromium + CHROME_PATH="$(find "$HOME/.cache/ms-playwright" -path '*chrome-linux*' -name chrome -type f | head -n 1)" + test -x "$CHROME_PATH" + echo "CHROME_PATH=$CHROME_PATH" >> "$GITHUB_ENV" + "$CHROME_PATH" --version + + # Als root in een container weigert Chrome te starten zonder --no-sandbox + # (gelezen door lighthouserc.cjs, zie daar waarom niet via LHCI_*) + - name: Lighthouse + env: + LIGHTHOUSE_CHROME_FLAGS: '--no-sandbox --headless=new' + run: pnpm lighthouse + + deploy-test: + needs: [check, lighthouse] + if: (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_test == 'true') || (github.event_name == 'push' && github.ref == 'refs/heads/master') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Download build artifact + uses: actions/download-artifact@v3 + with: + name: dist + path: web/dist + + # Eenvoudig: de testmap leegmaken en de nieuwe build erin zetten. Oude + # versies worden niet bewaard. Op de Pi draait ook de huidige + # WordPress-site; daarom weigert deze stap een lege variabele, '/', of + # een map waarin WordPress staat. + - name: Upload naar de testserver + env: + # Secrets via env, zodat bash tekens als $ of ` niet nog eens uitlegt + SSHPASS: ${{ secrets.PI_MAIN_PASSWORD }} + SSH_PORT: ${{ secrets.PI_MAIN_PORT }} + SSH_USER: ${{ secrets.PI_MAIN_USERNAME }} + SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }} + DEPLOY_PATH: ${{ vars.DEPLOY_PATH_TEST }} + run: | + case "$DEPLOY_PATH" in + ''|'/'|*' '*) echo "DEPLOY_PATH_TEST ontbreekt of is ongeldig: '$DEPLOY_PATH'"; exit 1 ;; + esac + sudo apt-get update && sudo apt-get install -y sshpass + SSH="sshpass -e ssh -p $SSH_PORT -o StrictHostKeyChecking=accept-new $SSH_USER@$SSH_HOST" + $SSH "set -e + if [ -e '$DEPLOY_PATH/wp-config.php' ] || [ -d '$DEPLOY_PATH/wp-content' ]; then + echo 'Geweigerd: $DEPLOY_PATH bevat WordPress'; exit 1 + fi + mkdir -p '$DEPLOY_PATH' + find '$DEPLOY_PATH' -mindepth 1 -delete" + sshpass -e scp -P "$SSH_PORT" -o StrictHostKeyChecking=accept-new -r dist/. "$SSH_USER@$SSH_HOST:$DEPLOY_PATH/" + echo "Gedeployd naar test: ${GITHUB_REF_NAME} (${GITHUB_SHA::7})" + + - name: Controle na deploy + env: + HEALTH_URL: ${{ vars.HEALTH_CHECK_URL_TEST }} + run: | + if [ -z "$HEALTH_URL" ]; then echo "Geen HEALTH_CHECK_URL_TEST ingesteld; overgeslagen"; exit 0; fi + curl -fsS -o /dev/null --retry 5 --retry-delay 3 "$HEALTH_URL" + curl -fsSI "$HEALTH_URL" | grep -qi '^content-security-policy:' + echo "Test bereikbaar met security headers" + + deploy-production: + needs: [check, lighthouse] + # Alleen handmatig, en alleen vanaf een release-branch + if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_production == 'true' && startsWith(github.ref, 'refs/heads/release/') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Download build artifact + uses: actions/download-artifact@v3 + with: + name: dist + path: web/dist + + - name: IIS-configuratie toevoegen + run: cp deploy/iis/web.config dist/web.config + + # FTP met TLS (verplicht) naar de webhoster. Eerst alle bestanden behalve + # index.html, dan index.html, en pas daarna oude bestanden opruimen. Zo + # verwijst een bezoeker nooit naar een bestand dat er nog niet staat. + - name: Upload naar productie (FTPS) + env: + FTP_HOST: ${{ secrets.FTP_HOST }} + FTP_USER: ${{ secrets.FTP_USERNAME }} + LFTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} + FTP_DIR: ${{ vars.FTP_REMOTE_DIR || 'wwwroot' }} + run: | + sudo apt-get update && sudo apt-get install -y lftp + lftp --env-password -u "$FTP_USER" "$FTP_HOST" -e " + set ftp:ssl-force true; + set ftp:ssl-protect-data true; + set net:max-retries 3; + mirror --reverse --verbose --exclude-glob index.html dist/ $FTP_DIR/; + put -O $FTP_DIR dist/index.html; + mirror --reverse --delete --verbose dist/ $FTP_DIR/; + quit" + echo "Gedeployd naar productie: ${GITHUB_REF_NAME} (${GITHUB_SHA::7})" + + - name: Controle na deploy + env: + HEALTH_URL: ${{ vars.HEALTH_CHECK_URL_PRODUCTION }} + run: | + if [ -z "$HEALTH_URL" ]; then echo "Geen HEALTH_CHECK_URL_PRODUCTION ingesteld; overgeslagen"; exit 0; fi + curl -fsS -o /dev/null --retry 5 --retry-delay 3 "$HEALTH_URL" + curl -fsSI "$HEALTH_URL" | grep -qi '^content-security-policy:' + echo "Productie bereikbaar met security headers" diff --git a/aidlc-docs/active-features.md b/aidlc-docs/active-features.md index 6aea403..b1a82b0 100644 --- a/aidlc-docs/active-features.md +++ b/aidlc-docs/active-features.md @@ -2,4 +2,4 @@ | Type | Name | Status | Branch | Affected Components | Session Start | |------|------|--------|--------|---------------------|---------------| -| Feature | frontend-shell | 🟢 Construction | feature/frontend-shell | web/src (AppShell, NavigationBar, Footer, Hero socials, new BackToTop/SkipLink/404/error pages, routes, theme.ts, main.tsx), web/vite.config.js, web/package.json | 2026-10-14 | +| Feature | frontend-shell | 🟡 Operations | feature/frontend-shell | web/src (AppShell, NavigationBar, Footer, Hero socials, new BackToTop/SkipLink/404/error pages, routes, theme.ts, main.tsx), web/vite.config.js, web/package.json | 2026-10-14 | diff --git a/aidlc-docs/features/frontend-shell/aidlc-state.md b/aidlc-docs/features/frontend-shell/aidlc-state.md index 25fc87e..aa86921 100644 --- a/aidlc-docs/features/frontend-shell/aidlc-state.md +++ b/aidlc-docs/features/frontend-shell/aidlc-state.md @@ -5,7 +5,7 @@ - **Feature Slug**: frontend-shell - **Project Type**: Brownfield - **Start Date**: 2026-10-14T09:46:02Z -- **Current Stage**: CONSTRUCTION - Build and Test (complete, awaiting Operations decision) +- **Current Stage**: OPERATIONS - Deployment Setup (awaiting approval) - **Branch**: feature/frontend-shell ## Workspace State @@ -33,8 +33,12 @@ | Property-Based Testing | Yes (full enforcement) | Requirements Analysis | ## Operations Configuration -- **Include Operations Phase**: Undecided -- **Decided At**: Pending — asked at Requirements Analysis +- **Include Operations Phase**: Yes +- **Decided At**: Build and Test + +### Deployment Setup +- **Included**: Yes +- **Method**: CI/CD (Gitea Actions) — test via SSH/scp to Raspberry Pi nginx, production via FTPS to IIS webhost (manual, release/* only) ## Scope Notes (from user) - Side area / "Info menu" from the static design is OUT of scope (deliberately left out) @@ -62,15 +66,17 @@ - [x] NFR Design - SKIP - [x] Infrastructure Design - SKIP - [x] Code Generation - EXECUTE (approved) -- [x] Build and Test - EXECUTE (complete; Operations decision pending) +- [x] Build and Test - EXECUTE (complete) ### 🟡 OPERATIONS PHASE -- [ ] Deployment Setup, Monitoring Setup, Production Readiness Validation - UNDECIDED +- [~] Deployment Setup - EXECUTE (artifacts generated, awaiting approval) +- [ ] Monitoring Setup - EXECUTE +- [ ] Production Readiness Validation - EXECUTE ## Current Status -- **Lifecycle Phase**: CONSTRUCTION -- **Current Stage**: Build and Test -- **Next Stage**: Operations (undecided) +- **Lifecycle Phase**: OPERATIONS +- **Current Stage**: Deployment Setup +- **Next Stage**: Monitoring Setup ## Reverse Engineering Status - [x] Reverse Engineering - Artifacts generated on 2026-10-14T09:58:04Z (approved 2026-10-14T10:05:21Z) diff --git a/aidlc-docs/features/frontend-shell/audit.md b/aidlc-docs/features/frontend-shell/audit.md index 12a9944..8c1909f 100644 --- a/aidlc-docs/features/frontend-shell/audit.md +++ b/aidlc-docs/features/frontend-shell/audit.md @@ -474,3 +474,147 @@ Verder heb ik de vraag ook beantwoord" **Context**: CONSTRUCTION - Build and Test; awaiting Operations decision --- + +## Operations - Decision and Deployment Setup Start + +**Timestamp**: 2026-10-18T15:06:16Z + +**User Input**: "commit de huidige changes en ga verder met de Operations Fase. We moeten in ieder geval de CI/CD opzetten. En misschien dat ik meteen logging an monitoring wel toevoegen" + +**AI Response**: "Committed on feature/frontend-shell (not pushed): 4d6408b (code) and 069c7cb (AI-DLC docs). Operations Configuration set to Yes (Decided At: Build and Test); active-features status Operations. Context: self-hosted Gitea at gitea.slpsoftware.nl, no CI config, empty api/, core.autocrlf=true without .gitattributes (CRLF vs Prettier LF risk). Created operations/plans/deployment-setup-plan.md with 8 questions (inclusion, CI system, runner, hosting, environments, trigger, Lighthouse in pipeline, rollback); .gitattributes eol=lf pre-decided." + +**Context**: OPERATIONS - Deployment Setup; awaiting answers + +--- + +## Deployment Setup - Answers and Clarification + +**Timestamp**: 2026-10-18T19:05:12Z + +**User Input**: "Ik heb de vragen beantwoord" + +**AI Response**: "Read deployment-setup-plan.md answers: A | A | A | X, voor productie wordt dat een webhoster met ftp/sftp toegang. Voor de testomgeving heb ik een eigen server, maar heb ik eventueel ook toegang met ftp/sftp. Ik heb alleen maar 1 website die ik kan hosten dus zodra ik de API ga bouwen die uit een ander project gaat komen moet de website als static files worden geserveerd door de API. Dit is een pagina met meer info over de webhost: https://www.mijnhostingpartner.nl/pg/info/aspnet-core-hosting/ en het gaat dan om het ASP.NET Core 10 Hosting pakket | B | B, ik wil de gitflow gaan toepassen. Naar test moet altijd kunnen. Zodat er makkelijk en snel een specifieke versie op de test-omgeving gedeployed of geredeployed kan worden. Naar productie mag alleen vanaf een release-branch. DIe branch wordt daarna teruggemerged naar develop en master en op master wordt dan een tag gezet. Ik heb ook van trunk-based gehoord. het zou kunnen dat dat praktischer is. Ik laat mij graag aanbevelen wat handiger is voor mij. | ik heb een headless browser op de gitea/buildserver staan. Als het goed is is dat chrome, maar niet meer helemaal zeker. | B als dat kan en ook gezien de database. Ik weet niet of er via de pipeline een migratie kan worden gedaan en ook terug worden gedraaid zodra we een API hebben?. Fetched hosting package page (Windows 2016/2019, URL Rewrite = IIS, 1 website, MSSQL/MySQL/MariaDB 50MB; FTP/SFTP not mentioned). Created operations/plans/deployment-clarification-questions.md: branching strategy (recommend trunk-based with release tags), go-live timing (first prod deploy replaces current site), transfer method to host, test server OS, Chromium in runner; plus info on EF Core migrations and roll-forward rollback." + +**Context**: OPERATIONS - Deployment Setup; awaiting clarification answers + +--- + +## Deployment Setup - Clarifications and Artifacts + +**Timestamp**: 2026-10-18T19:27:28Z + +**User Input**: "ik heb de vragen beantwoord" + +**AI Response**: "Clarification answers: CQ1 X (master + feature/* + release/*, no develop; PR merge auto-deploys to test; manual test deploy from any branch), CQ2 A (current site on other host, go-live by DNS switch), CQ3 B (FTPS; hoster KB: port 21, TLS, wwwroot), CQ4 B (Raspberry Pi nginx behind reverse-proxy Pi), CQ5 runner raspberry-pi-arm64 labels linux-arm64/ubuntu-latest, reference projects SlpSoftware and SlpModularCms (Podman runner: container actions fail with 409, use shell steps; sshpass/scp pattern). Created .gitea/workflows/continuous_integration.yaml (check, lighthouse, deploy-test, deploy-production), web/config/serverConfig.ts + writeServerConfig.ts + test (generated web/deploy/iis/web.config and web/deploy/nginx/andreaslop-test.conf from securityHeaders), .gitattributes eol=lf, packageManager pnpm@12.11.2 (lockfile now pins pnpm). Found and fixed: LHCI_COLLECT__SETTINGS__* env replaced the desktop preset (verified locally); chrome flags now via LIGHTHOUSE_CHROME_FLAGS read in lighthouserc. Docs: operations/deployment/deployment-plan.md, deployment-instructions.md, rollback-plan.md. Lint, format, 88 tests, build pass. Not verifiable from here: Chromium in runner container, lftp TLS with hoster certificate, Pi write permissions." + +**Context**: OPERATIONS - Deployment Setup; artifacts generated, awaiting approval + +--- + +## Deployment Setup - Test/Production Parity + +**Timestamp**: 2026-10-18T19:56:29Z + +**User Input**: "Waarom doen we op de test-omgeving vergelijkbaar met de andere projecten en niet zo dichtbij mogelijk bij de productie-omgeving?" / "Een sub-domein telt als een extra website. In het pakket wat ik wi lheb ik er maar 1 dus het subdomein zal ik op de pi blijven hosten. Uiteindelijk gaat het erom dat de website getest kan worden. Als de deployment anders is omdat de omgeving anders is is dat prima. Als er op test maar niks wordt gedaan wat op productie niet kan of het moet goed gedocumenteerd worden als het gaat om handmatig vs automatisch" + +**AI Response**: "Acknowledged test choice was based on CQ4 and reference projects without explicit parity weighing; explained identical vs different parts and IIS/FTPS-specific risk; offered options. Owner keeps test on Pi. Added 'Test vs Production' section to deployment-plan.md (identical parts, difference table with automatic/manual per aspect, IIS risk mitigation via dress rehearsal before go-live); flagged symlink rollback as test-only capability in plan and rollback-plan.md; added dress-rehearsal step to go-live in deployment-instructions.md." + +**Context**: OPERATIONS - Deployment Setup; awaiting approval + +--- + +## Deployment Setup - Simpler Test Deploy + +**Timestamp**: 2026-10-18T20:18:00Z + +**User Input**: "De opzet voor de testomgeving mag simpeler dan de andere apps. hij hoeft geen oud eversies tebewaren. het is maar een testomgeving. De productie site draait wel daar, maar dat is een wordpress website dus dat moet niet gaan conflicteren" + +**AI Response**: "Interpreted 'daar' as the Raspberry Pi. Replaced release folders + symlink with empty-and-copy deploy to DEPLOY_PATH_TEST; added guard refusing empty path, '/', paths with spaces, or folders containing wp-config.php/wp-content (verified locally on 5 cases incl. a WordPress folder left intact). nginx test block root /var/www/andreaslop-test, never default_server (test added). Rollback on test now same pipeline route as production. Updated deployment-plan (D8, D13, difference table incl. WordPress neighbour), deployment-instructions 1.2, rollback-plan. Lint, format, tests pass." + +**Context**: OPERATIONS - Deployment Setup; awaiting approval + +--- + +## Deployment Setup - Test Path + +**Timestamp**: 2026-10-18T21:13:04Z + +**User Input**: "in het plan zie ik staan /var/ww/andreaslop-test, maar het moet worden /var/ww/html/andreaslop-test" + +**AI Response**: "Interpreted as /var/www/html/andreaslop-test. Replaced in serverConfig.ts (nginx root), regenerated deploy/nginx/andreaslop-test.conf, deployment-instructions.md (variable example, mkdir/chown). Config tests pass. Flagged: if /var/www/html is the WordPress web root, the test folder becomes reachable as a subfolder of the WordPress site; asked owner to confirm WordPress root." + +**Context**: OPERATIONS - Deployment Setup; awaiting approval + +--- + +## Deployment Setup - nginx Config Location + +**Timestamp**: 2026-10-18T21:16:29Z + +**User Input**: "Het pad naar de config is ` /etc/nginx/conf.d/andreaslop-test.conf` en niet de sites-available folder" + +**AI Response**: "Updated deployment-instructions.md step 1.2: copy to /etc/nginx/conf.d/andreaslop-test.conf (loaded automatically, no sites-enabled symlink), with cp command and note to re-copy after pnpm server-config." + +**Context**: OPERATIONS - Deployment Setup; awaiting approval + +--- + +## Deployment Setup - Reverse Proxy Check + +**Timestamp**: 2026-10-18T21:18:22Z + +**User Input**: "op de eigen server draai ik een raspbedrry pi met nginx als reverse proxy. Daar laat ik ook de ssl certificaten genereren met certbot/lets encrypt. Dan op de hostende server zorge ik dat de boel naar de juiste folder gaat. Klopt dan de huidige configuiratie nog?" + +**AI Response**: "Reviewed chain proxy (TLS, certbot) -> hosting Pi nginx :80 -> folder. Config holds; two additions: proxy must pass Host header (else default block = WordPress answers), and absolute_redirect off on the backend so nginx redirects stay relative behind the proxy. Added absolute_redirect off + comment to serverConfig.ts generator with a test, regenerated deploy/nginx/andreaslop-test.conf; added proxy server block example, certbot command and 'do not duplicate headers on proxy' to deployment-instructions.md step 1.2.4." + +**Context**: OPERATIONS - Deployment Setup; awaiting approval + +--- + +## Deployment Setup - Reverse Proxy Config File + +**Timestamp**: 2026-10-18T21:20:15Z + +**User Input**: "heb ik voor de reverse proxy, die ook nginx draait, dan ook niet een config bestand nodig? Doe het alleen voor http, certbot maakt daar wel https van met ssl" + +**AI Response**: "Added nginxProxyConf() to the generator: web/deploy/nginx/test.andreaslop.nl.proxy.conf (HTTP only, Host header + X-Forwarded-*, placeholder HOSTING_PI_ADDRESS, no security headers). Tests: Host header present, no add_header, same server_name as test block (regex anchored after a comment false match). Instructions 1.2.4 now install this file, replace placeholder, run certbot, and warn not to re-copy after certbot. Deployment plan D11 and difference table updated. 14 config tests pass." + +**Context**: OPERATIONS - Deployment Setup; awaiting approval + +--- + +## Deployment Setup - Test Fix + +**Timestamp**: 2026-10-18T21:20:55Z + +**User Input**: "(none — self-review)" + +**AI Response**: "Found that the hostname test passed vacuously: sed dropped the backslash (^s* instead of ^\s*), so both matches were undefined. Fixed regex, asserted the proxy hostname is test.andreaslop.nl, and verified by mutation that a differing hostname makes the test fail. 14 config tests pass, format clean." + +**Context**: OPERATIONS - Deployment Setup; awaiting approval + +--- + +## Deployment Setup - Hosting Pi Address + +**Timestamp**: 2026-10-18T21:23:42Z + +**User Input**: "Ik heb HOSTING_PI_ADDRESS ingevuld in het test config bestand. die kan je voor de volgende kee rook aanhouden" + +**AI Response**: "Owner filled 192.168.1.103 in the generated proxy config; drift test caught it. Moved the address into config/serverConfig.ts (hostingPiAddress), regenerated deploy/nginx/test.andreaslop.nl.proxy.conf (same content), removed placeholder instructions and the sed step from deployment-instructions.md 1.2.4. 14 config tests pass." + +**Context**: OPERATIONS - Deployment Setup; awaiting approval + +--- + +## Deployment Setup - Commit and Push + +**Timestamp**: 2026-10-18T22:18:51Z + +**User Input**: "commit ook de operations changes en push dan. Dan kan ik gaan kijken of de workflow werkt. Werkt dat of moet die workflow eerst op master komen?" + +**AI Response**: "Set up ssh-agent via ~/.ssh/agent.env (owner added key in own Git Bash). Lint, format, 93 tests, build and workflow YAML pass. Committing operations work (pipeline, .gitattributes, server config generator + generated configs, deployment docs) on feature/frontend-shell and pushing the branch to origin." + +**Context**: OPERATIONS - Deployment Setup; commit and push for pipeline verification + +--- diff --git a/aidlc-docs/features/frontend-shell/operations/deployment/deployment-instructions.md b/aidlc-docs/features/frontend-shell/operations/deployment/deployment-instructions.md new file mode 100644 index 0000000..5899357 --- /dev/null +++ b/aidlc-docs/features/frontend-shell/operations/deployment/deployment-instructions.md @@ -0,0 +1,124 @@ +# Deployment Instructions — frontend-shell + +Pipeline: [`.gitea/workflows/continuous_integration.yaml`](../../../../../.gitea/workflows/continuous_integration.yaml). + +## 1. One-time setup + +### 1.1 Gitea repository settings +In Gitea, under **Repository → Settings → Actions**: + +**Secrets** (encrypted): + +| Name | Value | +|---|---| +| `PI_MAIN_ADDRESS` | Address of the Pi as reachable from the runner (same as in your other projects) | +| `PI_MAIN_PORT` | SSH port | +| `PI_MAIN_USERNAME` | SSH user | +| `PI_MAIN_PASSWORD` | SSH password (see 1.4 for switching to a key) | +| `FTP_HOST` | Domain or A-record IP of the hosting space (control panel) | +| `FTP_USERNAME` | FTP account **including** the FTP prefix | +| `FTP_PASSWORD` | Password of that FTP account | + +**Variables** (not secret): + +| Name | Example | Required | +|---|---|---| +| `DEPLOY_PATH_TEST` | `/var/www/html/andreaslop-test` | yes | +| `HEALTH_CHECK_URL_TEST` | `https://test.andreaslop.nl/` | no; without it the post-deploy check is skipped | +| `HEALTH_CHECK_URL_PRODUCTION` | `https://andreaslop.nl/` | no; set it only once the DNS points to the new host | +| `FTP_REMOTE_DIR` | `wwwroot` | no; default `wwwroot` | + +Check that Actions is enabled for the repository. The global runner `raspberry-pi-arm64` picks up `runs-on: ubuntu-latest`. + +### 1.2 Test server (Raspberry Pi with nginx) +The current WordPress site runs on the same Pi. The test site gets its **own folder** and its **own nginx block**, and touches nothing of WordPress. + +1. Create a separate folder, **not** inside the WordPress folder: + ```bash + sudo mkdir -p /var/www/html/andreaslop-test + sudo chown /var/www/html/andreaslop-test + ``` + Every deploy empties this folder first. The pipeline refuses a folder with `wp-config.php` or `wp-content` in it. +2. Copy [`web/deploy/nginx/andreaslop-test.conf`](../../../../../web/deploy/nginx/andreaslop-test.conf) to `/etc/nginx/conf.d/andreaslop-test.conf`. nginx loads everything in `conf.d/` automatically, so no symlink is needed. Adjust `server_name` and `root` if needed. + ```bash + sudo cp web/deploy/nginx/andreaslop-test.conf /etc/nginx/conf.d/andreaslop-test.conf + ``` + After `pnpm server-config` changes the file, copy it again (manual step; see "Test vs Production" in the deployment plan). + - The block answers only the test hostname, and never acts as `default_server`, so WordPress keeps getting its own requests. + - Do not change the WordPress server block. +3. Run `sudo nginx -t && sudo systemctl reload nginx`. +4. On the reverse-proxy Pi, install the HTTP-only proxy config [`web/deploy/nginx/test.andreaslop.nl.proxy.conf`](../../../../../web/deploy/nginx/test.andreaslop.nl.proxy.conf). It forwards the test hostname to the hosting Pi. + - The **`Host` header is required**, and the file sets it. The hosting Pi uses it to choose between the WordPress block and the test block; without it the request lands on the default block (WordPress). + - The hosting Pi's address (`192.168.1.103`) is set in `config/serverConfig.ts`. Change it there and run `pnpm server-config`, never in the generated file. + ```bash + sudo cp test.andreaslop.nl.proxy.conf /etc/nginx/conf.d/test.andreaslop.nl.conf + sudo nginx -t && sudo systemctl reload nginx + ``` + Then let certbot add TLS and the HTTP→HTTPS redirect. certbot edits this file on the proxy: + ```bash + sudo certbot --nginx -d test.andreaslop.nl + ``` + - **Only copy the file once.** Copying it again overwrites certbot's HTTPS changes. If the repository version ever changes, copy it and run `certbot --nginx -d test.andreaslop.nl` again. + Do **not** add the security headers or `X-Robots-Tag` on the proxy too. The hosting Pi already sets them, and setting them twice makes browsers see duplicate headers. +5. Create a DNS record for the test hostname that points to your proxy. + +The folder is empty until the first deploy. Run a deploy before testing. + +### 1.3 Production (MijnHostingPartner) +1. In the control panel, create an FTP account for the website. Use its full username, prefix included, in `FTP_USERNAME`. +2. Check that TLS is available for FTP. If it isn't, open a ticket (per the hoster's knowledge base); the pipeline refuses plain FTP. +3. Set up the domain `andreaslop.nl` in the package, but **do not change the DNS yet** (D12). + +### 1.4 Later: SSH key instead of a password (recommended) +Create a deploy key, put the public key in `~/.ssh/authorized_keys` on the Pi, and store the private key as the secret `PI_MAIN_SSH_KEY`. In the `deploy-test` job, replace `sshpass -e` with `ssh -i`. This is the same change as in your other projects. + +### 1.5 Line endings (once, after pulling this change) +`.gitattributes` makes Git use LF. Refresh your working copy once: +```bash +git rm --cached -r -q . && git reset --hard +``` +**Warning**: this throws away uncommitted changes. Commit or stash first. + +## 2. Day to day + +### Feature work +1. `git switch -c feature/` from `master`, work, push. +2. Open a pull request. CI runs: lint, format, tests, build, audit and Lighthouse. +3. Want to see it on test before merging? Go to **Actions → Continuous Integration → Run workflow**, pick your branch, tick **Deploy to Test**. +4. Merge the PR. `master` is deployed to test automatically. + +### Release to production +1. Cut a release branch from `master`: `git switch -c release/1.0 master`, then `git push -u origin release/1.0`. +2. Check it on test: run the workflow on `release/1.0` with **Deploy to Test**. +3. Deploy: run the workflow on `release/1.0` with **Deploy to Production**. The job only runs on `release/*` branches. +4. Afterwards, merge `release/1.0` back into `master` (PR) and tag the merge commit: + ```bash + git switch master && git pull + git tag -a v1.0.0 -m "Release 1.0.0" && git push origin v1.0.0 + ``` +5. A fix on a release goes to the release branch first, and is deployed and merged back the same way (tag `v1.0.1`). + +### Go-live (once) +1. **Dress rehearsal on the production host.** This is the only place IIS and FTPS are tested; test runs nginx (see "Test vs Production" in the deployment plan). + - Run a production deploy. + - Without changing DNS, open the new host via a temporary `hosts` entry (` andreaslop.nl`) or the hoster's preview URL. + - Check: + - the home page and a deep link (`/portfolio`) + - an unknown URL (the 404 page) + - the five security headers (`curl -sI`) + - that HTTP redirects to HTTPS + - Remove the `hosts` entry afterwards. +2. Switch the DNS of `andreaslop.nl` (and `www`) to the new host, and make sure HTTPS is active. +3. Set `HEALTH_CHECK_URL_PRODUCTION` so every deploy is checked from then on. +4. Verify the live headers: `curl -sI https://andreaslop.nl/` must show all five security headers. + +## 3. If something fails + +| Symptom | Likely cause | Fix | +|---|---|---| +| `Install Chromium` fails | Playwright cannot install its dependencies in the runner image | Look at the log for the missing package. As a fallback, run Lighthouse locally (`pnpm lighthouse`) and make the CI job optional; report it so we can fix it properly. | +| Lighthouse: "Chrome could not be started" | Sandbox | `LIGHTHOUSE_CHROME_FLAGS` must contain `--no-sandbox` (already set). | +| `Format` fails only in CI | Line endings | See 1.5. | +| `sshpass`: Permission denied | Wrong secret, or special characters | Secrets go via `env:` (already so); check the values. | +| `lftp`: certificate verification failed | Hostname does not match the hoster's certificate | Use the hostname from the control panel in `FTP_HOST`, not the IP. | +| Health check fails, page is 404 on deep links | SPA fallback missing | Production: `web.config` not uploaded or URL Rewrite off. Test: nginx config not active. | diff --git a/aidlc-docs/features/frontend-shell/operations/deployment/deployment-plan.md b/aidlc-docs/features/frontend-shell/operations/deployment/deployment-plan.md new file mode 100644 index 0000000..ded4cfa --- /dev/null +++ b/aidlc-docs/features/frontend-shell/operations/deployment/deployment-plan.md @@ -0,0 +1,87 @@ +# Deployment Plan — frontend-shell + +Decisions: [deployment-setup-plan.md](../plans/deployment-setup-plan.md) ("Q"), [deployment-clarification-questions.md](../plans/deployment-clarification-questions.md) ("CQ"). + +## Overview + +```mermaid +graph LR + Feature["feature/* branch"] -->|"pull request"| CI1["CI: check + Lighthouse"] + Feature -->|"manual, Deploy to Test"| Test["Test: Raspberry Pi nginx"] + CI1 -->|"merge"| Master["master"] + Master -->|"automatic"| Test + Master -->|"branch off"| Release["release/x.y"] + Release -->|"manual, Deploy to Production"| Prod["Production: IIS webhost via FTPS"] + Release -->|"merge back + tag vX.Y.Z"| Master + + classDef branch fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; + classDef ci fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000; + classDef env fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000; + + class Feature,Master,Release branch; + class CI1 ci; + class Test,Prod env; +``` + +Text alternative: feature branches go through a pull request with CI into master; master deploys to test automatically and any branch can be deployed to test manually; release branches are cut from master, deployed to production manually, then merged back into master and tagged. + +## Decisions + +| # | Decision | Source | +|---|---|---| +| D1 | **CI**: Gitea Actions on the existing global runner `raspberry-pi-arm64` (labels `linux-arm64`, `ubuntu-latest`; Podman). | Q2 = A, Q3 = A, CQ5 | +| D2 | **Branching**: `master` + short-lived `feature/*` + `release/*`, no `develop` (trunk-based with release branches). Releases are merged back into `master` and tagged `vX.Y.Z` there. | CQ1 | +| D3 | **Environments**: test and production. | Q5 = B | +| D4 | **Test deploy**: automatically on every push to `master` (incl. a merged PR), and manually from any branch with "Deploy to Test", for example to try a branch before merging. | Q6 = B, CQ1 | +| D5 | **Production deploy**: manual only ("Deploy to Production"), and only from a `release/*` branch; the workflow refuses other branches. | Q6 = B, CQ1 | +| D6 | **Quality gate**: every run does lint, format, tests, build, audit and Lighthouse (mobile + desktop) before any deploy job can start. | Q7 = A | +| D7 | **Chrome for Lighthouse**: Playwright's Chromium (supports linux-arm64), installed in the job with a pinned Playwright version. Not the browser on the host: jobs run in containers and cannot see it. | CQ5 | +| D8 | **Test target**: Raspberry Pi with nginx behind the reverse-proxy Pi, **next to the current WordPress site**. Deploy over SSH (`sshpass` + `scp`, same secrets as your other projects). Simple: empty the test folder, then copy the new build in; no old versions are kept. The step refuses an empty path, `/`, or a folder containing WordPress (`wp-config.php` / `wp-content`). The nginx block has its own `server_name` and never `default_server`. | CQ4 = B; owner: simpler than other apps, must not conflict with WordPress | +| D9 | **Test is never indexed**: `X-Robots-Tag: noindex, nofollow` and a `robots.txt` that disallows everything. | Derived | +| D10 | **Production target**: MijnHostingPartner ASP.NET Core 10 package (Windows/IIS). Upload with `lftp` over FTP with TLS (forced) to `wwwroot`. Order: all files except `index.html`, then `index.html`, then delete stale files. | Q4, CQ3 = B | +| D11 | **Server config from one source**: generated with `pnpm server-config`, and a test fails if the files drift from the generator.
  • `web/deploy/iis/web.config` (production) and `web/deploy/nginx/andreaslop-test.conf` (test hosting Pi) carry the headers from `config/securityHeaders.ts`.
  • `web/deploy/nginx/test.andreaslop.nl.proxy.conf` (reverse-proxy Pi) is HTTP only, sets no headers, and certbot adds HTTPS to it.
| NFR-SEC-01/02 | +| D12 | **Go-live**: the production pipeline is ready, but the DNS of `andreaslop.nl` keeps pointing to the current host until the pages have content. Deploying to the new host does not affect the live site until the DNS switch. | CQ2 = A | +| D13 | **Rollback**: redeploy a previous version through the pipeline, the same way on test and production. See [rollback-plan.md](rollback-plan.md). | Q8 = B | +| D14 | **Line endings**: `.gitattributes` with `eol=lf`, so the runner and every machine see the same files and Prettier passes. | Derived | +| D15 | **Versions pinned**: Node 24 in CI; pnpm via `packageManager` (`pnpm@12.11.2`, also pinned in the lockfile); Playwright 1.55.0. | SECURITY-10 | + +## Test vs Production + +A subdomain counts as an extra website in the hosting package (only one is included), so test stays on the Raspberry Pi. The goal of test is that **the site can be tested**. Deployment may differ because the environments differ. The rule: +- Nothing happens on test that cannot happen on production, unless it is listed here. +- For every difference it is stated whether it is automatic or manual. + +### Identical on both +- **Build**: one artifact per run, deployed unchanged to both environments. +- **Security headers and SPA fallback**: generated from the same source (`config/securityHeaders.ts`) into the nginx and IIS config; a test fails if they drift. +- **Unknown URLs**: return the app (HTTP 200), which shows the 404 page. +- **Quality gate**: lint, format, tests, build, audit and Lighthouse before every deploy. +- **Caching**: `index.html` is never cached; files in `/assets` (hashed names) are cached for a year. + +### Differences + +| Aspect | Test (Raspberry Pi, nginx) | Production (webhost, IIS) | Automatic / manual | +|---|---|---|---| +| Deploy trigger | Automatic on push to `master`; manual from any branch | Manual only, from `release/*` | By design | +| Transport | SSH/scp | FTP with TLS (`lftp`) | Both automatic in the pipeline | +| Upload method | Empty the test folder, then copy the build (a few seconds offline; fine for test) | Upload over the existing files: first all files except `index.html`, then `index.html`, then delete stale files (no offline moment) | Both automatic | +| Rollback | Redeploy a previous version through the pipeline (manual start) | Same: redeploy a previous version through the pipeline (manual start) | Identical route; see [rollback-plan.md](rollback-plan.md) | +| Neighbours on the server | The current WordPress site (andreaslop.nl) runs on the same Pi; the test site has its own folder and nginx block | The hosting package has only this site | Guard in the deploy step (automatic); nginx block installed by hand once | +| Server config | `deploy/nginx/andreaslop-test.conf` on the hosting Pi and `deploy/nginx/test.andreaslop.nl.proxy.conf` on the proxy Pi (then certbot), each installed **once by hand** | `deploy/iis/web.config`, uploaded **automatically** with every deploy | Re-install the nginx config by hand after `pnpm server-config` changes it | +| Indexing | `noindex` header + `robots.txt` that blocks everything (test only) | Normal: `robots.txt` and `sitemap.xml` from the build | Automatic | +| HTTPS | Terminated on the reverse-proxy Pi; redirect is the proxy's job | `web.config` redirects HTTP to HTTPS; certificate from the hoster | Test: proxy config, manual | +| Compression | nginx gzip settings of the Pi | Whatever IIS at the hoster does | Not managed by this project; may make Lighthouse scores differ slightly | +| Post-deploy check | `HEALTH_CHECK_URL_TEST` | `HEALTH_CHECK_URL_PRODUCTION` (set after go-live) | Automatic once the variable is set | + +### Covering the IIS-specific risk +Only production runs IIS and FTPS. A mistake in `web.config` or in the upload would therefore first show up there. Until go-live the DNS still points to the old host, so production can serve as a **dress rehearsal**: deploy, then test the new host before switching DNS (deployment-instructions.md, Go-live step 1). After go-live, every release follows the same route, and the post-deploy check verifies reachability and headers. + +## Later: when the .NET API arrives +- The hosting package has one website. The API (from its own project) will then serve this site as static files. That replaces `web.config`: the API sets the same headers (from the same list) and the SPA fallback in ASP.NET Core. +- **Database migrations**: run them in the pipeline before the new API goes live. Keep them backward compatible (expand/contract) and fix problems by rolling forward. Take a backup before each production migration. See the rollback plan. + +## Not verified yet (needs the first real runs) +These depend on the runner and the hoster and could not be tested from this machine: +1. Playwright's Chromium installs and starts in the runner container (`linux-arm64`). +2. `lftp` with forced TLS is accepted by the hoster's certificate. If the certificate does not match the hostname, the fix is to connect with the hostname from the hoster's control panel, not to turn verification off. +3. The SSH user on the Pi may write to and empty `DEPLOY_PATH_TEST`. diff --git a/aidlc-docs/features/frontend-shell/operations/deployment/rollback-plan.md b/aidlc-docs/features/frontend-shell/operations/deployment/rollback-plan.md new file mode 100644 index 0000000..642a27b --- /dev/null +++ b/aidlc-docs/features/frontend-shell/operations/deployment/rollback-plan.md @@ -0,0 +1,31 @@ +# Rollback Plan — frontend-shell + +Principle (Q8 = B): roll back by **deploying a previous version through the pipeline**. The site is static: there is no state or database to undo. + +## Test environment + +Old versions are not kept on test (keeping it simple). To go back, run the workflow on the branch, commit or tag you want, with **Deploy to Test**. This is the same route as production, so a rollback on test is also a rehearsal for production. + +## Production + +1. **Choose the version.** That is the previous tag (for example `v1.0.0`) or the release branch from before the faulty change. +2. **Deploy it.** If the release branch still exists at that version, run the workflow on it with **Deploy to Production**. Otherwise create a branch from the tag first: + ```bash + git switch -c release/1.0-rollback v1.0.0 && git push -u origin release/1.0-rollback + ``` + Then deploy that branch. Production deploys are only allowed from `release/*`, which is why the branch is needed. +3. **Check the result.** The pipeline's post-deploy check verifies reachability and the CSP header. Also open a deep link (for example `/portfolio`) and the home page. +4. **Fix forward.** Fix the problem on the release branch and deploy again as a new patch version. + +**Emergency (pipeline unavailable):** run `pnpm build` locally from the tag, copy `web/deploy/iis/web.config` into `dist/`, and upload `dist/` with FileZilla to `wwwroot`. Use "FTP over explicit TLS", and upload `index.html` last. + +## Before go-live +As long as the DNS points to the current host (D12), a broken production deploy affects no visitors. Fix it and deploy again. + +## Later: with the .NET API and a database +- **Code**: roll back the same way, by deploying the previous version. +- **Database**: do **not** roll back with "down" migrations, because they can destroy data. Instead: + - Make migrations backward compatible (expand/contract), so the previous API version still works on the new schema. + - Back up the database (or export it; the package allows 50 MB) before every production migration. The pipeline can do this as a step. + - Fix errors in data or schema with a new migration (roll forward). +- **Restore from backup** only as a last resort, when data was damaged. diff --git a/aidlc-docs/features/frontend-shell/operations/plans/deployment-clarification-questions.md b/aidlc-docs/features/frontend-shell/operations/plans/deployment-clarification-questions.md new file mode 100644 index 0000000..82131af --- /dev/null +++ b/aidlc-docs/features/frontend-shell/operations/plans/deployment-clarification-questions.md @@ -0,0 +1,89 @@ +# Deployment Clarification Questions — frontend-shell + +Je antwoorden in [deployment-setup-plan.md](deployment-setup-plan.md) brengen een paar keuzes boven die ik niet zelf kan maken. Vul per vraag de letter in na `[Answer]:`. + +Wat ik van de hoster weet ([pakketpagina](https://www.mijnhostingpartner.nl/pg/info/aspnet-core-hosting/)): Windows-hosting met **URL Rewrite**, dus IIS. Security headers en de SPA-fallback gaan daar via een `web.config` naast `index.html`. Over FTP/SFTP/SSH staat niets op de pagina. + +--- + +## Vraag 1: Branchstrategie + +Je vroeg om advies over gitflow tegenover trunk-based. + +**Gitflow**: `develop` voor lopend werk, `release/x.y`-branches voor een release, en daarna terugmergen naar `develop` én `master`, met een tag. Bedacht voor teams die meerdere versies tegelijk onderhouden of op vaste momenten releasen. Voor één ontwikkelaar levert het vooral extra merges op, en kans op merge-conflicten tussen `develop` en `master`. + +**Trunk-based (lichte variant)**: `master` is altijd releasebaar. Werk gebeurt in korte feature-branches die via een pull request naar `master` gaan, zoals je nu al doet. Een release is een **tag** op `master` (bv. `v1.2.0`). + +Mijn advies voor jouw situatie (één ontwikkelaar, een test- en een productieomgeving) is **trunk-based met release-tags**. Het past bij hoe je nu werkt, en alles wat je met gitflow wilde blijft mogelijk: + +| Jouw wens | Trunk-based met tags | +| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | +| Altijd en snel naar test, ook een specifieke versie | Handmatige "Deploy naar test" in Gitea met keuze van branch, commit of tag. Daarnaast automatisch bij elke merge naar `master`. | +| Productie alleen vanuit een release | Productie alleen vanaf een tag `v*`, handmatig gestart in Gitea | +| Een vaste versie kunnen terugzetten | Elke tag is een vaste versie; terugzetten is die tag opnieuw deployen | + +A) Trunk-based met release-tags **(aanbevolen)** +B) Gitflow zoals je beschreef: `develop`, `release/*`, `master` met tags. Productie alleen vanaf `release/*`. +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: x, ik wil een mix welke volgens mij nog steeds dichter bij trunk-based ligt. Ik wil release en feature branches om het werk nog wel geisoleerd te houden. Mocht het helemaal kapot gaan kan je de branch weggooien en zo kan ik nog steeds PR's gebruiken als jij dingen oppakt. Dan kan ik makkelijker de PR checken voor de veranderingen en bij mergen van de PR kan een test-release gedaan worden. Maar ik wil dan de develop branch er tussenuit halen. Ik ben volgens mij vergeten aan te geven dat na het succesvol mergen van een PR een workflow moet worden gestart met een deploy naar test als automatische deploy. Een deploy naar test moet ook handmatig kunnen om op test te kunnen deployen om iets te testen voordat de PR wordt gemerged. + +## Vraag 2: Wanneer gaat de nieuwe site live? + +De eerste deployment naar productie vervangt wat er nu op `andreaslop.nl` staat. De nieuwe site heeft nog alleen placeholderpagina's ("in de maak"). + +A) De productie-pipeline nu bouwen en testen, maar de eerste echte productie-deployment pas starten als de pagina's inhoud hebben. Tot die tijd alleen de testomgeving. **(aanbevolen)** Door de handmatige start kan het niet per ongeluk gebeuren. +B) Zodra de pipeline werkt live gaan, ook met placeholders +C) De huidige site staat ergens anders; productie op deze hoster is nog leeg +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A, mogelijk kan het eerder worden gedeployed, maar dat kan ook handmatig gestart worden. De huidige site staat op een andere host dus als ik de DNS daar nog naar toe verwijs zou het geen impact moeten hebben. + +## Vraag 3: Hoe komen de bestanden bij de productiehoster? + +Kijk in het hostingpaneel welke toegang je hebt. + +A) SFTP **(aanbevolen als beschikbaar)** Versleuteld en eenvoudig vanuit de pipeline. +B) Alleen FTP met TLS (FTPS) +C) Alleen gewone FTP (onversleuteld). Werkt, maar dan gaat het wachtwoord onversleuteld over het internet; liever niet. +D) Web Deploy (msdeploy), als de hoster dat aanbiedt +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: B, Meer info op: https://www.mijnhostingpartner.nl/client/knowledgebase/ftp/ftp-verbinding-opzetten/ + +## Vraag 4: Wat draait er op je testserver? + +De testomgeving moet zich zoveel mogelijk als productie gedragen (headers, SPA-fallback). + +A) Windows met IIS, net als productie. Dan gebruik ik dezelfde `web.config` en dezelfde deploymethode. +B) Linux met een webserver (nginx, Apache of Caddy), bereikbaar via SSH. Dan stel ik een gelijkwaardige config op, en deploy ik via SSH/rsync. +C) Linux, maar alleen via SFTP bereikbaar +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: B, maar dan een raspberry pi server met Nginx die weer achter een andere Raspberry pi zit die als reverse proxy is ingesteld. + +## Vraag 5: Chrome voor Lighthouse in de pipeline + +Je runner draait de jobs waarschijnlijk in **Docker-containers**; dat is de standaard bij `act_runner`. Een Chrome die op de server zelf staat, is dan in de container niet zichtbaar. + +A) De pipeline installeert zelf Chromium in de job (één regel, vaste versie uit de Debian-repository). Werkt ongeacht wat er op de server staat. **(aanbevolen)** +B) De runner draait jobs direct op de server (host-modus), en dan gebruik ik de Chrome die daar staat +C) Weet ik niet. Ik zoek de runner-labels op in Gitea (Site Administration of Settings → Actions → Runners) en vul ze hieronder in. +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: Ik denk B, De runner is `raspberry-pi-arm64` met versie v2.1.0, is een Global runner met de labels linux-arm64 en ubuntu-latest. Kijk in `K:\Development\SlpSoftware\Projects\SlpSoftware` en `K:\Development\Projects\SlpModularCms` hoe het dara gedaan is. Dat draait er nu ook, maar bedenk dat die wel volledig op de eigen server draaien dus nmiet alles klakkeloos overnemen. + +--- + +## Ter info: databasemigraties en terugdraaien (je vraag bij Vraag 8) + +Dit speelt pas als de API er is, maar het antwoord bepaalt nu al de aanpak: + +- **Migraties via de pipeline kunnen.** Met Entity Framework Core maak je bij het bouwen een migratiescript of "migration bundle". De pipeline voert dat uit vóór de nieuwe API live gaat. +- **Databasemigraties terugdraaien is riskant.** Een "down"-migratie kan data weggooien, bijvoorbeeld bij een verwijderde kolom. Gangbaar is daarom: + - **Achterwaarts compatibele migraties** (expand/contract). Een kolom hernoemen gaat in twee releases: eerst de nieuwe kolom erbij, en pas later de oude weg. De vorige versie van de API werkt dan nog met de nieuwe database. + - **Terugdraaien** = de vorige versie van de code deployen, met de database zoals die is (jouw keuze B). + - **Echte fouten in data of schema** los je op met een nieuwe migratie vooruit ("roll forward"), niet door terug te draaien. +- **Kleine database (50 MB)**: maak vóór elke productiemigratie een back-up of export; de pipeline kan dat aanroepen. + +Dit neem ik op in het rollback-plan als richtlijn voor de API-feature. Voor de huidige statische site is terugdraaien simpelweg de vorige tag opnieuw deployen. diff --git a/aidlc-docs/features/frontend-shell/operations/plans/deployment-setup-plan.md b/aidlc-docs/features/frontend-shell/operations/plans/deployment-setup-plan.md new file mode 100644 index 0000000..9d86997 --- /dev/null +++ b/aidlc-docs/features/frontend-shell/operations/plans/deployment-setup-plan.md @@ -0,0 +1,108 @@ +# Deployment Setup Plan — frontend-shell + +## Context + +- **Code**: `web/` (static SPA). `pnpm build` produces `dist/`. `pnpm check` runs lint, format, tests, build, audit and Lighthouse. +- **Git hosting**: self-hosted Gitea at `gitea.slpsoftware.nl`. There is no CI configuration yet (`.gitea/workflows` and `.github` do not exist). +- **Back-end**: `api/` exists but is empty; the .NET API comes later. +- **Carried-forward requirements**: + - `pnpm check` runs on every push (NFR follow-up 1). + - The production host sends the security headers (NFR-SEC-01/02). + - The SPA fallback: every unknown path serves `index.html`, so deep links like `/portfolio` work. + +## Plan + +- [x] 1. Answer the questions below +- [x] 2. Analyze answers (follow-up questions if needed) +- [x] 3. Generate `operations/deployment/deployment-plan.md` +- [x] 4. Generate the pipeline definition(s) in the repository, plus `operations/deployment/deployment-instructions.md` +- [x] 5. Generate `operations/deployment/rollback-plan.md` +- [x] 6. Fix line endings (see below) and verify the pipeline steps locally + +## Already decided (no question needed) + +- **Line endings**: a `.gitattributes` with `* text=auto eol=lf` (binary files excepted). + - Today Git converts files to Windows line endings (CRLF) on checkout, while Prettier requires LF. A fresh checkout on Windows can therefore fail `pnpm check`, and the CI runner and your machine would see different files. + - Your editor keeps working as before; files are simply stored and checked out with LF everywhere. +- **Pipeline order**: install with the lockfile, then `pnpm check`. Deployment only happens when that passes. +- **Secrets**: deployment credentials go in Gitea's encrypted Actions secrets, never in the repository. + +--- + +## Questions + +Vul per vraag de letter in na `[Answer]:`. Past geen enkele optie, kies dan de laatste (Anders) en licht toe. Waar ik een voorkeur heb staat **(aanbevolen)**. + +### Vraag 1: Deployment opzetten voor deze feature? + +A) Ja, help me deployment op te zetten +B) Nee, deployment gebeurt elders of is niet nodig +C) Weet ik niet, stel een aanpak voor en ik beslis +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +### Vraag 2: Welk CI-systeem? + +Gitea heeft een ingebouwd CI-systeem, **Gitea Actions**, met dezelfde workflow-syntax als GitHub Actions. Het heeft wel een **runner** nodig: een klein programma (`act_runner`) op een server, dat de jobs uitvoert. + +A) Gitea Actions **(aanbevolen)** Zit in je Gitea, geen extra dienst, en de workflows zijn later eenvoudig naar GitHub over te zetten. +B) Een aparte CI-dienst (bv. Woodpecker, Jenkins) +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +### Vraag 3: Is er al een runner voor Gitea Actions? + +A) Ja, er draait al een runner die ik voor dit project kan gebruiken +B) Nee. Neem in de instructies op hoe ik er een opzet (met Docker op een eigen server of pc) **(aanbevolen als er nog geen is)** +C) Weet ik niet, ik controleer het +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +### Vraag 4: Waar wordt de website gehost? + +A) Op een eigen server (bv. dezelfde als Gitea), met een webserver zoals Caddy of nginx. De pipeline zet de bestanden er via SSH/rsync neer. Volledige controle over security headers en de SPA-fallback. **(aanbevolen als je een eigen server hebt)** +B) Bij een webhoster met FTP/SFTP-toegang, bijvoorbeeld waar de huidige statische site staat. Headers en fallback dan via `.htaccess` (Apache), als de hoster dat toestaat. +C) Een static-hostingdienst (bv. Cloudflare Pages, Netlify, of een Europese variant). Weinig beheer, headers via een configbestand. +D) Nog niet bekend: zet nu alleen de CI op (bouwen en testen bij elke push) en de deployment later +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: X, voor productie wordt dat een webhoster met ftp/sftp toegang. Voor de testomgeving heb ik een eigen server, maar heb ik eventueel ook toegang met ftp/sftp. Ik heb alleen maar 1 website die ik kan hosten dus zodra ik de API ga bouwen die uit een ander project gaat komen moet de website als static files worden geserveerd door de API. Dit is een pagina met meer info over de webhost: https://www.mijnhostingpartner.nl/pg/info/aspnet-core-hosting/ en het gaat dan om het ASP.NET Core 10 Hosting pakket + +### Vraag 5: Welke omgevingen? + +A) Alleen productie +B) Test/staging (bv. `test.andreaslop.nl`) en productie. Je ziet een wijziging eerst op test voordat hij live gaat. **(aanbevolen)** +C) Ook een preview per pull request +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: B + +### Vraag 6: Wanneer wordt er gedeployd? + +A) Automatisch: elke merge naar `master` gaat live (en, bij een testomgeving, elke push naar een feature-branch naar test) +B) Automatisch naar test; naar productie pas na een handmatige goedkeuring of start in Gitea **(aanbevolen)** +C) Altijd handmatig starten +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: B, ik wil de gitflow gaan toepassen. Naar test moet altijd kunnen. Zodat er makkelijk en snel een specifieke versie op de test-omgeving gedeployed of geredeployed kan worden. Naar productie mag alleen vanaf een release-branch. DIe branch wordt daarna teruggemerged naar develop en master en op master wordt dan een tag gezet. Ik heb ook van trunk-based gehoord. het zou kunnen dat dat praktischer is. Ik laat mij graag aanbevelen wat handiger is voor mij. + +### Vraag 7: Lighthouse in de pipeline + +`pnpm check` draait ook Lighthouse, en daarvoor moet er Chrome in de runner zitten. Dat maakt de pipeline een paar minuten langer. + +A) Ja, de volledige `pnpm check`, inclusief Lighthouse, in de pipeline. De runner gebruikt een image met Chrome. **(aanbevolen)** Dit was jouw wens: een vergeten lokale check wordt dan alsnog opgevangen. +B) In de pipeline alles behalve Lighthouse; Lighthouse alleen lokaal +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: ik heb een headless browser op de gitea/buildserver staan. Als het goed is is dat chrome, maar niet meer helemaal zeker. + +### Vraag 8: Terugdraaien bij een mislukte release + +A) De server bewaart de laatste paar releases. Terugdraaien is één commando of één klik in Gitea, die terugwisselt naar de vorige release. **(aanbevolen bij een eigen server)** +B) Terugdraaien door de vorige commit opnieuw door de pipeline te laten deployen +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: B als dat kan en ook gezien de database. Ik weet niet of er via de pipeline een migratie kan worden gedaan en ook terug worden gedraaid zodra we een API hebben? diff --git a/web/config/serverConfig.test.ts b/web/config/serverConfig.test.ts new file mode 100644 index 0000000..4fd2c1d --- /dev/null +++ b/web/config/serverConfig.test.ts @@ -0,0 +1,76 @@ +import { readFileSync } from 'node:fs'; +import { describe, expect, it } from 'vitest'; +import { securityHeaders } from './securityHeaders'; +import { + iisWebConfig, + nginxProxyConf, + nginxTestConf, + serverConfigFiles, +} from './serverConfig'; + +describe('serverconfiguratie', () => { + it.each(Object.entries(serverConfigFiles))( + '%s is gelijk aan de generator (draai anders pnpm server-config)', + (path, generate) => { + expect(readFileSync(path, 'utf8')).toBe(generate()); + }, + ); + + it('IIS en nginx zetten elke productieheader', () => { + const iis = iisWebConfig(); + const nginx = nginxTestConf(); + for (const [name, value] of Object.entries( + securityHeaders('production'), + )) { + expect(iis).toContain( + ``, + ); + expect(nginx).toContain(`add_header ${name} "${value}" always;`); + } + }); + + it('IIS heeft een SPA-fallback en een HTTPS-redirect', () => { + const iis = iisWebConfig(); + expect(iis).toContain(''); + expect(iis).toContain(''); + }); + + it('de testsite wordt nooit geindexeerd', () => { + const nginx = nginxTestConf(); + expect(nginx).toContain('X-Robots-Tag "noindex, nofollow"'); + expect(nginx).toContain('Disallow: /'); + expect(nginx).toContain('try_files $uri $uri/ /index.html;'); + }); + + it('het testblok claimt nooit de standaardserver (WordPress op dezelfde Pi)', () => { + expect(nginxTestConf()).not.toMatch(/listen[^;]*default_server/); + }); + + it('houdt doorverwijzingen relatief achter de reverse proxy', () => { + expect(nginxTestConf()).toContain('absolute_redirect off;'); + }); + + it('de proxy geeft de Host-header door en zet zelf geen security headers', () => { + const proxy = nginxProxyConf(); + expect(proxy).toContain('proxy_set_header Host $host;'); + expect(proxy).toContain('server_name test.andreaslop.nl;'); + expect(proxy).not.toContain('add_header'); + }); + + it('proxy en testblok gebruiken dezelfde hostname', () => { + // Alleen echte config-regels, geen commentaar + const name = /^\s*server_name ([^;]+);/m; + const proxyHost = nginxProxyConf().match(name)?.[1]; + expect(proxyHost).toBe('test.andreaslop.nl'); + expect(nginxTestConf().match(name)?.[1]).toBe(proxyHost); + }); + + it('elk nginx location-blok herhaalt de security headers', () => { + // nginx erft add_header niet als een location er zelf een zet + const blocks = nginxTestConf().split('location ').slice(1); + expect(blocks).toHaveLength(3); + for (const block of blocks) { + expect(block).toContain('Content-Security-Policy'); + } + }); +}); diff --git a/web/config/serverConfig.ts b/web/config/serverConfig.ts new file mode 100644 index 0000000..11ed853 --- /dev/null +++ b/web/config/serverConfig.ts @@ -0,0 +1,161 @@ +// Genereert de webserverconfiguratie voor test (nginx op de Raspberry Pi) en +// productie (IIS bij de webhoster) uit dezelfde securityheaders als de Vite +// dev- en preview-server. Zo bestaat de headerset maar op één plek. +// Schrijven: `pnpm server-config`. Een test controleert dat de bestanden in +// deploy/ gelijk zijn aan wat deze functies opleveren. +import { securityHeaders } from './securityHeaders.ts'; + +const generatedNotice = + 'Gegenereerd door web/config/serverConfig.ts (pnpm server-config). Niet handmatig aanpassen.'; + +const xmlAttribute = (value: string) => + value + .replace(/&/g, '&') + .replace(/"/g, '"') + .replace(//g, '>'); + +// IIS (productie): security headers, HTTPS-redirect, SPA-fallback en caching. +// Bestanden in /assets hebben een hash in de naam en mogen lang gecachet +// worden; index.html nooit, zodat een nieuwe release direct zichtbaar is. +export function iisWebConfig(): string { + const headers = Object.entries(securityHeaders('production')) + .map( + ([name, value]) => + ` `, + ) + .join('\n'); + + return ` + + + + + + + + + + + + + + + + + + + + + + + + + +${headers} + + + + + + + + + + + + + + + + +`; +} + +// nginx (test): dezelfde headers, plus noindex zodat de testsite nooit in +// zoekmachines komt. nginx erft add_header niet als een location er zelf een +// zet, daarom staan de headers in elk location-blok. +export function nginxTestConf(): string { + const headers = [ + ...Object.entries(securityHeaders('production')).map( + ([name, value]) => `add_header ${name} "${value}" always;`, + ), + 'add_header X-Robots-Tag "noindex, nofollow" always;', + ]; + const block = (indent: string, extra: string[] = []) => + [...headers, ...extra].map((line) => indent + line).join('\n'); + + return `# ${generatedNotice} +# Test-omgeving op de Raspberry Pi, achter de reverse-proxy-Pi (die TLS afhandelt +# met certbot). De proxy moet de Host-header doorgeven (proxy_set_header Host +# $host), anders kiest nginx hier het standaardblok (WordPress). +# Eigen server-blok naast de WordPress-site: bewust geen default_server, zodat +# dit blok alleen de testhostname beantwoordt. +# Pas server_name en root aan aan de server; de rest komt uit de generator. +server { + listen 80; + server_name test.andreaslop.nl; + root /var/www/html/andreaslop-test; + index index.html; + + # Achter de reverse proxy: doorverwijzingen relatief houden, anders stuurt + # nginx naar zijn eigen http://-adres in plaats van de https-hostname + absolute_redirect off; + +${block(' ', ['add_header Cache-Control "no-cache" always;'])} + + # Testsite nooit indexeren + location = /robots.txt { +${block(' ')} + default_type text/plain; + return 200 "User-agent: *\\nDisallow: /\\n"; + } + + # Bestanden met een hash in de naam: lang cachen + location /assets/ { +${block(' ', ['add_header Cache-Control "public, max-age=31536000, immutable" always;'])} + try_files $uri =404; + } + + # SPA-fallback: onbekende paden krijgen index.html (de router toont de 404) + location / { +${block(' ', ['add_header Cache-Control "no-cache" always;'])} + try_files $uri $uri/ /index.html; + } +} +`; +} + +// nginx op de reverse-proxy-Pi (test): alleen HTTP. certbot voegt daarna +// HTTPS en de redirect toe (certbot --nginx -d test.andreaslop.nl). Geen +// security headers hier: die zet de hosting-Pi al, dubbel geeft dubbele headers. +// Intern adres van de hosting-Pi (waar het testblok en WordPress draaien) +const hostingPiAddress = '192.168.1.103'; + +export function nginxProxyConf(): string { + return `# ${generatedNotice} +# Reverse proxy voor de testsite naar de hosting-Pi. certbot past dit bestand +# aan voor HTTPS; kopieer het daarna dus niet opnieuw zonder certbot opnieuw te +# draaien. +server { + listen 80; + server_name test.andreaslop.nl; + + location / { + proxy_pass http://${hostingPiAddress}; + # Verplicht: de hosting-Pi kiest op basis van de hostname tussen het + # testblok en WordPress + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Real-IP $remote_addr; + } +} +`; +} + +export const serverConfigFiles = { + 'deploy/iis/web.config': iisWebConfig, + 'deploy/nginx/andreaslop-test.conf': nginxTestConf, + 'deploy/nginx/test.andreaslop.nl.proxy.conf': nginxProxyConf, +} as const; diff --git a/web/config/writeServerConfig.ts b/web/config/writeServerConfig.ts new file mode 100644 index 0000000..18d3256 --- /dev/null +++ b/web/config/writeServerConfig.ts @@ -0,0 +1,11 @@ +// Schrijft de webserverconfiguratie naar deploy/ (pnpm server-config). +// Draait direct met Node (type stripping), zonder extra tooling. +import { mkdirSync, writeFileSync } from 'node:fs'; +import { dirname } from 'node:path'; +import { serverConfigFiles } from './serverConfig.ts'; + +for (const [path, generate] of Object.entries(serverConfigFiles)) { + mkdirSync(dirname(path), { recursive: true }); + writeFileSync(path, generate()); + console.log(`Geschreven: ${path}`); +} diff --git a/web/deploy/iis/web.config b/web/deploy/iis/web.config new file mode 100644 index 0000000..c9e4ff9 --- /dev/null +++ b/web/deploy/iis/web.config @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/deploy/nginx/andreaslop-test.conf b/web/deploy/nginx/andreaslop-test.conf new file mode 100644 index 0000000..3b0f1e8 --- /dev/null +++ b/web/deploy/nginx/andreaslop-test.conf @@ -0,0 +1,61 @@ +# Gegenereerd door web/config/serverConfig.ts (pnpm server-config). Niet handmatig aanpassen. +# Test-omgeving op de Raspberry Pi, achter de reverse-proxy-Pi (die TLS afhandelt +# met certbot). De proxy moet de Host-header doorgeven (proxy_set_header Host +# $host), anders kiest nginx hier het standaardblok (WordPress). +# Eigen server-blok naast de WordPress-site: bewust geen default_server, zodat +# dit blok alleen de testhostname beantwoordt. +# Pas server_name en root aan aan de server; de rest komt uit de generator. +server { + listen 80; + server_name test.andreaslop.nl; + root /var/www/html/andreaslop-test; + index index.html; + + # Achter de reverse proxy: doorverwijzingen relatief houden, anders stuurt + # nginx naar zijn eigen http://-adres in plaats van de https-hostname + absolute_redirect off; + + add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always; + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-Frame-Options "DENY" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + add_header X-Robots-Tag "noindex, nofollow" always; + add_header Cache-Control "no-cache" always; + + # Testsite nooit indexeren + location = /robots.txt { + add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always; + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-Frame-Options "DENY" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + add_header X-Robots-Tag "noindex, nofollow" always; + default_type text/plain; + return 200 "User-agent: *\nDisallow: /\n"; + } + + # Bestanden met een hash in de naam: lang cachen + location /assets/ { + add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always; + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-Frame-Options "DENY" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + add_header X-Robots-Tag "noindex, nofollow" always; + add_header Cache-Control "public, max-age=31536000, immutable" always; + try_files $uri =404; + } + + # SPA-fallback: onbekende paden krijgen index.html (de router toont de 404) + location / { + add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always; + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-Frame-Options "DENY" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + add_header X-Robots-Tag "noindex, nofollow" always; + add_header Cache-Control "no-cache" always; + try_files $uri $uri/ /index.html; + } +} diff --git a/web/deploy/nginx/test.andreaslop.nl.proxy.conf b/web/deploy/nginx/test.andreaslop.nl.proxy.conf new file mode 100644 index 0000000..87c5851 --- /dev/null +++ b/web/deploy/nginx/test.andreaslop.nl.proxy.conf @@ -0,0 +1,18 @@ +# Gegenereerd door web/config/serverConfig.ts (pnpm server-config). Niet handmatig aanpassen. +# Reverse proxy voor de testsite naar de hosting-Pi. certbot past dit bestand +# aan voor HTTPS; kopieer het daarna dus niet opnieuw zonder certbot opnieuw te +# draaien. +server { + listen 80; + server_name test.andreaslop.nl; + + location / { + proxy_pass http://192.168.1.103; + # Verplicht: de hosting-Pi kiest op basis van de hostname tussen het + # testblok en WordPress + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Real-IP $remote_addr; + } +} diff --git a/web/lighthouserc.cjs b/web/lighthouserc.cjs index 49003bc..7e17ba5 100644 --- a/web/lighthouserc.cjs +++ b/web/lighthouserc.cjs @@ -51,6 +51,13 @@ module.exports = { (path) => origin + path, ), numberOfRuns: 1, + // In de CI-container draait Chrome als root en heeft het + // --no-sandbox nodig (LIGHTHOUSE_CHROME_FLAGS in de workflow). + // Niet via LHCI_COLLECT__SETTINGS__*: dat vervangt alle settings, + // ook de desktop-preset. + settings: { + chromeFlags: process.env.LIGHTHOUSE_CHROME_FLAGS ?? '', + }, }, assert: { assertMatrix: [ diff --git a/web/lighthouserc.desktop.cjs b/web/lighthouserc.desktop.cjs index ff4ce85..79f5ad6 100644 --- a/web/lighthouserc.desktop.cjs +++ b/web/lighthouserc.desktop.cjs @@ -9,7 +9,7 @@ module.exports = { ...base.ci, collect: { ...base.ci.collect, - settings: { preset: 'desktop' }, + settings: { ...base.ci.collect.settings, preset: 'desktop' }, }, assert: { assertMatrix: [ diff --git a/web/package.json b/web/package.json index b7414e3..08ec740 100644 --- a/web/package.json +++ b/web/package.json @@ -3,6 +3,7 @@ "private": true, "version": "0.0.0", "type": "module", + "packageManager": "pnpm@12.11.2", "scripts": { "dev": "vite", "build": "tsc && vite build", @@ -17,6 +18,7 @@ "audit:deps": "pnpm audit --prod --audit-level high", "audit:dev": "pnpm audit || echo Meldingen in ontwikkeltools blokkeren niet (NFR-SEC-05)", "lighthouse": "lhci autorun && lhci autorun --config=lighthouserc.desktop.cjs", + "server-config": "node config/writeServerConfig.ts", "check": "pnpm lint && pnpm format:check && pnpm test && pnpm build && pnpm audit:deps && pnpm audit:dev && pnpm lighthouse" }, "devDependencies": { diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index e6540ab..a7a35ee 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -1,3 +1,161 @@ +--- +lockfileVersion: '9.0' + +importers: + + .: + configDependencies: {} + packageManagerDependencies: + pnpm: + specifier: 12.11.2 + version: 12.11.2 + +packages: + + '@pnpm/exe.android-arm64@12.11.2': + resolution: {integrity: sha512-owLw13OfPkEoY+hLBNeeG+dCFhywr7q2d/EHPz4mNL2RhKnv8gNwMARkjkiDQu234aItVwFNDeGnmQXm+ikkAg==} + cpu: [arm64] + os: [android] + + '@pnpm/exe.android-x64@12.11.2': + resolution: {integrity: sha512-GYPkVebl4iokOA/4MPSpGoUVfFlsth7uqOCe1XiaiM23LAdvUOMJBObqHJijr89ZqjwHm9pO6vO45GRwJ2U2qA==} + cpu: [x64] + os: [android] + + '@pnpm/exe.darwin-arm64@12.11.2': + resolution: {integrity: sha512-n9M4On66y8FDxUAKgMO1FXt0qihyG4e+56p3/F0uo8Bx9KplW8BwKVnXigzCJ8aNM6sVVPkOE6M9XXbeVIxnZA==} + cpu: [arm64] + os: [darwin] + + '@pnpm/exe.darwin-x64@12.11.2': + resolution: {integrity: sha512-oSW7n3sBT0c0cyk4kj10T2Y6Mpm+OFEiCAWozgX039tdoI6yqJF1uaFD3sw7ugLdu6VV3+uY0pa1TUZIPdxDWA==} + cpu: [x64] + os: [darwin] + + '@pnpm/exe.freebsd-x64@12.11.2': + resolution: {integrity: sha512-qbzc3KoDpa/Lkf8vs3jnDe6dUUbso+6eLIyssYFMiliLpYNxn8dirk11YoNnOQcdHVB50v5RFls1Yid6ttT5pg==} + cpu: [x64] + os: [freebsd] + + '@pnpm/exe.linux-arm64-musl@12.11.2': + resolution: {integrity: sha512-uMEYDwKRktGwANubQ+kYCwmhNwg3Ik6qK89ahsbQ5cP30R/5FVJb/T99vr9XRUBC/A7mZI6eeT92oyVas9ACyg==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@pnpm/exe.linux-arm64@12.11.2': + resolution: {integrity: sha512-6e8ZAQUwFXAWHHHv5FesWqf/kEK04wuitBv5f/gxzkC0DiBfaixr+f+6JQede8SF4Ji5LcMwVFJbzAtffpWxEg==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-ppc64@12.11.2': + resolution: {integrity: sha512-Ui8A4nepkVupx2VpuFfysEluMvWK6gTB5rgVts7Ss/+8dj0RD28x3F/seNeH/zSypgC6yKdV6qsKVQh/uffTuQ==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-riscv64@12.11.2': + resolution: {integrity: sha512-i1yLdQ5bu+wjQ+srtFoJAaY2gN/+oXHFdjul4llCeoDxHE0rTIG3R41NhHfCjyFPW4+CpbBT58933CL9sMOCnA==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-s390x@12.11.2': + resolution: {integrity: sha512-YS1/lhPjjTsN4QL50VaFZKRa3Uc/bDnhE8eKbJMFvuX06UuFS5YaiDg04APoZdfVSGqTfX27QAg7rfLMSWaqxA==} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-x64-musl@12.11.2': + resolution: {integrity: sha512-7eIxQR05fvJxCujUSKp5KTtehJ7QqrgqP/HD1+BcB/SaV2Be4XI1PEHiOgA1zxsiMIeMvTF6E4G4dYHrFjeXRg==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@pnpm/exe.linux-x64@12.11.2': + resolution: {integrity: sha512-FK7QKe24AYgppJwO3mpooYptduuvIGqKJPi5ac7MdnWkjUy46JBfYhCW0grnkWKC8YOf0x+vGviuQqJEj3SpQQ==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.win32-arm64@12.11.2': + resolution: {integrity: sha512-PCTjVDdJb6VvraZxrEeFv6EqEA0hhIsAySx28e95J2Tqpi88hLpgOXgNqV0vpxq9A+b8GLQfyk/D+1UlJPv/YQ==} + cpu: [arm64] + os: [win32] + + '@pnpm/exe.win32-x64@12.11.2': + resolution: {integrity: sha512-8sgX86OvRjJ3yZs/TvGR2L31wH9ScPZ+f+geKI3ikuB0RRiK3i4LlTRO8OXN6pdRqj8epMde4312MCjj7JsJdA==} + cpu: [x64] + os: [win32] + + pnpm@12.11.2: + resolution: {integrity: sha512-JaUWUqGWeFr18ovabf6NxYLr76SsHRgCIc4TkCMcX7dmN4IupLbkYzznSs3LCnf3Ja8RutOBd/3t2u6BipVcuQ==} + engines: {node: '>=18.*'} + hasBin: true + +snapshots: + + '@pnpm/exe.android-arm64@12.11.2': + optional: true + + '@pnpm/exe.android-x64@12.11.2': + optional: true + + '@pnpm/exe.darwin-arm64@12.11.2': + optional: true + + '@pnpm/exe.darwin-x64@12.11.2': + optional: true + + '@pnpm/exe.freebsd-x64@12.11.2': + optional: true + + '@pnpm/exe.linux-arm64-musl@12.11.2': + optional: true + + '@pnpm/exe.linux-arm64@12.11.2': + optional: true + + '@pnpm/exe.linux-ppc64@12.11.2': + optional: true + + '@pnpm/exe.linux-riscv64@12.11.2': + optional: true + + '@pnpm/exe.linux-s390x@12.11.2': + optional: true + + '@pnpm/exe.linux-x64-musl@12.11.2': + optional: true + + '@pnpm/exe.linux-x64@12.11.2': + optional: true + + '@pnpm/exe.win32-arm64@12.11.2': + optional: true + + '@pnpm/exe.win32-x64@12.11.2': + optional: true + + pnpm@12.11.2: + optionalDependencies: + '@pnpm/exe.android-arm64': 12.11.2 + '@pnpm/exe.android-x64': 12.11.2 + '@pnpm/exe.darwin-arm64': 12.11.2 + '@pnpm/exe.darwin-x64': 12.11.2 + '@pnpm/exe.freebsd-x64': 12.11.2 + '@pnpm/exe.linux-arm64': 12.11.2 + '@pnpm/exe.linux-arm64-musl': 12.11.2 + '@pnpm/exe.linux-ppc64': 12.11.2 + '@pnpm/exe.linux-riscv64': 12.11.2 + '@pnpm/exe.linux-s390x': 12.11.2 + '@pnpm/exe.linux-x64': 12.11.2 + '@pnpm/exe.linux-x64-musl': 12.11.2 + '@pnpm/exe.win32-arm64': 12.11.2 + '@pnpm/exe.win32-x64': 12.11.2 + +--- lockfileVersion: '9.0' settings: