25 lines
930 B
Docker
25 lines
930 B
Docker
# Standalone FastAPI API image. Does not replace the data-management CLI image.
|
|
FROM python:3.11-slim
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PYTHONPATH=/app/src/api \
|
|
PORT=10000
|
|
|
|
WORKDIR /app
|
|
|
|
COPY deploy/docker/api-requirements.txt /tmp/api-requirements.txt
|
|
RUN python -m pip install --no-cache-dir -r /tmp/api-requirements.txt \
|
|
&& useradd --system --uid 10001 --create-home bearingapi
|
|
|
|
COPY --chown=bearingapi:bearingapi src/api/ /app/src/api/
|
|
|
|
USER bearingapi
|
|
EXPOSE 10000
|
|
|
|
# The Docker daemon probes the actual API health route using stdlib only.
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
|
CMD python -c "import os; from urllib.request import urlopen; urlopen('http://127.0.0.1:'+os.getenv('PORT','10000')+'/health',timeout=3).close()" || exit 1
|
|
|
|
CMD ["sh", "-c", "exec uvicorn main:app --app-dir src/api --host 0.0.0.0 --port ${PORT:-10000} --proxy-headers"]
|