Reputation: 1971
I am trying to wrap my head around an optimal structure for Dockerization of a web app. So one of the best practices recommendations for using Docker is having one process per container. So where do I put the source code of my app?
Assume I am making a simple nginx and php app. The one process per container rule suggests having a nginx
container that serves static assets and proxies php requests to a php-fpm
container.
Now where do I put the source code? Do I keep it in a separate container and use volumes_from
in Docker compose to let the two containers access the code? Or do I build each container with the source code inside (I suppose that makes it easier with versioning)?
What are the best practices around this?
Upvotes: 2
Views: 81
Reputation: 1324148
Do I keep it in a separate container and use volumes_from in Docker compose to let the two containers access the code?
That is the usual best-practice, which avoid duplicating/synchronizing codes between components.
See "Creating and mounting a data volume container".
This is not just for pure data, but also for other shared resources like libraries, as shown in this article "How to Create a Persistent Ruby Gems Container with Docker":
Upvotes: 2