67 lines
1.9 KiB
Bash
67 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
echo "=> Starting Docmost setup"
|
|
|
|
# Initialize /app/data if it's empty (first run)
|
|
if [ ! -f /app/data/.initialized ]; then
|
|
echo "=> Initializing data directory"
|
|
mkdir -p /app/data/uploads /app/data/logs
|
|
chown -R cloudron:cloudron /app/data
|
|
touch /app/data/.initialized
|
|
fi
|
|
|
|
# Generate APP_SECRET if not exists
|
|
if [ ! -f /app/data/app_secret ]; then
|
|
echo "=> Generating APP_SECRET"
|
|
openssl rand -hex 32 > /app/data/app_secret
|
|
chown cloudron:cloudron /app/data/app_secret
|
|
chmod 600 /app/data/app_secret
|
|
fi
|
|
|
|
APP_SECRET=$(cat /app/data/app_secret)
|
|
|
|
# Set up environment variables
|
|
export NODE_ENV=production
|
|
export APP_URL="${CLOUDRON_APP_ORIGIN}"
|
|
export APP_SECRET="${APP_SECRET}"
|
|
export PORT=3000
|
|
|
|
# Database configuration
|
|
export DATABASE_URL="${CLOUDRON_POSTGRESQL_URL}"
|
|
|
|
# Redis configuration
|
|
export REDIS_URL="${CLOUDRON_REDIS_URL}"
|
|
|
|
# Email configuration
|
|
export MAIL_DRIVER=smtp
|
|
export SMTP_HOST="${CLOUDRON_MAIL_SMTP_SERVER}"
|
|
export SMTP_PORT="${CLOUDRON_MAIL_SMTP_PORT}"
|
|
export SMTP_USERNAME="${CLOUDRON_MAIL_SMTP_USERNAME}"
|
|
export SMTP_PASSWORD="${CLOUDRON_MAIL_SMTP_PASSWORD}"
|
|
export MAIL_FROM_ADDRESS="${CLOUDRON_MAIL_FROM}"
|
|
|
|
# Storage configuration (using local storage)
|
|
export STORAGE_DRIVER=local
|
|
export STORAGE_LOCAL_PATH="/app/data/uploads"
|
|
|
|
# OIDC configuration for Cloudron authentication
|
|
export OIDC_CLIENT_ID="${CLOUDRON_OIDC_CLIENT_ID}"
|
|
export OIDC_CLIENT_SECRET="${CLOUDRON_OIDC_CLIENT_SECRET}"
|
|
export OIDC_ISSUER="${CLOUDRON_OIDC_ISSUER}"
|
|
export OIDC_REDIRECT_URI="${CLOUDRON_APP_ORIGIN}/api/v1/session/callback"
|
|
|
|
# File upload configuration
|
|
export FILE_UPLOAD_SIZE_LIMIT="50mb"
|
|
|
|
# JWT configuration
|
|
export JWT_TOKEN_EXPIRES_IN="30d"
|
|
|
|
echo "=> Running database migrations"
|
|
cd /app/code
|
|
chown -R cloudron:cloudron /app/data
|
|
sudo -u cloudron pnpm prisma migrate deploy || true
|
|
|
|
echo "=> Starting services with supervisor"
|
|
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf |