# backend/Dockerfile
FROM python:3.12-slim

WORKDIR /app

# Set environment variables to prevent buffering issues with logs
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Install dependencies
COPY ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Copy application code (AFTER installing dependencies for better caching)
COPY . /app/

RUN adduser --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser