File size: 1,495 Bytes
ca5f288
e83859c
ca5f288
 
 
33a55b5
e83859c
967f8b2
33a55b5
ca5f288
e010f62
ca5f288
179b1ef
ef9b2a2
 
 
 
 
 
 
 
179b1ef
 
 
 
ef9b2a2
 
179b1ef
 
ef9b2a2
ca5f288
e83859c
ca5f288
e83859c
ef9b2a2
 
179b1ef
e010f62
179b1ef
e010f62
 
09f9bba
 
 
 
 
179b1ef
ef9b2a2
09f9bba
e83859c
ca5f288
e010f62
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# =========================
# 1) Web build stage
# =========================
FROM node:20-slim AS web_builder
WORKDIR /web

COPY web/package*.json ./
RUN npm install

COPY web/ ./
RUN npm run build

# ✅ unify output into /web/out (supports vite dist OR custom outDir build)
RUN set -eux; \
    rm -rf /web/out; \
    mkdir -p /web/out; \
    if [ -d "/web/dist" ]; then \
      cp -r /web/dist/* /web/out/; \
    elif [ -d "/web/build" ]; then \
      cp -r /web/build/* /web/out/; \
    else \
      echo "ERROR: Neither /web/dist nor /web/build exists after build"; \
      echo "=== ls -la /web ==="; ls -la /web; \
      echo "=== ls -la /web/dist (if any) ==="; ls -la /web/dist || true; \
      echo "=== ls -la /web/build (if any) ==="; ls -la /web/build || true; \
      exit 1; \
    fi; \
    echo "=== Web output in /web/out ==="; \
    ls -la /web/out | head -n 80

# =========================
# 2) API runtime stage
# =========================
FROM python:3.11-slim
WORKDIR /app

# optional: keep git only if you truly need it at runtime
RUN apt-get update \
  && apt-get install -y --no-install-recommends ca-certificates \
  && rm -rf /var/lib/apt/lists/*

COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt

COPY api/ /app/api/

# ✅ always copy unified output to /app/web/build
COPY --from=web_builder /web/out /app/web/build

ENV PORT=7860
EXPOSE 7860
CMD ["uvicorn", "api.server:app", "--host", "0.0.0.0", "--port", "7860"]