Xylaria-Iris-v3 / Dockerfile
Reality123b's picture
Update Dockerfile
8a9fece verified
raw
history blame
1.14 kB
# 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;"]