[英]Docker project structure with git submodules
When I see git projects which use Docker, then docker is just added to the git project which contains the source code one application. 当我看到使用Docker的git项目时,则将docker仅添加到git项目中,该项目包含一个应用程序的源代码。 But what if I want to use docker-compose to orchestrate multiple of my git-projects, because they work together (backend, frontend, ...)? 但是如果我想使用docker-compose来组织多个git项目,因为它们可以协同工作(后端,前端等),该怎么办?
For now, I use the source code from two other git projects and some more self-created Dockerfiles - so my compose-file now has 7 services (also some public ones from docker hub). 现在,我使用来自其他两个git项目的源代码以及一些其他自行创建的Dockerfile-因此,我的compose-file现在具有7个服务(还有来自docker hub的一些公共服务)。 I also need to create slightly different .yml files for different use cases (just with different environment variables). 我还需要为不同的用例(只是具有不同的环境变量)创建略有不同的.yml文件。 Is there any best practise how to structure such a project? 是否有最佳实践来组织这样的项目?
My project looks like this: 我的项目如下所示:
my-project/
|__ env/
| |__ service-1/
| | |__ default.env
| | |__ usecase-1.env
| |__ service-2/
| |__ default.env
| |__ usecase-1.env
|__ override/
| |__ usecase-1.yml
|__ src/
| |__ service-1/
| | |__ service-1/ (git submodule)
| | |__ Dockerfile
| |__ service-2/
| |__ Dockerfile
|__docker-compose.yml # default .yml, containing service-1 and service-2
So if there is a new use case, I create a new usecase-2.yml
inside override/ and also some new usecase-2.env
files inside my env/ folder. 因此,如果有一个新的用例,我将在override /中创建一个新usecase-2.yml
并在env /文件夹中创建一些新usecase-2.env
文件。
For myself it's logical but I wonder what is best practise - becasue I don't find any similar project. 就我自己而言,这是合乎逻辑的,但是我不知道最佳实践是什么-因为我找不到任何类似的项目。
If you want to use git submodules , then you need to group by service, not by env
and src
: 如果要使用git子模块 ,则需要按服务而不是env
和src
进行分组:
my-project/
|__ service-1/
| |__ env/
| |__ src/
| |__ Dockerfile
|__ override/
| |__ usecase-1.yml
|__ service-2/
| |__ env/
| |__ src/
| |__ Dockerfile
|__docker-compose.yml # default .yml, containing service-1 and service-2
That way, service-1
and service-2
can be git repos of their own that you can add as submodules in the main parent repo ' my-project
'. 这样, service-1
和service-2
可以是它们自己的git repos,可以将其添加为主父存储库“ my-project
”中的子模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.