Docker compose build failed when trying to update git submodule from remote repo

Viewed 86

I need help with docker compose (v2.5.0) and git submodules. It is big project with many microservices using JS. Some microservices have git submodule (the same one) inside. I created docker-compose.yml which builds the whole project. It works great when I'm pointing build context to local directory like:

some-service:
 build:
  context: /my/home/dir/some-service_dir

but when I'm trying to build from remote git repo

some-service:
 build:
  context: https://gitURL/some-service.git#branch

and the service have submodule inside, it crashes with fatal: not a git repository (or any of the parent directories): .git when tries to do git submodule update. I tried to specify the appropriate instructions in the docker file and in the makefile alternately. This service has .gitsubmodule file with right structure like

[submodule "name"]
    path = submoduleDir
    url = https://git.repo.url/mysubmodule.git
    branch = develop

all configs in .git are also correct, I suppose, cause it works great in other cases. So I have no idea what happening and why it doesn't work only when context points to the remote git repo. Any suggestions?

0 Answers
Related