-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.frontend
31 lines (21 loc) · 928 Bytes
/
Dockerfile.frontend
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
# Dockerfile for React (frontend)
# Build the React app
FROM node:20.1.0 AS frontend
WORKDIR /app
COPY frontend/package.json ./
COPY frontend/ ./
# run npm install to install dependencies
RUN npm install
# for production
RUN npm run build
# after run npm run build we get build folder in our project
# pull nginx image from docker hub
FROM nginx:1.25.3
# node name as build
# take local folder directory /app/build which is create in this command npm run build above and copy to nginx folder /usr/share/nginx/html
# the default folder for nginx is /usr/share/nginx/html because nginx require the static files to run the app. when i try to npm run build it create stic files in build folder and we copy that build folder to nginx folder
COPY --from=frontend /app/build /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
# default port for nginx is 80
EXPOSE 80
CMD [ "nginx","-g","daemon off;" ]