-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
40 lines (28 loc) · 930 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
34
35
36
37
38
39
40
# Use the official Node.js runtime as the base image
FROM node:18 as build
ARG VITE_GRAPHQL_API_ENDPOINT
ARG PORT
ENV VITE_GRAPHQL_API_ENDPOINT=$VITE_GRAPHQL_API_ENDPOINT
ENV PORT=$PORT
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package.json ./
COPY yarn.lock ./
# Copy the entire application code to the container
COPY . .
# Install dependencies
RUN yarn && yarn run build
# Use Nginx as the production server
FROM nginx:alpine
# Copy the built React app to Nginx's web server directory
COPY --from=build /app/dist /usr/share/nginx/html
# COPY --from=build /app/dist /site
# Keep original nginx config
RUN mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf_orig
COPY nginx.conf /etc/nginx/nginx.conf
# Expose port 80 for the Nginx server
EXPOSE 80
EXPOSE $PORT
# Start Nginx when the container runs
CMD ["nginx", "-g", "daemon off;"]