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;"]

你可能感兴趣的