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 /app
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
nginx 相关配置查阅 vuecli官网
如果不需要使用 docker 调用 npm 打包,直接打包静态资源,可以这样。
FROM nginx
MAINTAINER 自由如风 <1517607397@qq.com>
COPY ./dist /app
COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80