Peiyan commited on
Commit
1c87d00
·
verified ·
1 Parent(s): 3fe76fe

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -8
Dockerfile CHANGED
@@ -2,17 +2,15 @@
2
  FROM node:14-bullseye-slim as build-step
3
  WORKDIR /app
4
  ENV PATH /app/node_modules/.bin:$PATH
5
- RUN mkdir ./frontend
 
6
  COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
7
  WORKDIR /app/frontend
8
  RUN npm install -g [email protected]
9
- # It's OK to have multiple consecutive `RUN` instructions.
10
- # hadolint ignore=DL3059
11
  RUN npm install
12
 
13
- WORKDIR /app
14
  COPY ./frontend ./frontend
15
-
16
  WORKDIR /app/frontend
17
  RUN npm run build
18
 
@@ -37,8 +35,9 @@ RUN chmod -R 755 /var/log/nginx && \
37
  # Step #3: configure nginx and flask
38
  COPY --from=build-step /app/frontend/build /usr/share/nginx/html
39
  COPY deployment/docker/nginx.conf /etc/nginx/nginx.conf
40
- COPY deployment/docker/serve.sh .
41
- RUN chmod a+x ./serve.sh
 
42
 
43
  # Expose port 80
44
  EXPOSE 80
@@ -47,4 +46,4 @@ EXPOSE 80
47
  USER root
48
 
49
  ENTRYPOINT ["/bin/bash"]
50
- CMD ["./serve.sh"]
 
2
  FROM node:14-bullseye-slim as build-step
3
  WORKDIR /app
4
  ENV PATH /app/node_modules/.bin:$PATH
5
+
6
+ # Copy package.json and package-lock.json first to leverage Docker cache
7
  COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
8
  WORKDIR /app/frontend
9
  RUN npm install -g [email protected]
 
 
10
  RUN npm install
11
 
12
+ # Copy the rest of the frontend code and build the project
13
  COPY ./frontend ./frontend
 
14
  WORKDIR /app/frontend
15
  RUN npm run build
16
 
 
35
  # Step #3: configure nginx and flask
36
  COPY --from=build-step /app/frontend/build /usr/share/nginx/html
37
  COPY deployment/docker/nginx.conf /etc/nginx/nginx.conf
38
+ COPY deployment/default /etc/nginx/sites-enabled/default
39
+ COPY deployment/docker/serve.sh /serve.sh
40
+ RUN chmod a+x /serve.sh
41
 
42
  # Expose port 80
43
  EXPOSE 80
 
46
  USER root
47
 
48
  ENTRYPOINT ["/bin/bash"]
49
+ CMD ["/serve.sh"]