Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +10 -14
Dockerfile
CHANGED
|
@@ -10,7 +10,7 @@ RUN npm install
|
|
| 10 |
COPY web/ ./
|
| 11 |
RUN npm run build
|
| 12 |
|
| 13 |
-
# ✅ unify output
|
| 14 |
RUN set -eux; \
|
| 15 |
rm -rf /web/out; \
|
| 16 |
mkdir -p /web/out; \
|
|
@@ -19,38 +19,34 @@ RUN set -eux; \
|
|
| 19 |
elif [ -d "/web/build" ]; then \
|
| 20 |
cp -r /web/build/* /web/out/; \
|
| 21 |
else \
|
| 22 |
-
echo "ERROR: Neither /web/dist nor /web/build exists after
|
| 23 |
-
ls -la /web; \
|
|
|
|
|
|
|
| 24 |
exit 1; \
|
| 25 |
fi; \
|
| 26 |
-
echo "Web output
|
| 27 |
-
ls -la /web/out | head -n
|
| 28 |
-
|
| 29 |
|
| 30 |
# =========================
|
| 31 |
# 2) API runtime stage
|
| 32 |
# =========================
|
| 33 |
FROM python:3.11-slim
|
| 34 |
-
|
| 35 |
WORKDIR /app
|
| 36 |
|
| 37 |
-
#
|
| 38 |
-
# Otherwise you can remove it later.
|
| 39 |
RUN apt-get update \
|
| 40 |
-
&& apt-get install -y --no-install-recommends
|
| 41 |
&& rm -rf /var/lib/apt/lists/*
|
| 42 |
|
| 43 |
-
# ---- Python deps ----
|
| 44 |
COPY requirements.txt /app/requirements.txt
|
| 45 |
RUN pip install --no-cache-dir -r /app/requirements.txt
|
| 46 |
|
| 47 |
-
# ---- Copy API source ----
|
| 48 |
COPY api/ /app/api/
|
| 49 |
|
| 50 |
-
#
|
| 51 |
COPY --from=web_builder /web/out /app/web/build
|
| 52 |
|
| 53 |
-
# ---- Run API (serves web build too) ----
|
| 54 |
ENV PORT=7860
|
| 55 |
EXPOSE 7860
|
| 56 |
CMD ["uvicorn", "api.server:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 10 |
COPY web/ ./
|
| 11 |
RUN npm run build
|
| 12 |
|
| 13 |
+
# ✅ unify output into /web/out (supports vite dist OR custom outDir build)
|
| 14 |
RUN set -eux; \
|
| 15 |
rm -rf /web/out; \
|
| 16 |
mkdir -p /web/out; \
|
|
|
|
| 19 |
elif [ -d "/web/build" ]; then \
|
| 20 |
cp -r /web/build/* /web/out/; \
|
| 21 |
else \
|
| 22 |
+
echo "ERROR: Neither /web/dist nor /web/build exists after build"; \
|
| 23 |
+
echo "=== ls -la /web ==="; ls -la /web; \
|
| 24 |
+
echo "=== ls -la /web/dist (if any) ==="; ls -la /web/dist || true; \
|
| 25 |
+
echo "=== ls -la /web/build (if any) ==="; ls -la /web/build || true; \
|
| 26 |
exit 1; \
|
| 27 |
fi; \
|
| 28 |
+
echo "=== Web output in /web/out ==="; \
|
| 29 |
+
ls -la /web/out | head -n 80
|
|
|
|
| 30 |
|
| 31 |
# =========================
|
| 32 |
# 2) API runtime stage
|
| 33 |
# =========================
|
| 34 |
FROM python:3.11-slim
|
|
|
|
| 35 |
WORKDIR /app
|
| 36 |
|
| 37 |
+
# optional: keep git only if you truly need it at runtime
|
|
|
|
| 38 |
RUN apt-get update \
|
| 39 |
+
&& apt-get install -y --no-install-recommends ca-certificates \
|
| 40 |
&& rm -rf /var/lib/apt/lists/*
|
| 41 |
|
|
|
|
| 42 |
COPY requirements.txt /app/requirements.txt
|
| 43 |
RUN pip install --no-cache-dir -r /app/requirements.txt
|
| 44 |
|
|
|
|
| 45 |
COPY api/ /app/api/
|
| 46 |
|
| 47 |
+
# ✅ always copy unified output to /app/web/build
|
| 48 |
COPY --from=web_builder /web/out /app/web/build
|
| 49 |
|
|
|
|
| 50 |
ENV PORT=7860
|
| 51 |
EXPOSE 7860
|
| 52 |
CMD ["uvicorn", "api.server:app", "--host", "0.0.0.0", "--port", "7860"]
|