-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
39 lines (29 loc) · 1.01 KB
/
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
#### Stage 1: Build the react application
FROM node:15.6.0-alpine as build
# Configure the main working directory inside the docker image.
# This is the base directory used in any further RUN, COPY, and ENTRYPOINT
# commands.
WORKDIR /app
# Copy the package.json as well as the package-lock.json and install
# the dependencies. This is a separate step so the dependencies
# will be cached unless changes to one of those two files
# are made.
COPY package.json package-lock.json ./
RUN npm install
# Copy the main application
COPY . ./
# Arguments
ARG REACT_APP_API_BASE_URL=/api
ENV REACT_APP_API_BASE_URL=${REACT_APP_API_BASE_URL}
# Build the application
RUN npm run build
#### Stage 2: Serve the React application from Nginx
FROM nginx:1.17.0-alpine
# # Copy the react build from Stage 1
COPY --from=build /app/build /static
# # Copy our custom nginx config
COPY nginx.conf /etc/nginx/nginx.conf
# # Expose port 80 to the Docker host, so we can access it
# # from the outside.
EXPOSE 80
ENTRYPOINT ["nginx","-g","daemon off;"]