This commit is contained in:
Nice Try
2026-06-26 16:34:53 +08:00
parent 433b237a35
commit f89e392ccf
+10 -5
View File
@@ -4,17 +4,22 @@ set -e
# Ensure bind-mounted runtime folders exist. # Ensure bind-mounted runtime folders exist.
mkdir -p /app/My_Courses /app/prisma mkdir -p /app/My_Courses /app/prisma
# If the container starts as root, make common bind mounts writable by the app user. # If the container starts as root, fix permissions.
# This helps when users create ./prisma/dev.db or ./My_Courses on the host first.
if [ "$(id -u)" = "0" ]; then if [ "$(id -u)" = "0" ]; then
chown -R nextjs:nodejs /app/My_Courses /app/prisma 2>/dev/null || true # For the database, we MUST own it to write to it. This folder is small, so -R is safe.
chown -R nextjs:nodejs /app/prisma 2>/dev/null || true
# For the courses, we just need to make sure the nextjs user can READ and TRAVERSE it.
# We avoid chown -R here because doing it on 500GB of videos takes forever on boot.
chmod -R 755 /app/My_Courses 2>/dev/null || true
fi fi
# A fresh Docker deployment often bind-mounts an empty SQLite file at /app/prisma/dev.db. # A fresh Docker deployment often bind-mounts an empty SQLite file.
# Initialize/update the Prisma schema before the Next.js server starts. # Initialize/update the Prisma schema before the Next.js server starts.
if [ -n "${DATABASE_URL:-}" ]; then if [ -n "${DATABASE_URL:-}" ]; then
echo "Initializing SQLite schema with Prisma..." echo "Initializing SQLite schema with Prisma..."
gosu nextjs:nodejs ./node_modules/.bin/prisma db push --schema=/app/prisma/schema.prisma --skip-generate gosu nextjs:nodejs ./node_modules/.bin/prisma db push --schema=/app/prisma/schema.prisma --skip-generate
fi fi
exec gosu nextjs:nodejs "$@" echo "Booting OfflineAcademy..."
exec gosu nextjs:nodejs "$@"