# Build stage FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . # Read Mapbox token from HF Spaces secret and build RUN --mount=type=secret,id=VITE_MAPBOX_TOKEN,mode=0444,required=true \ VITE_MAPBOX_TOKEN=$(cat /run/secrets/VITE_MAPBOX_TOKEN) npm run build # Production stage FROM nginx:alpine # Copy built files COPY --from=builder /app/dist /usr/share/nginx/html # Custom nginx config for HF Spaces (port 7860) RUN echo 'server { \ listen 7860; \ server_name localhost; \ location / { \ root /usr/share/nginx/html; \ index index.html; \ try_files $uri $uri/ /index.html; \ } \ }' > /etc/nginx/conf.d/default.conf EXPOSE 7860 CMD ["nginx", "-g", "daemon off;"]