Create Dockerfile
Browse files- Dockerfile +31 -0
Dockerfile
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ---------- base image ----------
|
2 |
+
FROM python:3.11-slim
|
3 |
+
|
4 |
+
# ---------- runtime options ----------
|
5 |
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
6 |
+
PYTHONUNBUFFERED=1 \
|
7 |
+
LOG_LEVEL=INFO \
|
8 |
+
WORKERS=4
|
9 |
+
|
10 |
+
# ---------- install system deps ----------
|
11 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
12 |
+
build-essential curl && \
|
13 |
+
rm -rf /var/lib/apt/lists/*
|
14 |
+
|
15 |
+
# ---------- install Python deps ----------
|
16 |
+
WORKDIR /app
|
17 |
+
COPY requirements.txt .
|
18 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
19 |
+
|
20 |
+
# ---------- copy source ----------
|
21 |
+
COPY . .
|
22 |
+
|
23 |
+
# ---------- network ----------
|
24 |
+
EXPOSE 8000
|
25 |
+
|
26 |
+
# ---------- healthcheck ----------
|
27 |
+
HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD \
|
28 |
+
curl -sf http://localhost:8000/health || exit 1
|
29 |
+
|
30 |
+
# ---------- start ----------
|
31 |
+
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 8000 --workers $WORKERS"]
|