I’m working on setting up an application using nginx, nodejs, and mongodb. I’ve got a docker-compose.yml file working to deploy this, but I’ve run into a slight design problem.
My original idea was to have 5 containers: nginx, node, mongodb, src, and mongodb-data. The src container would be the code tree with a volume shared between nginx and node as it would have both html files for the front end and js files for the backend.
When there was an update to the code, I was going to rebuild the src image and restart anything necessary. However, as you can image, since the code directory is a volume (so it can be shared) the new image (with updated source code) doesn’t update the volume. I can’t just delete all the volumes as I don’t want to delete the database data volume.
So my question is, how do people normally handle this?
For this particular project it would be easy to put nodejs code in the node image and anything needed by nginx in the nginx image. But, what about big projects that aren’t easily split apart?
Do you just put the code in the nginx image AND the node image? Do you use your CI tool to manually delete the src code volume? Is there a way to share files between containers that I haven’t found yet that doesn’t use volumes? I’d rather not have to mount a specific directory from the host machine. I want the source code to be in an image to make is easy to deploy in different servers.
I hope I explained this is some way that makes any sense.
Thank you for your responses.