Files
loyal_companion/Dockerfile
2026-01-10 21:46:27 +01:00

39 lines
841 B
Docker

# Stage 1: Build dependencies
FROM python:3.11-slim as builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
# Stage 2: Runtime
FROM python:3.11-slim
WORKDIR /app
# Create non-root user for security
RUN useradd --create-home --shell /bin/bash botuser
# Copy wheels from builder and install
COPY --from=builder /app/wheels /wheels
RUN pip install --no-cache /wheels/* && rm -rf /wheels
# Copy application code
COPY src/ ./src/
# Set Python path
ENV PYTHONPATH=/app/src
ENV PYTHONUNBUFFERED=1
# Switch to non-root user
USER botuser
# Run the bot
CMD ["python", "-m", "daemon_boyfriend"]