Files
MinecraftUpdates/DOCKER.md
T

303 lines
6.7 KiB
Markdown
Raw Permalink Normal View History

2026-03-12 21:45:01 +00:00
# Docker Deployment Guide
2026-03-11 23:24:42 +00:00
## Prerequisites
- Docker installed
- Docker Compose installed
## Quick Start
2026-03-12 21:45:01 +00:00
1. Copy environment template:
```bash
copy .env.example .env
```
2. Edit `.env` with your Reddit credentials:
```env
REDDIT_CLIENT_ID=your_client_id
REDDIT_CLIENT_SECRET=your_client_secret
REDDIT_USERNAME=your_username
REDDIT_PASSWORD=your_password
SUBREDDIT=your_subreddit
```
3. Start the bot:
```bash
docker-compose up -d
```
4. Verify it's running:
```bash
docker-compose ps
```
5. View logs:
```bash
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:
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
```env
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
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
## Container Management
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Start the bot:
```bash
docker-compose up -d
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
Stop the bot:
```bash
docker-compose down
```
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Restart the bot:
```bash
docker-compose restart
```
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Rebuild after code changes:
```bash
docker-compose build --no-cache
docker-compose up -d
```
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
View logs:
```bash
docker-compose logs -f minecraftupdatebot
```
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
View specific log entries:
2026-03-11 23:24:42 +00:00
```bash
2026-03-12 21:45:01 +00:00
docker-compose logs minecraftupdatebot | grep "[BOT]"
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
## Data Persistence
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
The bot's version database persists in a Docker volume named `minecraft-bot-db`.
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
View volume details:
2026-03-11 23:24:42 +00:00
```bash
2026-03-12 21:45:01 +00:00
docker volume inspect minecraft-bot-db
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
The database file is located at `/app/DB/posted_versions.json` inside the container.
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Reset the database (allows reposting all versions):
2026-03-11 23:24:42 +00:00
```bash
docker-compose down
2026-03-12 21:45:01 +00:00
docker volume rm minecraft-bot-db
docker-compose up -d
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
Check database contents from host:
```bash
docker run --rm -v minecraft-bot-db:/data alpine cat /data/posted_versions.json
```
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
## Wiki Configuration
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
The bot loads post templates from a subreddit wiki page (default name: minecraft_update_bot).
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Create the wiki page on your subreddit with YAML configuration:
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
```yaml
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}
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
See WIKI_CONFIG.md for complete documentation.
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
## Monitoring
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Check bot status:
2026-03-11 23:24:42 +00:00
```bash
2026-03-12 21:45:01 +00:00
docker-compose ps
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
Monitor logs in real-time:
2026-03-11 23:24:42 +00:00
```bash
2026-03-12 21:45:01 +00:00
docker-compose logs -f
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
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
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
For errors, look for:
- [BOT] Error messages
- [BEDROCK_CHECKER] Error messages
- [CHAT] Error messages
2026-03-11 23:24:42 +00:00
## Troubleshooting
2026-03-12 21:45:01 +00:00
Container won't start:
2026-03-11 23:24:42 +00:00
```bash
docker-compose logs
```
2026-03-12 21:45:01 +00:00
Check for missing credentials or configuration errors.
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
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
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
No posts being made:
1. Check logs: `docker-compose logs -f`
2. Verify subreddit name in REDDIT_SUBREDDIT env var
3. Check database: `docker run --rm -v minecraft-bot-db:/data alpine cat /data/posted_versions.json`
4. Verify wiki configuration loaded: Look for "[WIKI_CONFIG] Loaded" in logs
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
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
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
Chat commands not working:
- Only subreddit moderators can send commands
- Send messages containing "reload-config" or "repost-latest"
- Check logs for [CHAT] messages
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
## Network Access
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
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)
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
If behind a proxy, configure Docker networking accordingly.
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
## Performance
2026-03-11 23:24:42 +00:00
2026-03-12 21:45:01 +00:00
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:
```env
REDDIT_CHECK_INTERVAL=300
```
For production (less frequent):
```env
REDDIT_CHECK_INTERVAL=7200
2026-03-11 23:24:42 +00:00
```
2026-03-12 21:45:01 +00:00
## 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
2026-03-11 23:24:42 +00:00
### Resource Limits
Uncomment and adjust in `docker-compose.yml`:
```yaml
deploy:
resources:
limits:
cpus: '0.5'
memory: 256M
```
### Running Multiple Instances
Create separate directories with different `.env` files and run:
```bash
docker-compose -p instance1 up -d
docker-compose -p instance2 up -d
```
## Getting Reddit Credentials
1. Go to https://www.reddit.com/prefs/apps
2. Click "Create an app" or "Create another app"
3. Choose "Script" application type
4. Fill in the form:
- **Name:** MinecraftUpdateBot
- **Redirect URI:** http://localhost:8080
5. Copy Client ID and Client Secret from the app page
6. Use your Reddit username and password
## Docker Commands Reference
```bash
# 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
```