1

I have a maven project that I am building and running inside Docker container. My maven build needs to have an access to my project's GIT repository for some commit info extraction so I need to temporarily include my repository inside an image.

The problem is that my repository weights more than 600MB and it makes my image unnecessarily huge. I cannot add my repo to an image, perform some action and then remove it later. Well, I can. But it will not save any space due to nature of Docker images. Any ideas on how to deal with this?

Grzegorz Piwowarek
  • 13,172
  • 8
  • 62
  • 93

2 Answers2

2

You could consider accessing the git repo through a host volume mounted in your docker container.

Or you could consider cloning only the part of the git repo you need (just one branch, only a few commits as a shallow clone). That would minimize the size of the git repo in the image.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Circling back to this one a few years later and now the above problem is solved by multi-stage builds.

Grzegorz Piwowarek
  • 13,172
  • 8
  • 62
  • 93