FROM python:3.12-slim@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
COPY requirements.runtime.txt /tmp/requirements.lock
COPY dist/unexhub_agent-*.whl /tmp/runtime/
RUN pip install --no-cache-dir -r /tmp/requirements.lock \
    && pip install --no-cache-dir --no-deps /tmp/runtime/unexhub_agent-*.whl
COPY template/ /app/
RUN chown -R 10001:10001 /app
USER 10001:10001
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
    CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health', timeout=2)"
ENTRYPOINT ["unexhub-agent", "serve", "--config", "/app/agent.yaml"]
