FROM node:16-slim | |
WORKDIR /app | |
# Copy package files | |
COPY package*.json ./ | |
RUN npm install | |
# Copy source files | |
COPY public/ ./public/ | |
COPY src/ ./src/ | |
COPY tsconfig.json ./ | |
# Set environment variable | |
ARG REACT_APP_GEMINI_API_KEY | |
ENV REACT_APP_GEMINI_API_KEY=$REACT_APP_GEMINI_API_KEY | |
# Create .env file explicitly | |
RUN echo "REACT_APP_GEMINI_API_KEY=$REACT_APP_GEMINI_API_KEY" > .env | |
# Build the application | |
RUN npm run build | |
# Install serve globally | |
RUN npm install -g serve | |
EXPOSE 3000 | |
CMD ["serve", "-s", "build", "-p", "3000"] |