From 6b44b7dd59f7224ca8cae8e3c467452fdf3637c3 Mon Sep 17 00:00:00 2001 From: librelad Date: Thu, 13 Aug 2026 00:18:55 +0100 Subject: [PATCH] fix(nextcloud): copy nginx.conf on install, so the web container can start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found by actually installing it. The compose bind-mounts ./resources/nginx.conf into the web container, but nothing ever copied that file into the container tree, so Docker created a DIRECTORY in its place and nginx died with: error mounting ".../resources/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": not a directory Worse than a hard failure: the app still recorded as installed. Three of four containers came up, the DB and the app itself were fine, and only the web front end was missing — a quiet, partial install. Apps needing a resource file declare the copy in a hook (authelia does exactly this); Nextcloud simply never had one. Adds nextcloud_install_post_compose — after the compose file is written, before permissions and `up` — which repairs any stub directory left by a previous attempt and then copies the file. The stub repair matters: without it the copy lands INSIDE the directory (resources/nginx.conf/nginx.conf) and the mount fails identically. Co-Authored-By: Claude Opus 5 --- .../scripts/nextcloud_install_hooks.sh | 33 +++++++++++++++++++ .../source/files/arrays/function_manifest.sh | 3 ++ 2 files changed, 36 insertions(+) create mode 100644 containers/nextcloud/scripts/nextcloud_install_hooks.sh diff --git a/containers/nextcloud/scripts/nextcloud_install_hooks.sh b/containers/nextcloud/scripts/nextcloud_install_hooks.sh new file mode 100644 index 0000000..fca3a8f --- /dev/null +++ b/containers/nextcloud/scripts/nextcloud_install_hooks.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Nextcloud install hooks. +# +# The compose bind-mounts ./resources/nginx.conf into the web container, but +# nothing ever copied that file into the container tree — so on a fresh install +# Docker did what Docker does with a missing bind source and created a DIRECTORY +# in its place. nginx then refused to start with: +# +# error mounting ".../resources/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": +# not a directory: Are you trying to mount a directory onto a file? +# +# The app still "installed" — three of four containers came up and the app was +# recorded as installed — so it failed quietly, with only the web front end +# missing. Apps that need a resource file declare the copy in a hook (authelia +# does exactly this); Nextcloud never had one. +# +# post_compose is the right point: the compose file is written, permissions and +# `up` have not run yet, so the mount source exists before anything reads it. + +nextcloud_install_post_compose() +{ + local app_name="$1" + + # Clear a stub directory left behind by any previous attempt, otherwise the + # copy lands INSIDE it (resources/nginx.conf/nginx.conf) and the mount fails + # exactly as before. Shared helper — same repair the WebUI's own config uses. + repairStubDirForFile "$containers_dir$app_name/resources/nginx.conf" "loud" + + local result + result=$(copyResource "$app_name" "nginx.conf" "resources" | runInstallWrite -a "$logs_dir/$docker_log_file" 2>&1) + checkSuccess "Copying nginx.conf to $containers_dir$app_name/resources" +} diff --git a/scripts/source/files/arrays/function_manifest.sh b/scripts/source/files/arrays/function_manifest.sh index 1af4d5d..1e59121 100644 --- a/scripts/source/files/arrays/function_manifest.sh +++ b/scripts/source/files/arrays/function_manifest.sh @@ -700,6 +700,7 @@ declare -gA LP_FN_MAP=( [networkMtuCacheFile]="network/network_mtu.sh" [networkRedetectMtu]="network/network_mtu.sh" [networkScanConflicts]="docker/network/network_conflicts.sh" + [nextcloud_install_post_compose]="nextcloud/scripts/nextcloud_install_hooks.sh" [_nextcloudOcc]="nextcloud/scripts/nextcloud_auth.sh" [_nextcloudOccWithPass]="nextcloud/scripts/nextcloud_auth.sh" [nextcloud_upgrade_verify]="nextcloud/scripts/nextcloud_upgrade_hooks.sh" @@ -1745,6 +1746,7 @@ declare -gA LP_FN_ROOT=( [networkMtuCacheFile]="scripts" [networkRedetectMtu]="scripts" [networkScanConflicts]="scripts" + [nextcloud_install_post_compose]="containers" [_nextcloudOcc]="containers" [_nextcloudOccWithPass]="containers" [nextcloud_upgrade_verify]="containers" @@ -2824,6 +2826,7 @@ networkHealConflicts() { unset -f networkHealConflicts; __lpAutoload "${install_ networkMtuCacheFile() { unset -f networkMtuCacheFile; __lpAutoload "${install_scripts_dir}network/network_mtu.sh"; networkMtuCacheFile "$@"; } networkRedetectMtu() { unset -f networkRedetectMtu; __lpAutoload "${install_scripts_dir}network/network_mtu.sh"; networkRedetectMtu "$@"; } networkScanConflicts() { unset -f networkScanConflicts; __lpAutoload "${install_scripts_dir}docker/network/network_conflicts.sh"; networkScanConflicts "$@"; } +nextcloud_install_post_compose() { unset -f nextcloud_install_post_compose; __lpAutoload "${install_containers_dir}nextcloud/scripts/nextcloud_install_hooks.sh"; nextcloud_install_post_compose "$@"; } _nextcloudOcc() { unset -f _nextcloudOcc; __lpAutoload "${install_containers_dir}nextcloud/scripts/nextcloud_auth.sh"; _nextcloudOcc "$@"; } _nextcloudOccWithPass() { unset -f _nextcloudOccWithPass; __lpAutoload "${install_containers_dir}nextcloud/scripts/nextcloud_auth.sh"; _nextcloudOccWithPass "$@"; } nextcloud_upgrade_verify() { unset -f nextcloud_upgrade_verify; __lpAutoload "${install_containers_dir}nextcloud/scripts/nextcloud_upgrade_hooks.sh"; nextcloud_upgrade_verify "$@"; }