From 5c208d05198d133510cdf91dd6f95d1fa43b027f Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Fri, 26 Jan 2024 20:19:34 +0000 Subject: [PATCH] allow easy overrides of any and all files in container via new override mount --- .env.docker | 3 +++ docker-compose.yml | 2 ++ docker/shared/root/docker/entrypoint.sh | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/.env.docker b/.env.docker index 7be6e3e05..9cc8dacbd 100644 --- a/.env.docker +++ b/.env.docker @@ -982,6 +982,9 @@ DOCKER_APP_HOST_STORAGE_PATH="${DOCKER_ALL_HOST_DATA_ROOT_PATH}/pixelfed/storage # Path is relative (./some/other/path) to the docker-compose.yml or absolute (/some/other/path) DOCKER_APP_HOST_CACHE_PATH="${DOCKER_ALL_HOST_DATA_ROOT_PATH}/pixelfed/cache" +# Path (relative to the docker-compose.yml) or absolute (/some/other/path) where containers will store overrides +DOCKER_APP_HOST_OVERRIDES_PATH="${DOCKER_ALL_HOST_CONFIG_ROOT_PATH}/overrides" + # Automatically run "One-time setup tasks" commands. # # If you are migrating to this docker-compose setup or have manually run the "One time seutp" diff --git a/docker-compose.yml b/docker-compose.yml index fd62bd86e..986bf351b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -84,6 +84,7 @@ services: - "./.env:/var/www/.env" - "${DOCKER_APP_HOST_CACHE_PATH}:/var/www/bootstrap/cache" - "${DOCKER_APP_HOST_STORAGE_PATH}:/var/www/storage" + - "${DOCKER_APP_HOST_OVERRIDES_PATH}:/docker/overrides:ro" environment: LETSENCRYPT_HOST: "${LETSENCRYPT_HOST}" LETSENCRYPT_EMAIL: "${LETSENCRYPT_EMAIL}" @@ -126,6 +127,7 @@ services: - "./.env:/var/www/.env" - "${DOCKER_APP_HOST_CACHE_PATH}:/var/www/bootstrap/cache" - "${DOCKER_APP_HOST_STORAGE_PATH}:/var/www/storage" + - "${DOCKER_APP_HOST_OVERRIDES_PATH}:/docker/overrides:ro" depends_on: - db - redis diff --git a/docker/shared/root/docker/entrypoint.sh b/docker/shared/root/docker/entrypoint.sh index 9a170be13..73f6a4f3e 100755 --- a/docker/shared/root/docker/entrypoint.sh +++ b/docker/shared/root/docker/entrypoint.sh @@ -11,6 +11,9 @@ export ENTRYPOINT_ROOT : "${ENTRYPOINT_D_ROOT:="${ENTRYPOINT_ROOT}/entrypoint.d/"}" export ENTRYPOINT_D_ROOT +: "${DOCKER_APP_HOST_OVERRIDES_PATH:="${ENTRYPOINT_ROOT}/overrides"}" +export DOCKER_APP_HOST_OVERRIDES_PATH + # Space separated list of scripts the entrypoint runner should skip : "${ENTRYPOINT_SKIP_SCRIPTS:=""}" @@ -37,6 +40,12 @@ if directory-is-empty "${ENTRYPOINT_D_ROOT}"; then exec "$@" fi +# If the overridess directory exists, then copy all files into the container +if ! directory-is-empty "${DOCKER_APP_HOST_OVERRIDES_PATH}"; then + log-info "Overrides directory is not empty, copying files" + run-as-current-user cp --verbose --recursive "${DOCKER_APP_HOST_OVERRIDES_PATH}/." / +fi + acquire-lock "entrypoint.sh" # Start scanning for entrypoint.d files to source or run