-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
33 lines (25 loc) · 964 Bytes
/
Dockerfile
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
# Use a Node image to build the React app
FROM node:18-alpine AS builder
# Accept build arguments
ARG REACT_APP_RECAPTCHA_SITE_KEY
ARG REACT_APP_GOOGLE_ANALYTICS_TRACKING_ID
# Set working directory inside container
WORKDIR /app
# Copy package.json and install dependencies
COPY package*.json ./
RUN npm install
# Copy the source code and build the React app with the environment variable
COPY . .
# Set the REACT_APP_RECAPTCHA_SITE_KEY environment variable for the build
ENV REACT_APP_RECAPTCHA_SITE_KEY=${REACT_APP_RECAPTCHA_SITE_KEY}
ENV REACT_APP_GOOGLE_ANALYTICS_TRACKING_ID=${REACT_APP_GOOGLE_ANALYTICS_TRACKING_ID}
RUN npm run build
# Use a lightweight web server to serve the built files
FROM nginx:alpine
COPY --from=builder /app/build /usr/share/nginx/html
# Copy the custom Nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80 for the container
EXPOSE 80
# Start the Nginx server
CMD ["nginx", "-g", "daemon off;"]