303 lines
6.7 KiB
Markdown
303 lines
6.7 KiB
Markdown
# Docker Deployment Guide
|
|
|
|
## Prerequisites
|
|
|
|
- Docker installed
|
|
- Docker Compose installed
|
|
|
|
## Quick Start
|
|
|
|
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:
|
|
|
|
```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
|
|
```
|
|
|
|
## Container Management
|
|
|
|
Start the bot:
|
|
```bash
|
|
docker-compose up -d
|
|
```
|
|
|
|
Stop the bot:
|
|
```bash
|
|
docker-compose down
|
|
```
|
|
|
|
Restart the bot:
|
|
```bash
|
|
docker-compose restart
|
|
```
|
|
|
|
Rebuild after code changes:
|
|
```bash
|
|
docker-compose build --no-cache
|
|
docker-compose up -d
|
|
```
|
|
|
|
View logs:
|
|
```bash
|
|
docker-compose logs -f minecraftupdatebot
|
|
```
|
|
|
|
View specific log entries:
|
|
```bash
|
|
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:
|
|
```bash
|
|
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):
|
|
```bash
|
|
docker-compose down
|
|
docker volume rm minecraft-bot-db
|
|
docker-compose up -d
|
|
```
|
|
|
|
Check database contents from host:
|
|
```bash
|
|
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:
|
|
|
|
```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}
|
|
```
|
|
|
|
See WIKI_CONFIG.md for complete documentation.
|
|
|
|
## Monitoring
|
|
|
|
Check bot status:
|
|
```bash
|
|
docker-compose ps
|
|
```
|
|
|
|
Monitor logs in real-time:
|
|
```bash
|
|
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:
|
|
```bash
|
|
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:
|
|
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
|
|
|
|
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:
|
|
```env
|
|
REDDIT_CHECK_INTERVAL=300
|
|
```
|
|
|
|
For production (less frequent):
|
|
```env
|
|
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`:
|
|
```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
|
|
```
|