initial
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
# 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
|
||||
|
||||
```bash
|
||||
copy .env.example .env
|
||||
```
|
||||
|
||||
### 2. Edit .env
|
||||
|
||||
Open `.env` and fill in 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. (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](WIKI_CONFIG.md) for detailed instructions and examples.
|
||||
|
||||
### 4. Start the Bot
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
# Watch logs in real-time
|
||||
docker-compose logs -f
|
||||
|
||||
# Or check status
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
### 5. Stop the Bot
|
||||
|
||||
```bash
|
||||
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_INTERVAL` | | `3600` | Seconds between checks |
|
||||
| `REDDIT_USER_AGENT` | | `MinecraftUpdateBot/1.0` | API user agent |
|
||||
|
||||
### Examples
|
||||
|
||||
**Check for both releases and snapshots:**
|
||||
```env
|
||||
RELEASE_TYPES=release,snapshot
|
||||
```
|
||||
|
||||
**Check every 10 minutes (for testing):**
|
||||
```env
|
||||
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:
|
||||
```bash
|
||||
docker volume inspect minecraft-bot-db
|
||||
```
|
||||
|
||||
To reset the database (post all versions again):
|
||||
```bash
|
||||
docker volume rm minecraft-bot-db
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
To rebuild the image after code changes:
|
||||
|
||||
```bash
|
||||
docker-compose build --no-cache
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Container won't start
|
||||
|
||||
```bash
|
||||
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.json` to see what's been posted
|
||||
|
||||
## Advanced Options
|
||||
|
||||
### Custom Post Template
|
||||
|
||||
Mount your config file to customize the post format:
|
||||
|
||||
Edit `docker-compose.yml`:
|
||||
```yaml
|
||||
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`:
|
||||
```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
|
||||
```
|
||||
Reference in New Issue
Block a user