# Credential-pool server: arcobi-sdk with the [pool-server] extra.
# Build from the repository root:  docker build -f deploy/pool-server/Dockerfile -t arcobi-pool-server .
FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    POOL_HOST=0.0.0.0 \
    POOL_PORT=8002

RUN apt-get update \
    && apt-get install -y --no-install-recommends curl \
    && rm -rf /var/lib/apt/lists/* \
    && useradd --create-home --uid 10001 pool

WORKDIR /build

# Copy the sources first so the install sees the whole package.
COPY pyproject.toml README.md ./
COPY src ./src
RUN pip install --upgrade pip && pip install "./[pool-server]" && rm -rf /build

WORKDIR /app
USER pool

HEALTHCHECK --interval=15s --timeout=5s --retries=5 \
    CMD curl -fsS "http://127.0.0.1:${POOL_PORT}/health" || exit 1

EXPOSE 8002
CMD ["python", "-m", "arcobi_sdk.pool.server"]
