File size: 1,143 Bytes
4851680
9f254b5
 
 
211601f
 
 
9f254b5
 
 
 
 
 
8a9fece
 
 
 
 
 
 
 
9f254b5
 
 
4851680
9f254b5
 
 
 
 
f58414f
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
# Stage 1: Build the React application
FROM node:18-alpine as builder
WORKDIR /app

# API_KEY is expected to be set as an environment variable directly by Hugging Face Spaces
# using the secret named 'API_KEY' in the Space settings.
# vite.config.ts (via loadEnv) will pick up process.env.API_KEY from the build environment.

COPY package.json package-lock.json* ./
RUN npm install

COPY . .

# --- TEMPORARY DIAGNOSTIC STEP ---
RUN echo "--- Printing all environment variables (Hugging Face Build Environment) ---"
RUN env | sort
RUN echo "--- Value of API_KEY specifically: [$API_KEY] ---"
# --- END OF DIAGNOSTIC STEP ---

# Now, check for the API_KEY environment variable
RUN if [ -z "$API_KEY" ]; then echo "Error: Secret 'API_KEY' is not set or is empty in Hugging Face Space settings (checked after printing env)." && exit 1; fi

RUN npm run build

# Stage 2: Serve the static files with Nginx
FROM nginx:1.25-alpine
RUN rm /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /usr/share/nginx/html
RUN chown -R nginx:nginx /usr/share/nginx/html && chmod -R 755 /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]