fix(nextcloud): copy nginx.conf on install, so the web container can start

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 <noreply@anthropic.com>
This commit is contained in:
librelad 2026-08-13 00:18:55 +01:00
parent 046d69bad7
commit 6b44b7dd59
2 changed files with 36 additions and 0 deletions

View File

@ -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"
}

View File

@ -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 "$@"; }