dockerfile 打包 Vue 项目

FROM node:14.17.6 AS builder

COPY . /app

WORKDIR /app

# 设置镜像,安装依赖,编译
RUN npm config set registry https://registry.npm.taobao.org/ && \
    npm install && npm run build

FROM nginx

COPY --from=builder  /app/dist /usr/share/nginx/html

EXPOSE 80

如果不需要使用 docker 调用 npm 打包,直接打包静态资源,可以这样。

FROM nginx

MAINTAINER 自由如风 <1517607397@qq.com>

COPY ./dist /app

COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80