LibrePortal/containers/nextcloud/scripts/nextcloud_install_hooks.sh
librelad 6b44b7dd59 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>
2026-08-13 00:18:55 +01:00

34 lines
1.5 KiB
Bash

#!/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"
}