加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

用于包含多个存储库的Docker应用程序的Git存储库设置

发布时间:2020-12-16 03:51:39 所属栏目:安全 来源:网络整理
导读:鉴于以下结构; ├── api/ - A PHP application,to have its own repository├── docker/ - Docker configuration for shared containers (MySQL,Nginx)├── docker-compose.yml - Defines all of the services└── web-client/ - A standalone Angul

鉴于以下结构;

├── api/                - A PHP application,to have its own repository
├── docker/             - Docker configuration for shared containers (MySQL,Nginx)
├── docker-compose.yml  - Defines all of the services
└── web-client/         - A standalone Angular application,to have its own repository

目前整个应用程序位于一个存储库中,但我希望拆分为单独的存储库.开发尚未开始,因此维护任何历史记录等都没有问题.

首先,定义根级别docker-compose文件中的所有服务是最好的方法,或者api和web-client是否应该使用自己的docker-compose更加孤立,从而完全单独管理?如果分开,是否仍然可以有一个“depends_on”另一个?

其次,为此管理存储库的最佳方法是什么?根级别代码(docker-compose.yml和docker /)应该存在于一个存储库中,但这也取决于存在的其他两个存储库,可能是作为子级.我查看了git子模块,但似乎父存储库必须绑定到子节点中的特定提交,这可能会使多个并行功能难以处理?

我的建议如下:

├── api/
       |___ .git
       |___ Dockerfile
       |___ ... api src ...
├── docker/             - Docker configuration for shared containers (MySQL,Nginx)
├── docker-compose.yml  - Defines all of the services
└── web-client/
        |______ .git
        |______ Dockerfile
        |______ ... web-client src ...

每个应用程序都应该封装它的源代码加上它的Dockerfile,它们都存在于同一个git仓库中.

然后docker-compose.yml文件将使用它们,如:

(...)
services:
  api:
    build: ./api/
(...)
  web-client:
    build: ./web-client/

这是我经常看到的方式.

如果你想使用多个docker-compose文件,你可能想看一下:https://docs.docker.com/compose/extends/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读