#!/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" # Authentication will use built-in email/password system echo "=> Using built-in email/password authentication" # 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 /usr/bin/node /app/code/node_modules/.bin/prisma migrate deploy || true # Create nginx temp directories mkdir -p /tmp/nginx_client_temp /tmp/nginx_proxy_temp /tmp/nginx_fastcgi_temp /tmp/nginx_uwsgi_temp /tmp/nginx_scgi_temp chown -R cloudron:cloudron /tmp/nginx_* echo "=> Starting services with supervisor" exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf