# Dockerfile for Excommunicado Discord Bot
FROM python:3.12-slim

# Unbuffered stdout/stderr so logs appear immediately in `docker logs`
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    LOG_LEVEL=INFO

# Set working directory
WORKDIR /app

# 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 non-root user and give it ownership of the app + data directory.
# UID/GID 1000 is referenced by the named-volume / chown instructions in the README.
RUN useradd -m -u 1000 botuser \
    && mkdir -p /app/data \
    && chown -R botuser:botuser /app
USER botuser

# Run the bot
CMD ["python", "bot.py"]
