#!/bin/sh # Runs once per container start, before Apache — see /admin/docs/docker. # # docker-compose.yml bind-mounts App/, public/cache/, public/uploads/, and # data/ from the host so a project's content/db survive a rebuild and can be # edited without one. Two problems a plain COPY-at-build-time image can't # solve on its own: # # 1. A bind mount to an empty (or not-yet-created) host directory shadows # whatever COPY baked into that path in the image, replacing it with # nothing — Docker does not seed bind mounts from image content the way # it seeds a fresh named volume. App/ is only ever the docs/starter # content wanted on host: seed it from the pristine copy stashed # at build time (/opt/novaconium-app-default) if the mounted dir is # empty, so `docker compose up` produces a working site on a first run # with no manual copy step. # 2. A bind-mounted host directory keeps the host's ownership, not the # image's — the build-time `chown` in the Dockerfile never applies to # it. Re-chown the mounted paths to the Apache worker user on every # start so they're writable regardless of the host-side UID/GID. set -e if [ -z "$(ls -A /var/www/html/App 2>/dev/null)" ]; then cp -a /opt/novaconium-app-default/. /var/www/html/App/ fi chown -R www-data:www-data /var/www/html/public/cache /var/www/html/public/uploads /var/www/html/App /var/www/html/data exec "$@"