AI_Agent_Final / Dockerfile
SarahXia0405's picture
Update Dockerfile
179b1ef verified
# =========================
# 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"]