Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +13 -16
Dockerfile
CHANGED
|
@@ -1,18 +1,15 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
COPY requirements.txt .
|
| 6 |
-
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
|
| 7 |
-
|
| 8 |
-
WORKDIR /app
|
| 9 |
COPY . .
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
COPY
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
|
| 1 |
+
# ---------- stage 1: build ----------
|
| 2 |
+
FROM python:3.9-slim AS builder
|
| 3 |
+
WORKDIR /src
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
COPY . .
|
| 5 |
+
RUN pip install --prefix=/install --no-cache-dir -r requirements.txt
|
| 6 |
+
# optional: compile to .pyc or a zipapp
|
| 7 |
+
RUN python -m compileall -b app.py
|
| 8 |
|
| 9 |
+
# ---------- stage 2: runtime ----------
|
| 10 |
+
FROM python:3.9-slim
|
| 11 |
+
WORKDIR /app
|
| 12 |
+
# bring in only what you need
|
| 13 |
+
COPY --from=builder /install /usr/local
|
| 14 |
+
COPY --from=builder /src/app.pyc ./app.pyc # byte-code only
|
| 15 |
+
ENTRYPOINT ["python", "app.pyc"] # or uvicorn app:app ...
|
|
|