Files

4.1 KiB

Infrastructure Design: media directory (unit H3)

Bryan's decision: images live in a directory outside the release. This stage records how the directory is provided on each host and what is still unknown.

Requirements on the directory

  1. Outside the release and outside the web root (not served by IIS or nginx as static content; only the host's /media/... endpoint serves from it).
  2. Survives deploys (the release directory is replaced on every deploy).
  3. Writable by the account the host runs as; nothing else writes to it.
  4. Included in the backup of the site.
  5. Large enough: default safety limit Media:MaxTotalBytes 2 GB; expected use well below 100 MB.

Per host

Host Directory Setting Backup Status
Pi test, SLP (~/apps/slpsoftware/test) ~/apps/slpsoftware/test/shared/media (next to shared/env, shared/wwwroot-web) Media__Directory=%h/apps/slpsoftware/test/shared/media in shared/env Add the directory to the host backup routine for test (a test site may also be re-seeded) To do by Pi-Main with the first test deploy: mkdir -p, mode 700, owner the service account
Pi test, ASF ~/apps/<asf test>/shared/media (same pattern, its own env file) Media__Directory=… as above same
SLP production (Pi, later) ~/apps/slpsoftware/production/shared/media shared/env The production backup script (backup-slpsoftware-db.sh covers the database only): the directory must be added Open until the release; listed in the production checklist
ASF production (MijnHostingPartner, IIS, self-contained win-x64) A data directory beside the site, outside the web root (for example ..\data\media), writable by the application pool identity environment variable or appsettings.Production.json The hosting provider's file backup, or an FTP copy; to confirm Unknown: write permission and backup on this hosting are not known. Bryan tests with ASF (hosting package, application pool identity). If the test fails, Bryan is asked again and the database store (behind IMediaStore) is built.

Deployment behaviour

  • deploy-scp.yaml builds releases/<ts>/ and switches current; shared/ is not touched, so shared/media survives. No workflow change is needed for the Pi.
  • The directory is created by Pi-Main once (documented in docs/hero-module.md and in the checklist); the host also creates it at start-up when it is missing and the account may.
  • Release artifact size: Magick.NET adds about 35 MB native per platform; the upload limit of the deploy path (deployment-instructions.md 1.7.3, the nginx client_max_body_size for artifact upload) must allow the artifact; to be measured at the first deploy (the current artifact size is the reference).

Backup and restore

  • Files are immutable and content-addressed; a restore of the directory plus the database brings the site back; a restore needs both. A restored database without the directory leaves slides without files. Two safeguards: the start-up check logs a warning with the count of sets that the database refers to but the directory lacks, and the page injection (H4) checks that the first slide's files exist (through IMediaStore.ExistsAsync, cached with the page for 60 seconds) and leaves the baked hero in place when they do not, so a missing directory never produces a broken first image.
  • Test hosts: the seed script can rebuild the hero and images from the ASF sources, so a test restore is optional.

Risks

Risk Handling
Write permission or backup unavailable on the ASF production hosting Bryan tests with ASF before the release; IMediaStore allows a database implementation; Bryan is asked again when the test fails
Disk fills Media:MaxTotalBytes, free-space check before writing, clean-up of retired files, an error log line when 80% is reached
Directory missing after a server move Start-up check disables uploads and logs; the injection sees the missing first-slide files and leaves the baked hero (no broken image); documented in the checklist
Deploy artifact too large for the proxy limit Measured at the first deploy; the limit is raised on the proxy when needed