deploy.sh script generates a .env file that Docker Compose reads during container startup.
Core variables
These variables are defined indeploy.sh and control the fundamental deployment settings:
The public URL where Moodle will be accessibleExample:
https://eva.intiinside.comDefault: Must be set before running deploy.shThis URL is used in Moodle’s configuration and email notifications
PostgreSQL database nameDefault:
moodle (deploy.sh:5)Used by both the database container and Moodle application to connect to the correct database.PostgreSQL database usernameDefault:
moodle (deploy.sh:6)Credentials for Moodle to authenticate with PostgreSQL.PostgreSQL database passwordDefault:
moodle (deploy.sh:7)Docker Compose variables
These variables are used indocker-compose.yml to configure services:
Database service (db)
docker-compose.yml:8-10
Application service (app)
docker-compose.yml:22-27
MOODLE_DB_HOST: db uses Docker’s service discovery. The db service is automatically resolvable via Docker DNS.Setting variables
Before deployment
Editdeploy.sh before running it:
deploy.sh:3-7
SITE_URL line (line 4) with your actual domain.
After deployment
If you need to change variables after initial deployment:Security best practices
Use strong passwords
Generate secure passwords for
DB_PASS:Restrict file permissions
Limit access to the .env file:
Use secrets management
For production, consider using Docker secrets or external secret managers instead of plain .env files.
Separate environments
Maintain different .env files for development, staging, and production environments.
Verification
Check that environment variables are correctly loaded in containers:Troubleshooting
Moodle shows 'Database connection failed'
Moodle shows 'Database connection failed'
- Verify environment variables are set correctly in
.env - Check database credentials match between app and db services
- Ensure database container is running:
docker compose ps db - Check database logs:
docker compose logs db
Wrong site URL in Moodle
Wrong site URL in Moodle
- Update
SITE_URLin.env - Edit
/var/www/html/config.phpinside the app container - Update
$CFG->wwwrootto match your new URL - Restart services:
docker compose restart
.env file not being read
.env file not being read
The Regenerate if needed by running the relevant section of
.env file must be in the same directory as docker-compose.yml. Check:deploy.sh.Next steps
PHP settings
Configure PHP memory, upload limits, and timeouts
Nginx configuration
Customize web server settings
Database tuning
Optimize PostgreSQL performance
Security hardening
Implement security best practices