From c83ee4c4c3f513178d6be1de1a0d0d32b28f50c8 Mon Sep 17 00:00:00 2001 From: hyh123a Date: Tue, 29 Mar 2022 16:41:04 +0800 Subject: [PATCH 1/2] modify the Dockerfile --- myems-web/Dockerfile | 12 ++++++++++-- myems-web/README.md | 10 ---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/myems-web/Dockerfile b/myems-web/Dockerfile index d64289b7..87baa41f 100644 --- a/myems-web/Dockerfile +++ b/myems-web/Dockerfile @@ -1,4 +1,11 @@ -FROM nginx:latest +FROM node:latest as build-stage +WORKDIR /opt +COPY . . +RUN npm install --registry https://registry.npm.taobao.org +RUN npm run build + + +FROM nginx:latest as production-stage # remove the default config RUN rm /etc/nginx/conf.d/default.conf && rm /etc/nginx/nginx.conf @@ -7,7 +14,8 @@ RUN rm /etc/nginx/conf.d/default.conf && rm /etc/nginx/nginx.conf RUN mkdir -p /var/www/myems-web # Note: You should run 'npm run build' in the web direction to generate the production build. + COPY nginx.conf /etc/nginx/ -COPY ./build/ /var/www/myems-web +COPY --from=build-stage /opt/build/ /var/www/myems-web EXPOSE 80 CMD ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"] \ No newline at end of file diff --git a/myems-web/README.md b/myems-web/README.md index b84e0e34..f456d012 100644 --- a/myems-web/README.md +++ b/myems-web/README.md @@ -71,16 +71,6 @@ cd myems/myems-web nano nginx.conf ``` -* Download all the necessary dependencies into the node_modules directory. -```bash -npm i --unsafe-perm=true --allow-root --legacy-peer-deps -``` - -* Build for production with NPM -```bash -npm run build -``` - * Build a Docker image On Windows: From d825240842bdbf9628d94f991131334ad3bd2234 Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Tue, 29 Mar 2022 22:40:27 +0800 Subject: [PATCH 2/2] updated Dockerfile and README of Web UI --- myems-web/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/myems-web/README.md b/myems-web/README.md index f456d012..4941d538 100644 --- a/myems-web/README.md +++ b/myems-web/README.md @@ -73,6 +73,8 @@ nano nginx.conf * Build a Docker image +**NOTE**: You can safely ignore the command 'npm run build' in this section, because it is built into the Dockerfile + On Windows: ```bash cp -r myems/myems-web c:\myems-web