Prerequisites
- Docker Engine 20.10 or later
- Docker Compose v3 or later
- At least 512MB of available RAM
- PostgreSQL 13 (can be run in a separate container)
Docker Compose Setup
Configure environment variables
Create a
.env file in the project root with the following variables:Never commit your
.env file to version control. Use .env.example as a template.Database Container Setup
For development or standalone deployments, you can run PostgreSQL in a container usingdocker_db.yml:
Dockerfile Overview
The bot uses a multi-stage Docker build for optimized image size:The Dockerfile includes ImageMagick and GraphicsMagick for meal plan PDF processing.
Docker Management
View Logs
Restart the Bot
Stop the Bot
Rebuild After Changes
Update to Latest Image
Troubleshooting
Bot fails to connect to database
Bot fails to connect to database
Symptoms: Error messages about database connection failuresSolutions:
- Verify
DATABASE_URLin.envis correct - Ensure the database container is running:
docker ps - Check if PostgreSQL is accepting connections:
docker logs database - If using
network_mode: host, ensure no firewall blocking port 5432 - Test connection manually:
docker exec -it database psql -U faculty_manager -d faculty_manager
Permission errors on mounted volumes
Permission errors on mounted volumes
Symptoms: Cannot read
config.json or write to images/ directorySolutions:- Check file permissions:
ls -la config.json images/ - Ensure the Docker user has read access to mounted files
- For Linux:
chmod 644 config.json && chmod 755 images/
ImageMagick policy errors
ImageMagick policy errors
Symptoms: PDF conversion fails with policy errorsSolutions:
- The Dockerfile already disables restrictive policies
- If issues persist, check logs:
docker logs faculty_manager | grep -i imagemagick - Verify PDF file is accessible in the container
Container keeps restarting
Container keeps restarting
Symptoms:
docker ps shows container constantly restartingSolutions:- Check logs for errors:
docker logs faculty_manager - Verify Discord token is valid in
.env - Ensure all required environment variables are set
- Check if config.json has valid JSON syntax
Cannot access external resources
Cannot access external resources
Symptoms: Meal plan downloads fail, SMTP connection issuesSolutions:
- Verify network connectivity:
docker exec faculty_manager ping -c 4 8.8.8.8 - Check DNS resolution:
docker exec faculty_manager nslookup google.com - Ensure no proxy or firewall blocking outbound connections
- Verify SMTP credentials and server settings in
.env
Performance Tuning
Resource Limits
Add resource constraints todocker-compose.yml:
Logging Configuration
Control log verbosity in.env:
Production Considerations
Docker Compose with Health Checks
Next Steps
Database Setup
Learn about database migrations and schema management
Configuration
Configure bot settings and features