🛠️ Initial Docker support added — build likely broken, expect fixes in next patch

This commit is contained in:
milo 2025-05-10 00:26:28 -04:00
parent e0191b12b3
commit 1a39a39d84
6 changed files with 50 additions and 4 deletions

4
.env Normal file
View file

@ -0,0 +1,4 @@
DISCORD_TOKEN=your_real_discord_token_here
OLLAMA_API=http://localhost:11434
MODEL_NAME=llama3:latest
CHANNEL_ID=123456789012345678

22
Dockerfile Normal file
View file

@ -0,0 +1,22 @@
# Use Python base image
FROM python:3.11.9-slim
# Set working directory inside container
WORKDIR /app
# Copy requirements first (from host into /app inside container)
COPY src/requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy all app source code
COPY src/ ./src
COPY settings.yml .
COPY .env .
# Set environment variable so your app can find your src/ module
ENV PYTHONPATH=/app/src
# Run the bot
CMD ["python", "src/bot.py"]

14
docker-compose.yml Normal file
View file

@ -0,0 +1,14 @@
version: "3.9"
services:
discord-bot:
build: .
container_name: mirage-bot
environment:
- DISCORD_TOKEN=${DISCORD_TOKEN}
- CHANNEL_ID=${CHANNEL_ID}
- OLLAMA_API=${OLLAMA_API}
- MODEL_NAME=${MODEL_NAME}
volumes:
- ./settings.yml:/app/settings.yml:ro
restart: unless-stopped

View file

@ -1,2 +0,0 @@
DISCORD_TOKEN=MTM2OTc3NDY4OTYzNDg4MTU4Ng.G9Nrgz.akHoOO9SrXCDwiOCI3BUXfdR4bpSNb9zrVx9UI
OLLAMA_API_URL=http://192.168.1.100:11434/api/generate

View file

@ -5,6 +5,10 @@ import discord
import yaml
from discord.ext import commands
from dotenv import load_dotenv
dotenv_path = os.path.join(os.path.dirname(__file__), '..', '.env')
load_dotenv(dotenv_path)
from ai import get_ai_response
from personality import apply_personality, set_persona
from discord.ext.commands import (

View file

@ -1,4 +1,4 @@
# __init__.py formaly know as scheduler.py
# __init__.py formerly known as scheduler.py
import os
import yaml
@ -17,6 +17,11 @@ async def start_scheduler(bot):
settings = load_settings()
scheduler_settings = settings.get("scheduler", {})
# Override channel_id with environment variable if set
channel_id_env = os.getenv("CHANNEL_ID")
if channel_id_env:
scheduler_settings["channel_id"] = int(channel_id_env)
if not scheduler_settings.get("enabled", False):
print("🛑 Scheduler disabled in config.")
return
@ -52,7 +57,6 @@ async def start_scheduler(bot):
await asyncio.sleep(interval * 60)
elif mode == "inactivity":
await inactivity.run(bot, scheduler_settings, settings)