Files
f3-simple-blog/docker/entrypoint.sh
2026-03-27 14:43:08 +01:00

39 lines
1.1 KiB
Bash

#!/bin/sh
set -eu
APP_ROOT="/var/www/html"
CONFIG="$APP_ROOT/config.local.ini"
# Docker creates a directory when bind-mounting a file that doesn't exist on the host.
# Remove it so bootstrap.php falls back to defaults.
if [ -d "$CONFIG" ]; then
rmdir "$CONFIG" 2>/dev/null || true
echo "Warning: config.local.ini was mounted as a directory (file missing on host). Using defaults."
fi
install -d -m 0775 -o www-data -g www-data \
"$APP_ROOT/db" \
"$APP_ROOT/logs" \
"$APP_ROOT/public/uploads/media" \
"$APP_ROOT/tmp" \
"$APP_ROOT/tmp/cache" \
"$APP_ROOT/tmp/uploads"
# Bind mounts may keep host-side ownership/permissions. Normalize the writable
# application directories before boot so F3 can write its cache and SQLite files.
chown -R www-data:www-data \
"$APP_ROOT/db" \
"$APP_ROOT/logs" \
"$APP_ROOT/public/uploads/media" \
"$APP_ROOT/tmp"
chmod -R u+rwX,g+rwX \
"$APP_ROOT/db" \
"$APP_ROOT/logs" \
"$APP_ROOT/public/uploads/media" \
"$APP_ROOT/tmp"
# Run installation as the web user so generated files keep consistent ownership.
su -s /bin/sh www-data -c "php $APP_ROOT/scripts/install.php"
exec "$@"