SarahXia0405 commited on
Commit
179b1ef
·
verified ·
1 Parent(s): ef9b2a2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -14
Dockerfile CHANGED
@@ -10,7 +10,7 @@ RUN npm install
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; \
@@ -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 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
46
 
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"]
 
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"]