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
# install simple http server for serving static content
# 全局http-server用于本地运行
#RUN npm install -g http-server
# make the 'app' folder the current working directory
WORKDIR /app
# copy both 'package.json' and 'package-lock.json' (if available)
COPY package*.json ./
# install project dependencies
RUN npm install
# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .
# build app for production with minification
# 生产打包,对应脚本"build": "node build/build.js"
RUN npm run build
#本地,对应脚本"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js"
#RUN npm run dev
# production stage
#代理nginx,nginx直接访问
FROM nginx:stable-alpine as production
使用Dockerfile搭建vue项目
最新推荐文章于 2024-08-12 03:52:58 发布
本文介绍了如何利用Dockerfile来构建Vue项目的镜像,并通过Docker运行容器,使用http-server或nginx作为服务器,将应用暴露在8088端口上。读者可以按照指导访问localhost:8088来查看运行的Vue应用。
摘要由CSDN通过智能技术生成