P1-0: V8 heap cap (HOMARR_MAX_OLD_SPACE_SIZE, default 512MB)
P1-1: Module graph cuts
- Dynamic integration imports (55 static → lazy loaders)
- Conditional DB driver loading (only configured driver loaded)
- Replace jsdom with linkedom for SVG sanitization
- Delete eager widget barrel (55 import * as → 0)
- Extract createRetryableLoader to @homarr/common
P1-2: Enable cacheComponents + restructure root layout
- Suspense boundaries around session-dependent providers
- ColorSchemeScript replaces server-side cookie reads
- Board/manage/auth layouts wrapped in Suspense
P1-3: Cache read paths
- Cache tag registry + invalidation helpers
- Cache invalidation wired into all mutation routers
- Translation deep-merge memoized per locale
P1-4: Prerendered shells + loading.tsx files
P1-5: Shared integration data cache (60s TTL, stale-while-revalidate)
P1-6: Redis-backed Next.js cache handler (@homarr/next-cache-handler)
P1-7: Redis optional (memory channel fallback), TTL on pubSub:last:*,
Redis clients consolidated from 6 to 2
78 lines
2.0 KiB
Bash
78 lines
2.0 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Create sub directories in volume
|
|
mkdir -p /appdata/db
|
|
mkdir -p /appdata/redis
|
|
mkdir -p /appdata/trusted-certificates
|
|
|
|
# Run migrations
|
|
export NODE_OPTIONS="--max-old-space-size=${HOMARR_MAX_OLD_SPACE_SIZE:-512} ${NODE_OPTIONS}"
|
|
if [ "$DB_MIGRATIONS_DISABLED" = "true" ]; then
|
|
echo "DB migrations are disabled, skipping"
|
|
else
|
|
echo "Running DB migrations"
|
|
DISABLE_REDIS_LOGS=true node ./db/migrations/$DB_DIALECT/migrate.cjs ./db/migrations/$DB_DIALECT
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: DB migrations failed, aborting startup"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Auth secret is generated every time the container starts as it is required, but not used because we don't need JWTs or Mail hashing
|
|
export AUTH_SECRET=$(openssl rand -base64 32)
|
|
|
|
# Start nginx proxy
|
|
# 1. Replace the HOSTNAME in the nginx template file
|
|
# 2. Create the nginx configuration file from the template
|
|
# 3. Start the nginx server
|
|
export HOSTNAME
|
|
envsubst '${HOSTNAME}' < /etc/nginx/templates/nginx.conf > /etc/nginx/nginx.conf
|
|
# Start services in the background and store their PIDs
|
|
nginx -g 'daemon off;' &
|
|
NGINX_PID=$!
|
|
|
|
if [ "$REDIS_IS_EXTERNAL" = "true" ]; then
|
|
echo "Using external Redis server at redis://$REDIS_HOST:$REDIS_PORT"
|
|
REDIS_PID=""
|
|
else
|
|
echo "Starting internal Redis server"
|
|
redis-server /app/redis.conf &
|
|
REDIS_PID=$!
|
|
fi
|
|
|
|
SHUTTING_DOWN=false
|
|
|
|
terminate() {
|
|
SHUTTING_DOWN=true
|
|
echo "Shutting down..."
|
|
kill -TERM $NEXTJS_PID 2>/dev/null
|
|
wait $NEXTJS_PID 2>/dev/null
|
|
kill -TERM $NGINX_PID 2>/dev/null
|
|
wait $NGINX_PID 2>/dev/null
|
|
if [ -n "$REDIS_PID" ]; then
|
|
kill -TERM $REDIS_PID 2>/dev/null
|
|
wait $REDIS_PID 2>/dev/null
|
|
fi
|
|
echo "Shutdown complete."
|
|
exit 0
|
|
}
|
|
|
|
trap terminate TERM INT
|
|
|
|
node apps/nextjs/server.js &
|
|
NEXTJS_PID=$!
|
|
|
|
while true; do
|
|
wait $NEXTJS_PID
|
|
EXIT_CODE=$?
|
|
|
|
if [ "$SHUTTING_DOWN" = true ]; then
|
|
break
|
|
fi
|
|
|
|
echo "Next.js exited with code $EXIT_CODE, restarting in 1s..."
|
|
sleep 1
|
|
node apps/nextjs/server.js &
|
|
NEXTJS_PID=$!
|
|
done
|