ARG CACHE_BUST=1 # ---- 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 --prefer-offline --no-audit --no-fund --no-cache # Copy source and build frontend + bundle server COPY . . RUN npm run build --if-present # ---- 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 --prefer-offline --no-audit --no-fund --no-cache --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"] # FORCE REBUILD 1789683005 # FORCE REBUILD 1789683498 # FORCE REBUILD 1789684080 # FORCE REBUILD 1789684846