FROM python:3.12-slim

WORKDIR /app

# Install deps first for layer caching.
COPY pyproject.toml ./
COPY axon ./axon
RUN pip install --no-cache-dir .

ENV AXON_HOST=0.0.0.0 \
    AXON_PORT=8080

EXPOSE 8080

# Healthcheck hits the unauthenticated /healthz route.
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
  CMD python -c "import urllib.request,os; urllib.request.urlopen('http://127.0.0.1:'+os.environ.get('AXON_PORT','8080')+'/healthz')" || exit 1

CMD ["python", "-m", "axon.server"]
