# ============================================================================= # Fileserver capability overlay — the storage volume, added only when the capability is selected. # # Usage, on top of a stack whose image carries the fileserver module (a service that selected # `:composition:fileserver-platform`, or COMPOSITION=qualification): # docker compose -f docker-compose.yml -f docker-compose.local.yml \ # -f infra/fileserver/compose/docker-compose.fileserver.yml up # # Why a file of its own (review 2026-11-01 07-08, capability criterion 7): the default image and # docker-compose.yml carry no fileserver, so they no longer carry its volume either. Before, every # container — default composition included — mounted a volume for a module it did not have, and the # image declared it a VOLUME. It sits with the rest of the capability's infrastructure # (infra/fileserver), so removing the capability removes it with that directory. # # The volume is a named volume, not a tmpfs and not the read-only root: published content must # outlive the container that wrote it. Back it with real storage in any deployment that keeps files. # Kubernetes does the same job with a PersistentVolumeClaim and the pod's fsGroup # (infra/fileserver/kubernetes/pvc-certification-job.yaml). # # Ownership. The application runs as the image's non-root `app` account (src/Dockerfile). Docker # seeds a fresh named volume's owner from the image directory at the mount point, and the image has # no such directory any more; a reused volume or a host bind mount keeps whatever owner it had. # Left like that, the volume is root's, every write is refused, and the module's storage probe stops # startup with "storage root is not writable". fileserver-storage-init fixes the owner each time # before the application starts: it runs once, as root, in the application's own image, and chowns # to the `app` account by name, so the owner follows the image rather than a uid written here. # ============================================================================= services: fileserver-storage-init: # The image the app service builds and tags. Never pulled: Compose builds it for `app` first, # and a registry has no image by this local tag. image: caskeleton:${BUILD_VERSION:-0.0.1_local_0000000}-${COMPOSITION:-default} pull_policy: never user: "0:0" entrypoint: - "sh" - "-c" - "chown app:app /var/lib/backend/files && chmod 0750 /var/lib/backend/files" read_only: true network_mode: none volumes: - fileserver-data:/var/lib/backend/files restart: "no" app: depends_on: fileserver-storage-init: condition: service_completed_successfully environment: # The mount and the root the module writes to must name one path. This is also the module's # default (config/module-defaults/fileserver.yml), stated so that moving one moves the other. APP_FILESERVER_PLATFORM_STORAGE_ROOT: "/var/lib/backend/files" volumes: - fileserver-data:/var/lib/backend/files volumes: fileserver-data: