admin管理员组

文章数量:1198783

Background:

  • a number of codependent projects, projA and projB
  • each project can build separately, in a docker instance. A build script starts a docker instance, mounting the project's root in the instance, then running other build steps.
  • a project may use git information into the build, e.g. from git describe.

The projects build fine, and find their relevant git information.

Next step, tying the projects into a larger one. Enters the umbrella project projU, with projA and projB as submodules.

projU
    + projA
    + projB

ProjU attempts to use the submodules' own build scripts. Again, these start a docker instance, for which they mount their own project root.

The issue is that, unlike when it is its own clone, projA as a submodule does not own its .git directory. Since it mounts its root in a docker instance, it does not have access to its parent. Therefore, git describe fails.

I would like a smooth way to support building both as a submodule, and as a separate repo. Some alternatives that come to mind:

  1. find a way to make git save the .git dir under each submodule. As far as I recall, that's how submodules worked once upon a time. I could not find a way to do that today.
  2. don't use actual submodules in projB, just write a script that makes separate clones in subdirectories.
  3. save the required git info for submodules from projU, and pass that as envvars when starting the docker instances for projA and projB
  4. create and maintain alternative build scripts in projU, to build the submodules with mounting the whole projU in docker, instead of the submodules' roots.

Right now, I find that the more pragmatic approach, also avoiding redundant scripts, would be 2. Number 1 would work too, but I don't have much hope that this is feasible.

Any other more adequate approches?

本文标签: dockerAccess git data from a submodulewhich lacks access to its parentStack Overflow