Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker project structure with submodules

Tags:

git

docker

I use microservices in my projects. Each microservice lives in it's own folder and it's own git repo.

All services live in separate docker container. So overall project structure looks like this:

project_root/
             microservice1_folder -> Dockerfile, .git, files ...
             microservice2_folder -> Dockerfile, .git, files ...
             microservice3_folder -> Dockerfile, .git, files ...
             docker-compose.yml

The problem is that docker-compose.yml isn't in any repo. There is no repo I could git clone and bring all services up with docker-compose up -d.

One could suggest to use submodules but I see no way of integrating them into my workflow.

With current setup I mount each microservice folder into docker, so I can make changes on the fly, commit and so on.

How do I work with submodules?

like image 312
Glueon Avatar asked Feb 26 '26 13:02

Glueon


1 Answers

project_root would need to be a git repo. You would then use

git submodule add {REPO_NAME} {PATH_TO_REPO}

for each of your submodules, which would, in turn, create a .gitmodules file in project_root.

When you clone project_root, you would then need to call

git submodule update --init

which would pull down the source for each of your submodules.

like image 157
J. Titus Avatar answered Feb 28 '26 05:02

J. Titus