Spaces:
Sleeping
Sleeping
Melika Kheirieh commited on
Commit ·
f188061
1
Parent(s): fec0f37
feat(docker): run FastAPI backend and Gradio UI together with healthcheck
Browse files- Dockerfile +18 -25
Dockerfile
CHANGED
|
@@ -1,35 +1,28 @@
|
|
| 1 |
-
# ----------
|
| 2 |
-
FROM python:3.12-slim
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
#
|
| 10 |
COPY requirements.txt .
|
| 11 |
-
RUN
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
# ----------
|
| 15 |
-
FROM python:3.12-slim AS runtime
|
| 16 |
-
WORKDIR /app
|
| 17 |
-
|
| 18 |
-
# Copy from builder
|
| 19 |
-
COPY --from=builder /usr/local/lib/python3.12 /usr/local/lib/python3.12
|
| 20 |
-
COPY --from=builder /usr/local/bin /usr/local/bin
|
| 21 |
-
|
| 22 |
-
# Copy project files
|
| 23 |
COPY . .
|
| 24 |
|
| 25 |
# ---------- Metadata & Healthcheck ----------
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
# CMD ["python", "app.py"]
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
|
|
|
|
|
| 1 |
+
# ---------- Base ----------
|
| 2 |
+
FROM python:3.12-slim
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 6 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 7 |
+
PIP_NO_CACHE_DIR=1
|
| 8 |
|
| 9 |
+
# ---------- Dependencies ----------
|
| 10 |
COPY requirements.txt .
|
| 11 |
+
RUN apt-get update && apt-get install -y --no-install-recommends curl && \
|
| 12 |
+
pip install --no-cache-dir -r requirements.txt && \
|
| 13 |
+
rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
+
# ---------- Copy app ----------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
COPY . .
|
| 17 |
|
| 18 |
# ---------- Metadata & Healthcheck ----------
|
| 19 |
+
LABEL org.opencontainers.image.title="nl2sql-copilot" \
|
| 20 |
+
org.opencontainers.image.description="NL2SQL Copilot full-stack demo (FastAPI + Gradio)" \
|
| 21 |
+
org.opencontainers.image.version="1.0.0"
|
| 22 |
|
| 23 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
| 24 |
+
CMD curl -fs http://localhost:8000/healthz || exit 1
|
|
|
|
| 25 |
|
| 26 |
+
# ---------- Run both backend & frontend ----------
|
| 27 |
+
EXPOSE 7860 8000
|
| 28 |
+
CMD ["bash", "-c", "uvicorn main:app --host 0.0.0.0 --port 8000 & python app.py"]
|