Using environment variables
Paideia LMS uses environment variables to configure database connections, file storage, API settings, and other system parameters. You can set environment variables in your hosting environment or by using a .env file in the directory where you run the Paideia CLI.
Setting environment variables
Section titled “Setting environment variables”In your hosting environment
Section titled “In your hosting environment”When deploying Paideia LMS to a hosting platform, you typically set environment variables through your hosting provider’s control panel or configuration interface. This is the recommended approach for production deployments.
Common hosting platforms include:
- Cloud VPS (Hetzner, DigitalOcean, AWS EC2, etc.): Set environment variables in your systemd service file,
.bashrc, or system environment - Docker: Set environment variables in your
docker-compose.ymlfile or through Docker’s environment variable system - Kubernetes: Use ConfigMaps and Secrets for environment variables
- Platform-as-a-Service (Heroku, Railway, Render, etc.): Set environment variables through their web interfaces or CLI tools
Using .env files
Section titled “Using .env files”For local development or when running the Paideia binary directly, you can create a .env file in the directory where you run the Paideia CLI.
Just create a .env file in your project directory and add your environment variables:
# DatabaseDATABASE_URL=postgresql://user:password@localhost:5432/paideia_db
# S3/MinIOS3_URL=http://localhost:9000S3_ACCESS_KEY=your-access-keyS3_SECRET_KEY=your-secret-keyS3_BUCKET=paideia-bucketS3_REGION=us-east-1
# PayloadPAYLOAD_SECRET=your-secure-random-string
# PortsPORT=3001FRONTEND_PORT=3000
# CORSCORS_ORIGINS=*
# EmailEMAIL_FROM_ADDRESS=info@paideialms.comEMAIL_FROM_NAME=Paideia LMSWhen you run the Paideia binary, it will automatically load environment variables from the .env file in the current directory.
Using the command line
Section titled “Using the command line”You can also set environment variables directly when running the Paideia binary:
DATABASE_URL="postgresql://user:password@localhost:5432/paideia_db" \S3_URL="http://localhost:9000" \S3_ACCESS_KEY="your-access-key" \S3_SECRET_KEY="your-secret-key" \S3_BUCKET="paideia-bucket" \./paideiaEnvironment variables reference
Section titled “Environment variables reference”For a complete list of all available environment variables, including descriptions, default values, and whether they are required, see the Installation and Setup guide.
The environment variables include:
- Database:
DATABASE_URLfor PostgreSQL connection - Storage:
S3_URL,S3_ACCESS_KEY,S3_SECRET_KEY,S3_BUCKET,S3_REGIONfor S3-compatible storage - Security:
PAYLOAD_SECRETfor encryption,CORS_ORIGINSfor CORS configuration - Ports:
PORTfor backend API,FRONTEND_PORTfor frontend - Email:
EMAIL_FROM_ADDRESS,EMAIL_FROM_NAME,SMTP_HOST,SMTP_USER,SMTP_PASS,RESEND_API_KEY - Other:
SANDBOX_MODEfor sandbox functionality
Priority order
Section titled “Priority order”When Paideia LMS looks for environment variables, it uses the following priority order (highest to lowest):
.envfile: Variables defined in the.envfile in the current directory- System environment variables: Variables set in your system environment
- Default values: Built-in defaults (if available)
This means that if you set an environment variable both in your system environment and in a .env file, the .env file value will take precedence.
Security recommendations
Section titled “Security recommendations”- Never commit secrets: Always add
.envto your.gitignorefile - Use strong secrets: Generate cryptographically secure random strings for
PAYLOAD_SECRET - Restrict CORS: Replace
CORS_ORIGINS: "*"with your actual domain(s) in production - Use secure connections: Use HTTPS URLs for
S3_URLandDATABASE_URLin production - Rotate secrets regularly: Change passwords and API keys periodically
For more security best practices, see the Installation and Setup guide.
Learn