Files
blinko-cloudron/start.sh
Andreas Düren 9a1bb3d3bc Initial Blinko Cloudron package
- CloudronManifest.json with PostgreSQL and localstorage addons
- Dockerfile based on cloudron/base:5.0.0
- NGINX reverse proxy configuration
- Supervisor process management
- Initialization script with auto-configuration
2025-12-29 15:50:37 -06:00

62 lines
1.8 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}"
# Link data directory for Blinko
ln -sfn /app/data/.blinko /app/code/.blinko
# Run database migrations
echo "=> Running database migrations..."
cd /app/code
npx prisma migrate deploy --schema=/app/code/prisma/schema.prisma
# Seed database if needed
echo "=> Checking database seed..."
node /app/code/server/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