10.5.docker部署angular项目
编辑angular项目中的package.json
package.json
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json --port 4200",
// "build": "ng build --prod --outputPath=dist/mo --base-href=/mo/",
"build": "ng build --prod --outputPath=dist --base-href=/",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},添加Dockerfile
Dockerfile
FROM nginx:1.16.1
COPY dist /usr/share/nginx/html
WORKDIR /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]构建镜像
创建nginx配置
运行容器
Last updated
Was this helpful?