File size: 1,206 Bytes
e6f4e7b | 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 | # ---- Stage 1: Build ----
FROM node:20-alpine AS builder
WORKDIR /app
# Vite bakes VITE_* vars in at BUILD time — pass them as build args
# (see docker-compose.yml). Empty values keep the demo fallback UI.
ARG VITE_SUPABASE_URL=""
ARG VITE_SUPABASE_ANON_KEY=""
ARG VITE_API_URL=""
ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL \
VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY \
VITE_API_URL=$VITE_API_URL
# Install dependencies first (layer caching)
COPY package.json ./
RUN npm install
# Copy source and build frontend + bundle server
COPY . .
RUN npm run build
# ---- Stage 2: Production ----
FROM node:20-alpine AS production
WORKDIR /app
# HF Spaces routes to 7860 — the server MUST default to it (see server.ts).
ENV NODE_ENV=production \
PORT=7860
# Install production-only dependencies (esbuild, vitest, typescript etc. excluded)
COPY package.json ./
RUN npm install --omit=dev && npm cache clean --force
# Copy the built output from builder stage
COPY --from=builder /app/dist ./dist
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://127.0.0.1:7860/api/health >/dev/null 2>&1 || exit 1
CMD ["node", "dist/server.cjs"]
|