-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.api
More file actions
32 lines (24 loc) · 1.03 KB
/
Copy pathDockerfile.api
File metadata and controls
32 lines (24 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# ---- CFDQandA API Server ----
# Lightweight container for the FastAPI API server.
# Does NOT include Foam-Agent, OpenFOAM, or Worker — those live in Dockerfile.worker.
#
# Build: docker build -f Dockerfile.api -t cfdqanda-api .
# Run: docker run -p 8000:8000 --env-file .env cfdqanda-api
# Size: ~200 MB
FROM python:3.12-slim
# Prevent Python from writing .pyc files and enable unbuffered stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /app
# Install dependencies first (layer caching — only re-run if requirements change)
COPY requirements-api.txt .
RUN pip install --no-cache-dir -r requirements-api.txt
# Copy application code
COPY api_server.py .
# Expose the API port
EXPOSE 8000
# Health check: hit the root endpoint every 30s
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/')" || exit 1
# Run with uvicorn
CMD ["uvicorn", "api_server:app", "--host", "0.0.0.0", "--port", "8000"]