From 9ca7d35ce07844c27ae8ae694907ad2b3979108e Mon Sep 17 00:00:00 2001 From: Subinacls Date: Mon, 8 Jun 2026 21:20:20 -0400 Subject: [PATCH] added docker --- .dockerignore | 31 +++++++++++++++++++++++++++++++ Dockerfile | 29 +++++++++++++++++++++++++++++ README.md | 26 ++++++++++++++++++++++++++ docker-compose.yml | 22 ++++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..addae8e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,31 @@ +# Docker ignore file for Excommunicado + +# Environment & secrets +.env +.env.* + +# Data directory (we mount it as volume instead) +data/ + +# Git +.git +.gitignore + +# Python +__pycache__/ +*.py[cod] +*.egg-info/ +.venv/ +venv/ + +# IDE / OS +.vscode/ +.idea/ +*.log +Thumbs.db +.DS_Store + +# Docker +Dockerfile +.dockerignore +docker-compose*.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3f757e2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Dockerfile for Excommunicado Discord Bot +FROM python:3.12-slim + +# Set working directory +WORKDIR /app + +# Install system dependencies (if needed) +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# Copy requirements first (better layer caching) +COPY requirements.txt . + +# Install Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application +COPY . . + +# Create data directory for persistence +RUN mkdir -p /app/data + +# Create non-root user for security +RUN useradd -m botuser && chown -R botuser:botuser /app +USER botuser + +# Run the bot +CMD ["python", "bot.py"] diff --git a/README.md b/README.md index 0e751ef..d51aa04 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,32 @@ Ideal for: ## Installation & Quick Start +### Docker Deployment (Recommended) + +1. Make sure you have Docker and Docker Compose installed. +2. Copy `.env.example` → `.env` and fill in your token. +3. Build and run the container: + +```powershell +docker compose up -d --build +``` + +The bot runs as a non-root user with healthchecks and log rotation. + +To view logs: +```powershell +docker compose logs -f excommunicado-bot +``` + +To stop: +```powershell +docker compose down +``` + +--- + +### Manual Installation (Non-Docker) + ### 1. Prepare the project ``` cd ~/Excommunicado # or your chosen folder diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7af471f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: "3.9" + +services: + excommunicado: + build: . + container_name: excommunicado-bot + restart: unless-stopped + env_file: + - .env + volumes: + - ./data:/app/data + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + healthcheck: + test: ["CMD", "python", "-c", "import sys; sys.exit(0)"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s