6.7 KiB
Docker Deployment Guide
Prerequisites
- Docker installed
- Docker Compose installed
Quick Start
-
Copy environment template:
copy .env.example .env -
Edit
.envwith your Reddit credentials:REDDIT_CLIENT_ID=your_client_id REDDIT_CLIENT_SECRET=your_client_secret REDDIT_USERNAME=your_username REDDIT_PASSWORD=your_password SUBREDDIT=your_subreddit -
Start the bot:
docker-compose up -d -
Verify it's running:
docker-compose ps -
View logs:
docker-compose logs -f
Environment Variables
Required variables (in .env):
- REDDIT_CLIENT_ID - OAuth client ID from Reddit app
- REDDIT_CLIENT_SECRET - OAuth client secret
- REDDIT_USERNAME - Your Reddit account username
- REDDIT_PASSWORD - Your Reddit account password
- SUBREDDIT - Target subreddit name
Optional variables:
- REDDIT_RELEASE_TYPES - Comma-separated types (default: release)
- Examples: "release", "release,snapshot"
- REDDIT_CHECK_BEDROCK - Enable Bedrock Edition detection (default: false)
- Set to "true" or "false"
- REDDIT_CHECK_INTERVAL - Seconds between checks (default: 3600)
- Example: 600 for 10-minute checks
- REDDIT_WIKI_PAGE_NAME - Post template wiki page name (default: minecraft_update_bot)
- REDDIT_USER_AGENT - API user agent (default: MinecraftUpdateBot/1.0)
Configuration File
Edit .env to control all behavior. Example with all options:
REDDIT_CLIENT_ID=abc123
REDDIT_CLIENT_SECRET=xyz789
REDDIT_USERNAME=mybot
REDDIT_PASSWORD=botpass
SUBREDDIT=mysubreddit
REDDIT_RELEASE_TYPES=release,snapshot
REDDIT_CHECK_BEDROCK=true
REDDIT_CHECK_INTERVAL=3600
REDDIT_WIKI_PAGE_NAME=minecraft_update_bot
REDDIT_USER_AGENT=MinecraftUpdateBot/1.0
Container Management
Start the bot:
docker-compose up -d
Stop the bot:
docker-compose down
Restart the bot:
docker-compose restart
Rebuild after code changes:
docker-compose build --no-cache
docker-compose up -d
View logs:
docker-compose logs -f minecraftupdatebot
View specific log entries:
docker-compose logs minecraftupdatebot | grep "[BOT]"
Data Persistence
The bot's version database persists in a Docker volume named minecraft-bot-db.
View volume details:
docker volume inspect minecraft-bot-db
The database file is located at /app/DB/posted_versions.json inside the container.
Reset the database (allows reposting all versions):
docker-compose down
docker volume rm minecraft-bot-db
docker-compose up -d
Check database contents from host:
docker run --rm -v minecraft-bot-db:/data alpine cat /data/posted_versions.json
Wiki Configuration
The bot loads post templates from a subreddit wiki page (default name: minecraft_update_bot).
Create the wiki page on your subreddit with YAML configuration:
release:
title: "Minecraft {version} Released"
body: |
New version available!
Version: {version}
Released: {release_date}
snapshot:
title: "Minecraft {version} Snapshot"
body: |
Test build available
Released: {release_date}
bedrock-windows:
title: "Bedrock Edition {version} Available"
body: |
Bedrock update available
Released: {release_date}
See WIKI_CONFIG.md for complete documentation.
Monitoring
Check bot status:
docker-compose ps
Monitor logs in real-time:
docker-compose logs -f
Look for these status messages:
- [BOT] Successfully connected to Reddit
- [BOT] Started update checker
- [BOT] New Java release found
- [BOT] New Bedrock release found
- [BOT] Posted Minecraft
For errors, look for:
- [BOT] Error messages
- [BEDROCK_CHECKER] Error messages
- [CHAT] Error messages
Troubleshooting
Container won't start:
docker-compose logs
Check for missing credentials or configuration errors.
Reddit authentication fails:
- Verify credentials in .env are correct
- Check Reddit app still exists at https://www.reddit.com/prefs/apps
- Ensure the bot account has permission to post to the subreddit
No posts being made:
- Check logs:
docker-compose logs -f - Verify subreddit name in REDDIT_SUBREDDIT env var
- Check database:
docker run --rm -v minecraft-bot-db:/data alpine cat /data/posted_versions.json - Verify wiki configuration loaded: Look for "[WIKI_CONFIG] Loaded" in logs
Bedrock detection not working:
- Ensure REDDIT_CHECK_BEDROCK is set to "true" in .env
- Check logs for minecraft.wiki scraping errors
- Bedrock detection requires internet access to minecraft.wiki
Chat commands not working:
- Only subreddit moderators can send commands
- Send messages containing "reload-config" or "repost-latest"
- Check logs for [CHAT] messages
Network Access
The bot requires:
- Reddit API connectivity (PRAW library)
- Minecraft launcher manifest (launchermeta.mojang.com)
- minecraft.wiki (for Bedrock detection if enabled)
- Update server (updts.slfhstd.uk for bot version checking)
If behind a proxy, configure Docker networking accordingly.
Performance
Default settings:
- Checks every 3600 seconds (1 hour)
- Allows 86400 seconds (24 hours) between update notifications
- Wiki config refreshes on each check (cached for 5 minutes)
For testing with faster checks:
REDDIT_CHECK_INTERVAL=300
For production (less frequent):
REDDIT_CHECK_INTERVAL=7200
Security
Best practices:
- Never commit .env file with real credentials to version control
- .env is listed in .gitignore by default
- Use Reddit app credentials, not your personal account password if possible
- Restrict subreddit moderator permissions for bot accounts
- Review logs regularly for unauthorized access attempts
Resource Limits
Uncomment and adjust in docker-compose.yml:
deploy:
resources:
limits:
cpus: '0.5'
memory: 256M
Running Multiple Instances
Create separate directories with different .env files and run:
docker-compose -p instance1 up -d
docker-compose -p instance2 up -d
Getting Reddit Credentials
- Go to https://www.reddit.com/prefs/apps
- Click "Create an app" or "Create another app"
- Choose "Script" application type
- Fill in the form:
- Name: MinecraftUpdateBot
- Redirect URI: http://localhost:8080
- Copy Client ID and Client Secret from the app page
- Use your Reddit username and password
Docker Commands Reference
# Start the bot
docker-compose up -d
# Stop the bot
docker-compose down
# Restart the bot
docker-compose restart
# View logs
docker-compose logs -f
# Check status
docker-compose ps
# Execute a command in the container
docker exec minecraft-bot python test_setup.py
# Remove everything (including volumes)
docker-compose down -v