File size: 1,236 Bytes
ae14296 03fbbd1 ae14296 03fbbd1 ae14296 03fbbd1 67bb6b7 ae14296 03fbbd1 ae14296 67bb6b7 | 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 | # Build stage
FROM node:20-alpine AS build
WORKDIR /app
# Install dependencies
COPY package*.json ./
RUN npm install
# Copy source and build
COPY . .
# Note: We build with placeholders or local .env if present.
# Secrets will be injected at runtime via env.js
RUN npm run build
# Production stage
FROM nginx:stable-alpine
COPY --from=build /app/dist /usr/share/nginx/html
# Clean default configuration and create a new one for Hugging Face (port 7860)
RUN rm /etc/nginx/conf.d/default.conf && \
printf 'server {\n\
listen 7860;\n\
server_name localhost;\n\
location / {\n\
root /usr/share/nginx/html;\n\
index index.html;\n\
try_files $uri $uri/ /index.html;\n\
}\n\
error_page 500 502 503 504 /50x.html;\n\
location = /50x.html {\n\
root /usr/share/nginx/html;\n\
}\n\
}\n' > /etc/nginx/conf.d/default.conf
EXPOSE 7860
# At runtime, generate an env.js file that contains the environment variables
# from Hugging Face Secrets, then start Nginx.
CMD ["/bin/sh", "-c", "echo \"window.ENV = { VITE_SUPABASE_URL: '$VITE_SUPABASE_URL', VITE_SUPABASE_PUBLISHABLE_KEY: '$VITE_SUPABASE_PUBLISHABLE_KEY' };\" > /usr/share/nginx/html/env.js && exec nginx -g 'daemon off;'"]
|