Are there any best practices about what belongs into the build phase of a container?
Based on several images available on the hub and articles like this from Spotify, I got the impression, that all source code is put into the image during docker build. This however seems to me very inconvenient for development. So how are you dealing with this?
Do you have different images for development and production? Any other idea about this?
Most of my coding images do put the code into the image - and then compile
them too - so make build does a docker build which compiles the code
that is in the branch i’m workingin
but when I need to do some fast round tripping, I have a make shell,
which starts the build container with a bindmount of the current directory
over the top of the build location (and runs bash)
from there, I can kick off a build, or use filesystem watches to
auto-rebuild.
It would be good however to know what you find inconvenient about it - as
your issue may not be what i think it is
Sven
Docker Engineer
Ask me anything …
Brisbane, Australia (UTC+10)
I guess we are talking about the same inconvenience.
Currently I’m working on a lot of small code changes and would like to compile and test them immediately. I do have my complete development environment in container and usually use a graphical editor on the host. So that makes putting the code into the container more or less inconvenient.
Probably this is more an indication of a bad development setup with docker on my side. I think your make shell is something I should consider. This obviously means that I need make on my host. Currently I try to get rid of anything (regarding development) on my host and put it into containers.
Do you know of any articles or other resources describing a development environment similar to yours in more detail?
However, it is really not clear to me why make is so intensively used. From what I see and understand, you could also use docker-compose. This would have the advantage that you do not require any other build tools except docker and its tools.
After playing around with docker-compose in this context, I’m staring to agree that make might be the better option. Although docker-compose would be capable of doing the same stuff, it is not intended to work like this.
When using docker-compose like make only the docker-compose run command would make sense, while docker-compose up does not make sense at all. It might even give some really strange side-effects.
yup, make is (imo) a much more appropriate tool for doing builds.
I also have removed make from my host OS - I have a set of containers that I use as my shell and development environment - the bash image has make installed (and the host docker socket bind mounted into it) :).
the main pain is that containers that are children of the shell container will be bind mounting to the host, not paths in the shell container.
I do not have any experience with docker in docker, which I’m assuming you are using!?! Are there any examples I can analyse to better understand how you setup your environment or something similar? It sounds like it fulfils my requirements.