Initial commit: Docmost Cloudron package with customizable configuration

This commit is contained in:
Andreas Dueren
2025-07-15 13:13:03 -06:00
parent 49ae672cb5
commit 65cd9a73bb
6 changed files with 314 additions and 24 deletions

109
start.sh
View File

@@ -4,6 +4,21 @@ set -eu
echo "=> Starting Docmost setup"
# Set up writable client dist directory
if [ ! -d "/app/data/client-dist" ]; then
echo "=> Setting up writable client dist directory"
cp -r /app/client-dist-original /app/data/client-dist
chown -R cloudron:cloudron /app/data/client-dist
fi
# Copy sample .env file and documentation for user reference
if [ ! -f "/app/data/env.sample" ]; then
echo "=> Copying configuration files to /app/data/"
cp /app/code/env.sample /app/data/env.sample
cp /app/code/CONFIGURATION.md /app/data/CONFIGURATION.md
chown cloudron:cloudron /app/data/env.sample /app/data/CONFIGURATION.md
fi
# Initialize /app/data if it's empty (first run)
if [ ! -f /app/data/.initialized ]; then
echo "=> Initializing data directory"
@@ -42,13 +57,21 @@ echo "=> Configuring Redis..."
echo "=> Original CLOUDRON_REDIS_URL: ${CLOUDRON_REDIS_URL}"
if [ -n "${CLOUDRON_REDIS_URL}" ]; then
# Try to use the original URL first and see if it's valid
export REDIS_URL="${CLOUDRON_REDIS_URL}"
# Parse the URL components first
# Also extract components for individual env vars
REDIS_PASSWORD=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://:\([^@]*\)@.*|\1|p')
REDIS_HOST=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://[^@]*@\([^:]*\):.*|\1|p')
REDIS_PORT=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://[^@]*@[^:]*:\([0-9]*\).*|\1|p')
# Handle both formats: redis://default:password@host and redis://:password@host:port
if echo "$CLOUDRON_REDIS_URL" | grep -q "redis://default:"; then
# Format: redis://default:password@host
REDIS_PASSWORD=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://default:\([^@]*\)@.*|\1|p')
REDIS_HOST=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://default:[^@]*@\([^:/]*\).*|\1|p')
REDIS_PORT=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://default:[^@]*@[^:]*:\([0-9]*\).*|\1|p')
else
# Format: redis://:password@host:port
REDIS_PASSWORD=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://:\([^@]*\)@.*|\1|p')
REDIS_HOST=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://[^@]*@\([^:]*\):.*|\1|p')
REDIS_PORT=$(echo "$CLOUDRON_REDIS_URL" | sed -n 's|redis://[^@]*@[^:]*:\([0-9]*\).*|\1|p')
fi
# Default port if not found
if [ -z "$REDIS_PORT" ]; then
@@ -61,29 +84,77 @@ if [ -n "${CLOUDRON_REDIS_URL}" ]; then
export REDIS_PASSWORD="${REDIS_PASSWORD}"
export REDIS_DB="0"
echo "=> Redis configured: host=${REDIS_HOST}, port=${REDIS_PORT}"
echo "=> Using Redis URL: ${REDIS_URL}"
echo "=> Redis configured: host=${REDIS_HOST}, port=${REDIS_PORT}, has password: $([ -n "$REDIS_PASSWORD" ] && echo "yes" || echo "no")"
# Try alternative formats if the original fails
if [ -z "$REDIS_PASSWORD" ]; then
# Reconstruct the Redis URL in the correct format for ioredis
if [ -n "$REDIS_PASSWORD" ]; then
export REDIS_URL="redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}"
else
export REDIS_URL="redis://${REDIS_HOST}:${REDIS_PORT}"
fi
echo "=> Using Redis URL: ${REDIS_URL}"
else
echo "=> Error: Redis URL not provided by Cloudron"
exit 1
fi
# 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}"
# Load custom environment variables if they exist
if [ -f "/app/data/.env" ]; then
echo "=> Loading custom environment variables from /app/data/.env"
set -a # automatically export all variables
source /app/data/.env
set +a # stop automatically exporting
else
echo "=> No custom .env file found, using Cloudron defaults"
fi
# Storage configuration (using local storage)
export STORAGE_DRIVER=local
export STORAGE_LOCAL_PATH="/app/data/uploads"
# Email configuration - use custom settings if provided, otherwise use Cloudron defaults
export MAIL_DRIVER="${MAIL_DRIVER:-smtp}"
export SMTP_HOST="${SMTP_HOST:-${CLOUDRON_MAIL_SMTP_SERVER}}"
export SMTP_PORT="${SMTP_PORT:-${CLOUDRON_MAIL_SMTP_PORT}}"
export SMTP_USERNAME="${SMTP_USERNAME:-${CLOUDRON_MAIL_SMTP_USERNAME}}"
export SMTP_PASSWORD="${SMTP_PASSWORD:-${CLOUDRON_MAIL_SMTP_PASSWORD}}"
export SMTP_SECURE="${SMTP_SECURE:-false}"
export MAIL_FROM_ADDRESS="${MAIL_FROM_ADDRESS:-${CLOUDRON_MAIL_FROM}}"
export MAIL_FROM_NAME="${MAIL_FROM_NAME:-Docmost}"
# Storage configuration - use custom settings if provided, otherwise use local storage
export STORAGE_DRIVER="${STORAGE_DRIVER:-local}"
export STORAGE_LOCAL_PATH="${STORAGE_LOCAL_PATH:-/app/data/uploads}"
# S3 Storage configuration (only used if STORAGE_DRIVER=s3)
export AWS_S3_ACCESS_KEY_ID="${AWS_S3_ACCESS_KEY_ID:-}"
export AWS_S3_SECRET_ACCESS_KEY="${AWS_S3_SECRET_ACCESS_KEY:-}"
export AWS_S3_REGION="${AWS_S3_REGION:-}"
export AWS_S3_BUCKET="${AWS_S3_BUCKET:-}"
export AWS_S3_ENDPOINT="${AWS_S3_ENDPOINT:-}"
export AWS_S3_FORCE_PATH_STYLE="${AWS_S3_FORCE_PATH_STYLE:-false}"
# File upload limits
export FILE_UPLOAD_SIZE_LIMIT="${FILE_UPLOAD_SIZE_LIMIT:-50MB}"
export FILE_IMPORT_SIZE_LIMIT="${FILE_IMPORT_SIZE_LIMIT:-50MB}"
# Application configuration
export APP_URL="${APP_URL:-https://${CLOUDRON_APP_DOMAIN}}"
export APP_SECRET="${APP_SECRET:-${CLOUDRON_APP_ORIGIN}-$(date +%s)}"
export PORT="${PORT:-3001}"
export JWT_TOKEN_EXPIRES_IN="${JWT_TOKEN_EXPIRES_IN:-7d}"
# Diagrams configuration
export DRAWIO_URL="${DRAWIO_URL:-https://embed.diagrams.net}"
# Telemetry (disabled by default for privacy)
export DISABLE_TELEMETRY="${DISABLE_TELEMETRY:-true}"
# Postmark email (alternative to SMTP)
export POSTMARK_TOKEN="${POSTMARK_TOKEN:-}"
echo "=> Email configuration: ${MAIL_DRIVER} via ${SMTP_HOST}:${SMTP_PORT}"
echo "=> Storage configuration: ${STORAGE_DRIVER}"
if [ "${STORAGE_DRIVER}" = "s3" ]; then
echo "=> S3 storage: ${AWS_S3_BUCKET} in ${AWS_S3_REGION}"
fi
# Authentication will use built-in email/password system
echo "=> Using built-in email/password authentication"