Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +24 -9
Dockerfile
CHANGED
|
@@ -10,18 +10,36 @@ RUN npm install
|
|
| 10 |
COPY web/ ./
|
| 11 |
RUN npm run build
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# =========================
|
| 14 |
# 2) API runtime stage
|
| 15 |
# =========================
|
| 16 |
FROM python:3.11-slim
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
RUN apt-get update \
|
| 20 |
&& apt-get install -y --no-install-recommends git ca-certificates \
|
| 21 |
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
|
| 23 |
-
WORKDIR /app
|
| 24 |
-
|
| 25 |
# ---- Python deps ----
|
| 26 |
COPY requirements.txt /app/requirements.txt
|
| 27 |
RUN pip install --no-cache-dir -r /app/requirements.txt
|
|
@@ -29,13 +47,10 @@ RUN pip install --no-cache-dir -r /app/requirements.txt
|
|
| 29 |
# ---- Copy API source ----
|
| 30 |
COPY api/ /app/api/
|
| 31 |
|
| 32 |
-
# ---- Copy
|
| 33 |
-
|
| 34 |
-
# If your build outputs /web/build, it will exist; if it outputs /web/dist, build step should be adjusted accordingly.
|
| 35 |
-
# We copy both when present.
|
| 36 |
-
COPY --from=web_builder /web/build /app/web/build
|
| 37 |
-
COPY --from=web_builder /web/dist /app/web/dist
|
| 38 |
|
|
|
|
| 39 |
ENV PORT=7860
|
| 40 |
EXPOSE 7860
|
| 41 |
CMD ["uvicorn", "api.server:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 10 |
COPY web/ ./
|
| 11 |
RUN npm run build
|
| 12 |
|
| 13 |
+
# ✅ unify output: create /web/out and copy build artifacts into it
|
| 14 |
+
RUN set -eux; \
|
| 15 |
+
rm -rf /web/out; \
|
| 16 |
+
mkdir -p /web/out; \
|
| 17 |
+
if [ -d "/web/dist" ]; then \
|
| 18 |
+
cp -r /web/dist/* /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 npm run build"; \
|
| 23 |
+
ls -la /web; \
|
| 24 |
+
exit 1; \
|
| 25 |
+
fi; \
|
| 26 |
+
echo "Web output files:"; \
|
| 27 |
+
ls -la /web/out | head -n 50
|
| 28 |
+
|
| 29 |
+
|
| 30 |
# =========================
|
| 31 |
# 2) API runtime stage
|
| 32 |
# =========================
|
| 33 |
FROM python:3.11-slim
|
| 34 |
|
| 35 |
+
WORKDIR /app
|
| 36 |
+
|
| 37 |
+
# (Optional) If you still have scripts that call git, keep this.
|
| 38 |
+
# Otherwise you can remove it later.
|
| 39 |
RUN apt-get update \
|
| 40 |
&& apt-get install -y --no-install-recommends git ca-certificates \
|
| 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
|
|
|
|
| 47 |
# ---- Copy API source ----
|
| 48 |
COPY api/ /app/api/
|
| 49 |
|
| 50 |
+
# ---- Copy unified web assets ----
|
| 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"]
|