forked from SLFullStackers/SpringAngularWebSocket
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (37 loc) · 1.34 KB
/
Dockerfile
File metadata and controls
51 lines (37 loc) · 1.34 KB
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
47
48
49
50
51
# multi-stage: base (build)
FROM node:18.13.0-slim AS base
# instantiate environment variable
ARG REACT_APP_SERVER_URL=http://localhost:3000
# set the environment variable that points to the server
ENV REACT_APP_SERVER_URL=$REACT_APP_SERVER_URL
# create directory where the application will be built
WORKDIR /app
# copy over the dependency manifests, both the package.json
# and the package-lock.json are copied over
COPY package*.json ./
# installs packages and their dependencies
RUN npm install
# copy over the code base
COPY . .
# create the bundle of the application
RUN npm run build
# multi-stage: production (runtime)
FROM nginx:1.22-alpine AS production
# copy over the bundled code from the build stage
COPY --from=base /app/build /usr/share/nginx/html
COPY --from=base /app/configuration/nginx.conf /etc/nginx/conf.d/default.conf
# create a new process indication file
RUN touch /var/run/nginx.pid
# change ownership of nginx related directories and files
RUN chown -R nginx:nginx /var/run/nginx.pid \
/usr/share/nginx/html \
/var/cache/nginx \
/var/log/nginx \
/etc/nginx/conf.d
# set user to the created non-privileged user
USER nginx
# expose a specific port on the docker container
ENV PORT=80
EXPOSE ${PORT}
# start the server using the previously build application
ENTRYPOINT [ "nginx", "-g", "daemon off;" ]