diff --git a/Dockerfile.api b/Dockerfile.api index b6d91714..196b5a15 100644 --- a/Dockerfile.api +++ b/Dockerfile.api @@ -1,18 +1,16 @@ -FROM python:3.12-slim - -WORKDIR /app - -RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - curl \ - git \ +FROM python:3.12-slim AS builder +RUN apt-get update && apt-get install -y --no-install-recommends build-essential git \ && rm -rf /var/lib/apt/lists/* - +WORKDIR /build COPY . . +RUN pip wheel --no-cache-dir --wheel-dir /wheels . -RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -e . - +FROM python:3.12-slim AS runtime +RUN useradd --create-home --uid 10001 agentwatch +COPY --from=builder /wheels /wheels +RUN pip install --no-cache-dir /wheels/*.whl && rm -rf /wheels +USER agentwatch EXPOSE 8000 - +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1 CMD ["uvicorn", "agentwatch.api.server:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file