Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/trustlessmatt/discord-exporter-bot/llms.txt

Use this file to discover all available pages before exploring further.

The Discord Exporter Bot includes a production-ready Dockerfile for containerized deployment. This guide covers building, running, and configuring the bot with Docker.

Dockerfile Overview

The bot uses a lightweight Python 3.11 slim image with Git support for GitHub integration:
Dockerfile
FROM python:3.11-slim

# Install git (required for GitHub sync)
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy bot code
COPY bot.py .

# Create directories
RUN mkdir -p /app/exports /app/digests

# Run the bot
CMD ["python", "-u", "bot.py"]
Key Features:
  • Based on python:3.11-slim for minimal image size
  • Includes git for GitHub digest synchronization
  • Creates /app/exports and /app/digests directories
  • Uses unbuffered Python output (-u) for real-time logs
  • No entrypoint script - runs bot.py directly

Building the Image

1

Prepare your workspace

Ensure you have all required files:
.
├── bot.py
├── requirements.txt
├── Dockerfile
└── .env
2

Build the image

docker build -t discord-exporter-bot .
Build output:
[+] Building 45.2s (11/11) FINISHED
=> [1/6] FROM python:3.11-slim
=> [2/6] RUN apt-get update && apt-get install -y git
=> [3/6] WORKDIR /app
=> [4/6] COPY requirements.txt .
=> [5/6] RUN pip install --no-cache-dir -r requirements.txt
=> [6/6] COPY bot.py .
=> exporting to image
3

Verify the image

docker images | grep discord-exporter-bot
Expected output:
discord-exporter-bot   latest   abc123def456   2 minutes ago   245MB

Running the Container

Basic Usage

Minimal setup for message exports only:
docker run -d \
  --name discord-bot \
  --env-file .env \
  discord-exporter-bot

With Volume Mounts

Recommended for persistent storage of exports and digests:
docker run -d \
  --name discord-bot \
  --env-file .env \
  -v $(pwd)/exports:/app/exports \
  -v $(pwd)/digests:/app/digests \
  discord-exporter-bot
Volume Mapping:
  • /app/exports → Local JSON export files
  • /app/digests → Local Markdown digest files

Full Production Setup

With all features enabled and persistent volumes:
docker run -d \
  --name discord-bot \
  --restart unless-stopped \
  --env-file .env \
  -v $(pwd)/exports:/app/exports \
  -v $(pwd)/digests:/app/digests \
  -v $(pwd)/data:/app/data \
  discord-exporter-bot
Additional options:
  • --restart unless-stopped → Auto-restart on failure
  • -v $(pwd)/data:/app/data → For DOKPLOY_VOLUME_PATH=/app/data

Docker Compose

For easier management and configuration:
version: '3.8'

services:
  discord-bot:
    build: .
    container_name: discord-exporter-bot
    restart: unless-stopped
    env_file:
      - .env
    volumes:
      - ./exports:/app/exports
      - ./digests:/app/digests
Usage:
1

Start the bot

docker-compose up -d
2

View logs

docker-compose logs -f discord-bot
3

Stop the bot

docker-compose down
4

Rebuild after changes

docker-compose up -d --build

Environment Variables in Docker

You can pass environment variables to the container in multiple ways:
docker run -d --env-file .env discord-exporter-bot
Your .env file:
DISCORD_TOKEN=MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.GhIjKl.xxx
GUILD_ID=123456789012345678
ANTHROPIC_API_KEY=sk-ant-api03-xxx
DOKPLOY_VOLUME_PATH=/app/data
GITHUB_REPO_URL=https://github.com/user/repo.git
GITHUB_TOKEN=ghp_xxx

Method 2: Individual -e flags

docker run -d \
  -e DISCORD_TOKEN="MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.GhIjKl.xxx" \
  -e GUILD_ID="123456789012345678" \
  -e ANTHROPIC_API_KEY="sk-ant-api03-xxx" \
  discord-exporter-bot

Method 3: Docker Compose with env_file

services:
  discord-bot:
    env_file:
      - .env
    environment:
      - DOKPLOY_VOLUME_PATH=/app/data

Volume Mounting Explained

The bot creates files in specific directories that you’ll want to persist:

Exports Directory (/app/exports)

Created by: !export command and perform_export() function (bot.py:238) File format: discord_export_YYYYMMDD_HHMMSS_ET.json Example:
{
  "guild_name": "My Team Server",
  "export_time_eastern": "2026-03-04T15:30:00-05:00",
  "time_range_hours": 24,
  "channels": {
    "general": {
      "channel_id": "123456789",
      "messages": [...]
    }
  }
}
Docker mount:
-v $(pwd)/exports:/app/exports

Digests Directory (/app/digests)

Created by: !digest command and scheduled task (bot.py:379-399) File format: YYYY-MM-DD - Team Digest.md Example:
---
date: 2026-03-04
type: daily-digest
tags: [team, standup, daily]
---

# Team Digest - 2026-03-04

**📊 Activity Summary**
- 42 messages across 3 channels
- 5 active team members
Docker mount:
-v $(pwd)/digests:/app/digests

Data Volume (Optional)

For DOKPLOY_VOLUME_PATH or custom persistent storage:
-v $(pwd)/data:/app/data
Set in your .env:
DOKPLOY_VOLUME_PATH=/app/data
The bot will save digests to /app/data/Daily Digests/ (bot.py:334-338).

Container Management

View Logs

# Real-time logs
docker logs -f discord-bot

# Last 100 lines
docker logs --tail 100 discord-bot

# Logs since 1 hour ago
docker logs --since 1h discord-bot
Expected startup logs:
2026-03-04 15:30:00 - INFO - Bot has connected to Discord!
2026-03-04 15:30:00 - INFO - Bot is in 1 guild(s)
2026-03-04 15:30:00 - INFO - Connected to: My Team Server
2026-03-04 15:30:00 - INFO - Text channels: 5
2026-03-04 15:30:00 - INFO - Daily digest task started
2026-03-04 15:30:00 - INFO - ⏰ Waiting 8.5 hours until first digest at 0:00am ET

Restart Container

docker restart discord-bot

Stop and Remove

docker stop discord-bot
docker rm discord-bot

Access Container Shell

docker exec -it discord-bot /bin/bash
Useful for debugging:
# Check if exports exist
ls -lh /app/exports/

# Check digest files
ls -lh /app/digests/

# Verify git repo (if GitHub sync enabled)
cd /app/data/Daily\ Digests && git status

Troubleshooting

Bot crashes on startup

Check environment variables:
docker run --rm --env-file .env discord-exporter-bot python -c "import os; print('DISCORD_TOKEN:', os.getenv('DISCORD_TOKEN')[:20] if os.getenv('DISCORD_TOKEN') else 'NOT SET')"

Volumes not persisting

Verify mounts:
docker inspect discord-bot | grep -A 10 Mounts
Expected output:
"Mounts": [
    {
        "Type": "bind",
        "Source": "/home/user/discord-bot/exports",
        "Destination": "/app/exports",
        "Mode": "",
        "RW": true
    }
]

GitHub sync fails

Check git installation:
docker exec discord-bot git --version
Check git configuration:
docker exec discord-bot git config --list

Permission issues

Fix volume permissions:
# On host
sudo chown -R $(id -u):$(id -g) ./exports ./digests ./data

# Or run container as specific user
docker run -d --user $(id -u):$(id -g) --env-file .env discord-exporter-bot

Health Checks

Add a health check to your Docker setup:
docker-compose.yml
services:
  discord-bot:
    build: .
    healthcheck:
      test: ["CMD-SHELL", "ps aux | grep 'python.*bot.py' || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
Or in docker run:
docker run -d \
  --health-cmd="ps aux | grep 'python.*bot.py' || exit 1" \
  --health-interval=30s \
  --health-timeout=10s \
  --health-retries=3 \
  --env-file .env \
  discord-exporter-bot

Production Recommendations

Always mount /app/exports and /app/digests to prevent data loss during container restarts or updates.
Use --restart unless-stopped to ensure the bot automatically recovers from crashes or server reboots.
Use Docker’s logging drivers to prevent logs from consuming disk space:
logging:
  driver: "json-file"
  options:
    max-size: "10m"
    max-file: "3"
Never commit .env files to version control. Use Docker secrets for production:
echo "MTIzNDU2..." | docker secret create discord_token -
Check container stats:
docker stats discord-bot

Build docs developers (and LLMs) love