-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
46 lines (34 loc) · 1.17 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
40
41
42
43
44
45
46
#### Stage 1: Build the React application
FROM node:17.3.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 NEXT_PUBLIC_TENANT
ENV NEXT_PUBLIC_TENANT=${NEXT_PUBLIC_TENANT}
ARG NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
# Build and export the application
RUN npm run build
RUN npm run export
#### Stage 2: Serve the React application from nginx
FROM nginx:1.21.5-alpine
# Remove default nginx index page
RUN rm -rf /usr/share/nginx/html/*
# Copy the React build from Stage 1
COPY --from=build /app/out /usr/share/nginx/html
# Copy the custom nginx config
COPY nginx.conf /etc/nginx/nginx.conf
# Expose port 8081 to the Docker host, so we can access it
# from the outside.
EXPOSE 8081
ENTRYPOINT ["nginx","-g","daemon off;"]