Author SHA1 Message Date
SluijsensandClaude Sonnet 5.5 1f087581d4 Production upload: plain FTP (no FTPS), no web.config from this repo, optional port
Continuous Integration / deploy-production (pull_request) Blocked by required conditions
Continuous Integration / check (pull_request) Successful in 4m12s
Continuous Integration / build-test (pull_request) Skipped
Continuous Integration / deploy-test (pull_request) Skipped
Continuous Integration / lighthouse (pull_request) In progress
The production package only offers plain FTP. The upload goes into the
prerendered-pages folder of the CMS host; the host and its web.config come from
the CMS pipeline.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-18 21:17:04 +01:00
5 changed files with 85 additions and 33 deletions
+8 -6
View File
@@ -369,14 +369,16 @@ jobs:
name: dist
path: web/dist
# FTP met TLS (verplicht) naar de webhoster, in drie rondes (zie
# deploy/upload-production.sh): eerst alles behalve HTML en web.config,
# dan web.config en alle HTML, en pas daarna oude bestanden opruimen. Zo
# verwijst een bezoeker nooit naar een bestand dat er nog niet staat.
# Deze job kan pas draaien als er een webhost is.
- name: Upload naar productie (FTPS)
# Gewone FTP (het productiepakket biedt geen FTPS) naar de map met
# voorgerenderde pagina's van de CMS-host, in drie rondes (zie
# deploy/upload-production.sh): eerst alles behalve HTML, dan alle HTML,
# en pas daarna oude bestanden opruimen. Zo verwijst een bezoeker nooit
# naar een bestand dat er nog niet staat. De host zelf en zijn web.config
# komen uit de CMS-pijplijn. Deze job kan pas draaien als er een webhost is.
- name: Upload naar productie (gewone FTP)
env:
FTP_HOST: ${{ secrets.PROD_HOST_ADDRESS }}
FTP_PORT: ${{ secrets.PROD_HOST_PORT }}
FTP_USER: ${{ secrets.PROD_HOST_USERNAME }}
LFTP_PASSWORD: ${{ secrets.PROD_HOST_PASSWORD }}
FTP_DIR: ${{ vars.PROD_DEPLOY_PATH || 'wwwroot' }}
+1 -1
View File
@@ -51,7 +51,7 @@ The hero of the homepage comes from the CMS hero module (`GET /api/v1/hero`); th
Decision (Bryan, 2026-11-15): the hosting package has one entry per website. The CMS host (Kestrel) is that entry and serves the website itself (the prerendered pages), `/admin` and `/api/v1/*`. In production IIS (or the proxy) therefore passes **all** requests to the CMS host, not only `/api/v1/*`, and serves no static files or HTML cache of its own. This holds for the test host and for ASF production alike.
- **Test (ASF):** nginx on the proxy Pi forwards everything for `test.andreaslop.nl` to the CMS host (`web/deploy/nginx/test.andreaslop.nl.proxy.conf`), which serves the site files and the API. Nothing to add.
- **Production: not in place yet.** The generated `web/deploy/iis/web.config` and the FTP upload of static files (`web/deploy/upload-production.sh`) still describe the old idea of IIS serving the files. They have to change with the production hosting: IIS keeps only the redirects (www, HTTPS) and the pass-through to the CMS host, and the prerendered `dist/` goes to the CMS host's prerendered-pages folder as on test. Security headers then come from the CMS host (as on test). This is part of the production hosting work, not of the packages feature. Until then production builds use the committed snapshot and the live calls fail safely (the baked list stays; the browser console shows a 404 for the API). Change generated server files only in `web/config/serverConfig.ts` and run `pnpm server-config`.
- **Production: not in place yet.** The FTP upload (`web/deploy/upload-production.sh`) is now plain FTP into the CMS host's prerendered-pages folder and no longer puts a `web.config` on the server (the host's own `web.config` comes from the CMS pipeline). The generated `web/deploy/iis/web.config` still describes the old idea of IIS serving the files and has to change with the production hosting: IIS keeps only the redirects (www, HTTPS) and the pass-through to the CMS host, and the prerendered `dist/` goes to the CMS host's prerendered-pages folder as on test. Security headers then come from the CMS host (as on test). This is part of the production hosting work, not of the packages feature. Until then production builds use the committed snapshot and the live calls fail safely (the baked list stays; the browser console shows a 404 for the API). Change generated server files only in `web/config/serverConfig.ts` and run `pnpm server-config`.
- **Host injection (built in the site; the host side is the CMS repo's work):** the build leaves markers in the prerendered pages and the CMS host fills them from live data, so a CMS change is visible to search engines at once without a rebuild. Contract and plan: `aidlc-docs/features/asf-cms-host-injection/plan.md`; golden files for the list HTML: `web/contract/host-injection/`.
- Markers: `<!--CMS:DATA-->` + `<script type="application/json" id="cms-data">` (root document, every page), `<!--CMS:OFFERINGS-HTML-->`, `<!--CMS:BANNER-TOP-HTML-->` and `<!--CMS:BANNER-BOTTOM-HTML-->` regions (home page), `<!--CMS:OFFER-JSON-LD slug="...">` before the ld+json block of the newborn, zwangerschap and gezin pages, and `<span data-cms-price="slug">` in their price block.
- In the page: `CmsRegion` renders the plain HTML between the markers (`lib/cmsHtml.ts`, styled by `.cms-*` rules in `theme.ts`) and React leaves it alone until hydration, so a host that wrote different data causes no hydration mismatch; after hydration the styled components take over. `PackagesProvider` reads the data block in the first render after hydration (`hostCmsData`); a block with `"source":"build"` is the baked one and counts as "no host data", so the page asks the API as before. The site address comes from `siteUrl` in the block (`setSiteUrl` in `client.tsx`), because the script files cannot be rewritten per host.
+4
View File
@@ -72,3 +72,7 @@ Format `{ENV}_{GROUP}_{NAME}` with `ENV` = `TEST` or `PROD`, no app part (this r
Removed: `PI_MAIN_*` (the SSH password login; the old secrets are deleted by Bryan after a green run), `DEPLOY_PATH_TEST`, `HEALTH_CHECK_URL_TEST`, `HEALTH_CHECK_URL_PRODUCTION`, `FTP_REMOTE_DIR`, `FTP_HOST`, `FTP_USERNAME`, `FTP_PASSWORD` (renamed), `ASF_OFFERINGS_URL_TEST` and `ASF_TEST_SERVED_BY_CMS` (no longer needed). The old names in the repo are removed by SLS after a green run.
**Monitoring per build.** Sentry and Umami settings are no longer in the code (`src/monitoring/config.ts`): every build gets them for its own environment and measures only on that environment's host (production build on `andreaslop.nl`, test build on `test.andreaslop.nl`; any other host measures nothing). The CSP origins for Umami and Sentry (`config/securityHeaders.ts`) come from the same variables, so a build without them has neither a measurement nor those origins; the build steps fail when a variable is empty. Unit and browser tests use the production values from `config/monitoringTestEnv.ts` (public values, the same as the variables); `pnpm server-config` does too, so the committed generated files carry the production CSP. The CMS host has its own copy of the origins in its environment (CMS repo).
## Plain FTP to production
The production package only offers plain FTP, no FTPS or SFTP. `deploy/upload-production.sh` therefore never tries TLS (`ftp:ssl-allow no`, passive mode) and sends the user name, the password and the files unencrypted. Measures: a separate FTP account with rights only on the folder of the prerendered pages, a unique strong password that only exists as the secret `PROD_HOST_PASSWORD`, rotating it after the first rollout, and asking the host whether SFTP or explicit FTPS can be switched on. The script uploads in three rounds (everything except HTML, then all HTML, then cleaning up old files) into the prerendered-pages folder of the CMS host (`PROD_DEPLOY_PATH`, the exact folder is still open, see `aidlc-docs/features/asf-production-iis/plan.md`, A2). It does not put a `web.config` there and deletes nothing outside that folder; the host and its `web.config` come from the CMS pipeline. `PROD_HOST_PORT` is optional (default 21).
+21 -13
View File
@@ -1,7 +1,13 @@
#!/usr/bin/env bash
# Upload naar productie in drie rondes (BR-HST-14, 15; FR-PR-18).
# Gebruik: upload-production.sh <dist-map> <doelmap-op-de-server>
# Verbinding: FTP_HOST, FTP_USER en LFTP_PASSWORD uit de omgeving (FTPS).
# De doelmap is de map met voorgerenderde pagina's van de CMS-host; de host
# (en zijn web.config) staat er los van en wordt door de CMS-pijplijn gedeployd.
# Verbinding: FTP_HOST, FTP_USER en LFTP_PASSWORD uit de omgeving, optioneel
# FTP_PORT. Gewone FTP, geen FTPS: het productiepakket biedt alleen dat. De
# gegevens gaan dus onversleuteld over het netwerk (zie docs/deploy-and-ci.md,
# "Plain FTP"); daarom nooit TLS proberen en een eigen FTP-account met rechten
# alleen op deze map.
# Alleen voor de test: LFTP_OPEN (bijvoorbeeld file:///) vervangt de
# verbinding, en UPLOAD_PASS=1|2|3 voert maar één ronde uit.
set -euo pipefail
@@ -36,7 +42,6 @@ done
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
bash "$here/check-artifact.sh" "$dist"
cp "$here/iis/web.config" "$dist/web.config"
pass="${UPLOAD_PASS:-all}"
case "$pass" in
@@ -48,7 +53,7 @@ wants() { [ "$pass" = all ] || [ "$pass" = "$1" ]; }
# Geen back-ups: lftp zet standaard een kopie met een tijdstempel
# (web.config~20261101221045~) naast elk bestand dat het overschrijft. Op de
# host zou elke deploy er een achterlaten, bereikbaar voor wie de naam raadt.
settings="set ftp:ssl-force true; set ftp:ssl-protect-data true; set net:max-retries 3; set xfer:make-backup no;"
settings="set ftp:ssl-allow no; set ftp:passive-mode on; set net:max-retries 3; set xfer:make-backup no;"
# Elke opdracht krijgt een eigen lftp-sessie, zodat het script bij een mislukte
# ronde stopt (set -e) voordat de volgende ronde begint: de HTML gaat nooit
@@ -60,22 +65,25 @@ run_lftp() {
else
: "${FTP_HOST:?FTP_HOST ontbreekt}" "${FTP_USER:?FTP_USER ontbreekt}"
: "${LFTP_PASSWORD:?LFTP_PASSWORD ontbreekt}"
lftp --env-password -u "$FTP_USER" "$FTP_HOST" -e "$commands"
local port=()
if [ -n "${FTP_PORT:-}" ]; then
[[ "$FTP_PORT" =~ ^[0-9]+$ ]] || { echo "Ongeldige FTP_PORT" >&2; exit 2; }
port=(-p "$FTP_PORT")
fi
lftp --env-password -u "$FTP_USER" "${port[@]}" "$FTP_HOST" -e "$commands"
fi
}
# Ronde 1: alles behalve HTML en web.config, dus ook /assets. Nieuwe
# bestanden met hash in de naam storen de oude release niet.
# Ronde 1: alles behalve HTML, dus ook /assets. Nieuwe bestanden met hash in
# de naam storen de oude release niet.
if wants 1; then
echo "== Ronde 1: alles behalve HTML en web.config"
run_lftp "mirror --reverse --verbose --exclude-glob '*.html' --exclude-glob web.config $dist/ $remote/;"
echo "== Ronde 1: alles behalve HTML"
run_lftp "mirror --reverse --verbose --exclude-glob '*.html' $dist/ $remote/;"
fi
# Ronde 2: web.config vlak voor de HTML (de regels passen bij de nieuwe
# bestanden), dan alle HTML, ook de geneste pagina's en 404.html. Pas nu
# verwijst iets naar de nieuwe assets.
# Ronde 2: alle HTML, ook de geneste pagina's en 404.html. Pas nu verwijst
# iets naar de nieuwe assets.
if wants 2; then
echo "== Ronde 2: web.config en alle HTML"
run_lftp "put -O $remote $dist/web.config;"
echo "== Ronde 2: alle HTML"
run_lftp "mirror --reverse --verbose --include-glob '*.html' $dist/ $remote/;"
fi
# Ronde 3: opruimen als laatste, zodat bezoekers met de oude HTML hun oude
+51 -13
View File
@@ -539,7 +539,6 @@ describe.skipIf(toolsMissing || lftpMissing)('upload-production.sh', () => {
'robots.txt',
'soorten-fotoshoots/newborn.html',
'stale.txt',
'web.config',
]);
const third = await upload(dist, target, '3');
@@ -551,7 +550,6 @@ describe.skipIf(toolsMissing || lftpMissing)('upload-production.sh', () => {
'over-mij.html',
'robots.txt',
'soorten-fotoshoots/newborn.html',
'web.config',
]);
});
@@ -567,19 +565,18 @@ describe.skipIf(toolsMissing || lftpMissing)('upload-production.sh', () => {
);
expect(rounds).toEqual(['1', '2', '3']);
const expected = [...validFiles, 'web.config'].sort();
const expected = [...validFiles].sort();
expect(await tree(target)).toEqual(expected);
});
it('laat bij een tweede deploy geen back-upbestanden met ~ achter', async () => {
const { dist, target } = await setup();
expect((await upload(dist, target)).code).toBe(0);
// Nu bestaat web.config al op de host, en alles wordt overschreven
// Nu bestaat alles al op de host en wordt het overschreven
await write(dist, 'robots.txt', 'nieuwe inhoud');
expect((await upload(dist, target)).code).toBe(0);
const files = await tree(target);
expect(files.filter((file) => file.includes('~'))).toEqual([]);
expect(files).toContain('web.config');
});
it('weigert een ongeldige build en uploadt dan niets', async () => {
@@ -590,13 +587,12 @@ describe.skipIf(toolsMissing || lftpMissing)('upload-production.sh', () => {
expect(await tree(target)).toEqual(['stale.txt']);
});
it('neemt de web.config uit deploy/iis over', async () => {
it('zet geen web.config op de server: die hoort bij de CMS-host', async () => {
const { dist, target } = await setup();
const run = await upload(dist, target);
expect(run.code).toBe(0);
expect(await readFile(join(target, 'web.config'), 'utf8')).toBe(
await readFile(join(deployDir, 'iis/web.config'), 'utf8'),
);
expect(existsSync(join(target, 'web.config'))).toBe(false);
expect(existsSync(join(dist, 'web.config'))).toBe(false);
});
});
@@ -666,7 +662,7 @@ touch '${slash(marker)}'
},
);
it('zet in elke lftp-sessie de back-ups uit en de TLS-eisen aan', async () => {
it('zet in elke lftp-sessie de back-ups uit en TLS uit (gewone FTP)', async () => {
const dist = await makeDist();
const bin = await makeTemp('andreaslop-fakebin-');
const log = join(bin, 'opdrachten');
@@ -690,11 +686,53 @@ printf '%s\\n' "$2" >> '${slash(log)}'
const sessions = (await readFile(log, 'utf8'))
.split('\n')
.filter(Boolean);
// Ronde 1, web.config, ronde 2 (HTML) en ronde 3
expect(sessions).toHaveLength(4);
// Ronde 1, ronde 2 (HTML) en ronde 3
expect(sessions).toHaveLength(3);
for (const commands of sessions) {
expect(commands).toContain('set xfer:make-backup no;');
expect(commands).toContain('set ftp:ssl-force true;');
expect(commands).toContain('set ftp:ssl-allow no;');
expect(commands).toContain('set ftp:passive-mode on;');
expect(commands).not.toContain('ssl-force');
}
});
it('geeft FTP_PORT door aan lftp en weigert een ongeldige poort', async () => {
const dist = await makeDist();
const bin = await makeTemp('andreaslop-fakebin-');
const log = join(bin, 'argumenten');
await writeFile(
join(bin, 'lftp'),
`#!/bin/sh
printf '%s\n' "$*" >> '${slash(log)}'
`,
{ mode: 0o755 },
);
const env = {
PATH: `${bin}${delimiter}${process.env.PATH ?? ''}`,
FTP_HOST: 'ftp.example.test',
FTP_USER: 'gebruiker',
LFTP_PASSWORD: 'geheim',
};
const bad = await runScript(
'upload-production.sh',
[basename(dist), 'wwwroot'],
{ ...env, FTP_PORT: '21; rm -rf' },
dirname(dist),
);
expect(bad.code).toBe(2);
expect(existsSync(log)).toBe(false);
const good = await runScript(
'upload-production.sh',
[basename(dist), 'wwwroot'],
{ ...env, FTP_PORT: '2121' },
dirname(dist),
);
expect(good.code).toBe(0);
for (const line of (await readFile(log, 'utf8'))
.split('\n')
.filter(Boolean)) {
expect(line).toContain('-u gebruiker -p 2121 ftp.example.test');
}
});