MEAN Docker 项目教程

随笔4个月前发布 秋风
36 0 0

MEAN Docker 项目教程

mean-dockerA Mean stack (Angular 17.0.3, Expressjs 4.17.1, MongoDB) jump start project with support of docker.项目地址:https://gitcode.com/gh_mirrors/me/mean-docker

1. 项目的目录结构及介绍




mean-docker/


├── api/


│   ├── Dockerfile


│   ├── package.json


│   └── ...


├── frontend/


│   ├── Dockerfile


│   ├── package.json


│   └── ...


├── loadbalancer/


│   ├── Dockerfile


│   └── default.conf


├── mongo/


│   ├── Dockerfile


│   └── init-mongo.js


├── docker-compose.yml


├── docker-compose.debug.yml


├── docker-compose.nginx.yml


├── .gitignore


├── LICENSE


└── README.md

api/: 包含 Express.js 后端服务的代码和配置文件。frontend/: 包含 Angular 前端应用的代码和配置文件。loadbalancer/: 包含 Nginx 配置文件,用于负载均衡。mongo/: 包含 MongoDB 的初始化脚本和配置文件。docker-compose.yml: 主 Docker Compose 文件,用于启动项目。docker-compose.debug.yml: 用于开发调试的 Docker Compose 文件。docker-compose.nginx.yml: 包含 Nginx 配置的 Docker Compose 文件。.gitignore: Git 忽略文件列表。LICENSE: 项目许可证。README.md: 项目说明文档。

2. 项目的启动文件介绍

docker-compose.yml




version: '3.8'


services:


  angular:


    build:


      context: ./frontend


      dockerfile: Dockerfile


    container_name: mean_angular


    volumes:


      - ./frontend:/frontend


      - /frontend/node_modules


    ports:


      - "4200:4200"


    environment:


      - NODE_ENV=production


 


  express:


    build:


      context: ./api


      dockerfile: Dockerfile


    container_name: mean_express


    volumes:


      - ./api:/api


      - /api/node_modules


    ports:


      - "3000:3000"


    environment:


      - NODE_ENV=production


 


  mongo:


    image: mongo


    container_name: mean_mongo


    ports:


      - "27017:27017"


    volumes:


      - mongo-data:/data/db


 


volumes:


  mongo-data:

docker-compose.debug.yml




version: '3.8'


services:


  angular:


    build:


      context: ./frontend


      dockerfile: debug.Dockerfile


    container_name: mean_angular


    volumes:


      - ./frontend:/frontend


      - /frontend/node_modules


    ports:


      - "4200:4200"


      - "49153:49153"


    environment:


      - NODE_ENV=dev


 


  express:


    build:


      context: ./api


      dockerfile: debug.Dockerfile


    container_name: mean_express


    volumes:


      - ./api:/api


      - /api/node_modules


    ports:


      - "3000:3000"


    environment:


      - NODE_ENV=dev

docker-compose.nginx.yml




version: '3.8'


services:


  angular:


    build:


      context: ./frontend


      dockerfile: Dockerfile


    container_name: mean_angular


    volumes:


      - ./frontend:/frontend


      - /frontend/node_modules


    ports:


      - "4000:4000"


    environment:


      - NODE_ENV=production


 


  express:


    build:


      context: ./api


      dockerfile: Dockerfile


    container_name: mean_express


    volumes:


      - ./api:/api


      - /api/node_modules


    ports:


      - "3000:3000"


    environment:


      - NODE_ENV=production


 


  nginx:


    build:


      context: ./loadbalancer


      dockerfile: Dockerfile


    container_name: mean_nginx


    ports:


      - "80:80"


   

mean-dockerA Mean stack (Angular 17.0.3, Expressjs 4.17.1, MongoDB) jump start project with support of docker.项目地址:https://gitcode.com/gh_mirrors/me/mean-docker

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...