vue使用docker+node+nginx部署

问题:在网上搜索的dockefile

FROM node:lts-alpine as build-stage

# # npm镜像,解决报错而引入
# RUN npm config set registry https://registry.npm.taobao.org
# RUN npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
...

执行到npm install时总出现错误
解决办法:
换镜像版本
我选择的是
node:14.18
完整dockerfile

FROM node:14.18 as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM nginx:stable-alpine as production-stage
RUN mkdir -p /opt/html
COPY --from=build-stage /app/dist /opt/html/.
COPY /nginx/nginx.conf /etc/nginx/.
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

版权声明:本文为qq_40086487原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。