FROM --platform=linux/amd64 python:3.12-slim

WORKDIR /app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY server.py ./

RUN groupadd --gid 1001 agent && \
    useradd --uid 1001 --gid 1001 --no-create-home --shell /usr/sbin/nologin agent
USER 1001:1001

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    TMPDIR=/tmp \
    SERVER_PORT=8001
EXPOSE 8001

CMD ["python", "server.py"]
