Files
blinko-cloudron/start.sh
Andreas Düren 74108fba9b Fix read-only filesystem issue in start.sh
- Remove symlink creation in /app/code (read-only)
- Set HOME=/app/data for Blinko data storage
- Use full path to prisma binary
- Fix seed.js path to dist directory
2025-12-29 17:01:59 -06:00

65 lines
1.9 KiB
Bash

#!/bin/bash
set -eu
echo "=> Starting Blinko for Cloudron"
# Initialize data directory on first run
if [[ ! -f /app/data/.initialized ]]; then
echo "=> First run: initializing data directory..."
mkdir -p /app/data/.blinko
touch /app/data/.initialized
fi
# Generate NEXTAUTH_SECRET if not present
if [[ ! -f /app/data/.nextauth_secret ]]; then
echo "=> Generating NEXTAUTH_SECRET..."
openssl rand -base64 32 > /app/data/.nextauth_secret
fi
NEXTAUTH_SECRET=$(cat /app/data/.nextauth_secret)
# Set ownership
chown -R cloudron:cloudron /app/data
# Configure environment from Cloudron
export NODE_ENV=production
export DATABASE_URL="${CLOUDRON_POSTGRESQL_URL}"
export NEXTAUTH_URL="${CLOUDRON_APP_ORIGIN}"
export NEXT_PUBLIC_BASE_URL="${CLOUDRON_APP_ORIGIN}"
export NEXTAUTH_SECRET="${NEXTAUTH_SECRET}"
export TRUST_PROXY=1
export DISABLE_SECURE_COOKIE=false
# Configure mail settings if available
if [[ -n "${CLOUDRON_MAIL_SMTP_SERVER:-}" ]]; then
export SMTP_HOST="${CLOUDRON_MAIL_SMTP_SERVER}"
export SMTP_PORT="${CLOUDRON_MAIL_SMTP_PORT}"
export SMTP_USER="${CLOUDRON_MAIL_SMTP_USERNAME}"
export SMTP_PASS="${CLOUDRON_MAIL_SMTP_PASSWORD}"
export SMTP_FROM="${CLOUDRON_MAIL_FROM}"
fi
# Set timezone if configured
export TZ="${TZ:-UTC}"
# Set HOME to /app/data so Blinko stores data there
export HOME=/app/data
# Create .blinko in the data directory (writable location)
mkdir -p /app/data/.blinko
# Run database migrations
echo "=> Running database migrations..."
cd /app/code
/app/code/node_modules/.bin/prisma migrate deploy --schema=/app/code/prisma/schema.prisma
# Seed database if needed
echo "=> Checking database seed..."
node /app/code/dist/seed.js 2>/dev/null || true
# Configure NGINX
cp /app/code/nginx.conf /run/nginx.conf
echo "=> Starting supervisor..."
exec /usr/bin/supervisord --configuration /app/code/supervisor/supervisord.conf --nodaemon