🛠️ Initial Docker support added — build likely broken, expect fixes in next patch
This commit is contained in:
parent
e0191b12b3
commit
1a39a39d84
6 changed files with 50 additions and 4 deletions
4
.env
Normal file
4
.env
Normal 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
22
Dockerfile
Normal 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
14
docker-compose.yml
Normal 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
|
||||||
2
src/.env
2
src/.env
|
|
@ -1,2 +0,0 @@
|
||||||
DISCORD_TOKEN=MTM2OTc3NDY4OTYzNDg4MTU4Ng.G9Nrgz.akHoOO9SrXCDwiOCI3BUXfdR4bpSNb9zrVx9UI
|
|
||||||
OLLAMA_API_URL=http://192.168.1.100:11434/api/generate
|
|
||||||
|
|
@ -5,6 +5,10 @@ import discord
|
||||||
import yaml
|
import yaml
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from dotenv import load_dotenv
|
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 ai import get_ai_response
|
||||||
from personality import apply_personality, set_persona
|
from personality import apply_personality, set_persona
|
||||||
from discord.ext.commands import (
|
from discord.ext.commands import (
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# __init__.py formaly know as scheduler.py
|
# __init__.py formerly known as scheduler.py
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
|
@ -17,6 +17,11 @@ async def start_scheduler(bot):
|
||||||
settings = load_settings()
|
settings = load_settings()
|
||||||
scheduler_settings = settings.get("scheduler", {})
|
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):
|
if not scheduler_settings.get("enabled", False):
|
||||||
print("🛑 Scheduler disabled in config.")
|
print("🛑 Scheduler disabled in config.")
|
||||||
return
|
return
|
||||||
|
|
@ -52,7 +57,6 @@ async def start_scheduler(bot):
|
||||||
|
|
||||||
await asyncio.sleep(interval * 60)
|
await asyncio.sleep(interval * 60)
|
||||||
|
|
||||||
|
|
||||||
elif mode == "inactivity":
|
elif mode == "inactivity":
|
||||||
await inactivity.run(bot, scheduler_settings, settings)
|
await inactivity.run(bot, scheduler_settings, settings)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue