4.4 KiB
Running with Docker Compose
This project includes Docker and Docker Compose configuration for easy deployment.
Prerequisites
- Docker installed
- Docker Compose installed
Quick Start
1. Copy Environment File
copy .env.example .env
2. Edit .env
Open .env and fill in 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
3. (Optional) Set Up Wiki Configuration
Create a wiki page on your subreddit named minecraft_update_bot with your post templates in YAML format. This allows different posts for releases, snapshots, etc.
See WIKI_CONFIG.md for detailed instructions and examples.
4. Start the Bot
docker-compose up -d
This will:
- Build the Docker image
- Start the bot in a container
- Persist data in a Docker volume named
minecraft-bot-db - Auto-restart the container if it crashes
5. View Logs
# Watch logs in real-time
docker-compose logs -f
# Or check status
docker-compose ps
5. Stop the Bot
docker-compose down
Configuration
All configuration is done via the .env file. The following variables are available:
| Variable | Required | Default | Description |
|---|---|---|---|
REDDIT_CLIENT_ID |
✓ | - | Your Reddit app client ID |
REDDIT_CLIENT_SECRET |
✓ | - | Your Reddit app secret |
REDDIT_USERNAME |
✓ | - | Your Reddit username |
REDDIT_PASSWORD |
✓ | - | Your Reddit password |
SUBREDDIT |
✓ | - | Subreddit to post to |
RELEASE_TYPES |
release |
Comma-separated: release,snapshot |
|
CHECK_BEDROCK |
false |
Enable Bedrock Edition detection: true or false |
|
CHECK_INTERVAL |
3600 |
Seconds between checks | |
REDDIT_USER_AGENT |
MinecraftUpdateBot/1.0 |
API user agent |
Examples
Check for both releases and snapshots:
RELEASE_TYPES=release,snapshot
Check every 10 minutes (for testing):
CHECK_INTERVAL=600
Data Persistence
The bot's database (list of posted versions) is stored in a Docker volume called minecraft-bot-db. This persists between container restarts.
To view the data:
docker volume inspect minecraft-bot-db
To reset the database (post all versions again):
docker volume rm minecraft-bot-db
Building
To rebuild the image after code changes:
docker-compose build --no-cache
docker-compose up -d
Troubleshooting
Container won't start
docker-compose logs
Check for configuration errors or missing credentials.
Reddit authentication error
- Verify your credentials in
.env - Check that your Reddit app still exists at https://www.reddit.com/prefs/apps
- Make sure your account can post to the subreddit
No posts being made
- Check the logs:
docker-compose logs -f - Verify the subreddit name in
.env - Check
docker exec minecraft-bot cat /app/DB/posted_versions.jsonto see what's been posted
Advanced Options
Custom Post Template
Mount your config file to customize the post format:
Edit docker-compose.yml:
volumes:
- minecraft-bot-db:/app/DB
- ./config.py:/app/config.py # Uncomment this line
Then edit config.py locally to customize POST_TEMPLATE.
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