czsjCRM-vue/Dockerfile

25 lines
957 B
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 第一阶段
# 使用alpine镜像可以减少构建后docker镜像文件的体积
FROM node:14-alpine as build-stage
# 设置工作目录
WORKDIR /ruoyi_ui
# 先copy package.json文件到工作目录一般我们的项目中依赖是不会变的这样可以充分利用缓存减少部署时的构建时间
COPY package*.json /ruoyi_ui/
# 安装node_modules
RUN npm config set registry=https://registry.npmmirror.com/
RUN npm install
# 将所有文件copy到工作目录
COPY . /ruoyi_ui
# 开始打包
RUN npm run build:prod
# 第二阶段
# 拉取nginx镜像文件
FROM nginx
# 这里的dist文件就是打包好的文件project是我们上面设置的工作目录
COPY --from=build-stage /ruoyi_ui/dist /usr/share/nginx/ruoyi_ui
# default.conf就是我们项目下面的nginx配置文件我们需要copy到nginx的相应目录
COPY --from=0 /ruoyi_ui/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]