I created a simple Docker Compose project as a development environment. I have PHP-FPM, Nginx, MongoDB and Code. Now I want to automate the process and deploy it to production.docker-compose.ymlcan be expanded and can define multiple environments. See https://docs.docker.com/compose/extends/ for more details .However, for my containers there are Dockerfiles. And for the development environment, more packages are required than in production.
docker-compose.yml
The main question is: should separate dockers for devand be used prodand managed in docker-compose.ymland production.yml?Separate docker files are a simple approach, but there is code duplication.
dev
prod
production.yml
Another solution is to use environment variables and somehow process them from a bash script (perhaps as an entry point?).
I am looking for other ideas.
In accordance with official documents :
... you probably want to define a separate Compose file, say production.yml, that defines a configuration suitable for production.Note. The keyword extendsis useful for supporting multiple compose files that reuse shared services without having to manually copy and paste.
... you probably want to define a separate Compose file, say production.yml, that defines a configuration suitable for production.
Note. The keyword extendsis useful for supporting multiple compose files that reuse shared services without having to manually copy and paste.
extends
docker-compose version >= 1.5.0 , ?
docker-compose
, , (.. ), Dockerfile, , , .
Dockerfile
, docker-compose.yml, , development.yml , .
development.yml
In this situation, it might be worth considering using an "onbuild" image to handle commonality between environments, and then use separate images to process specifics. Some official images have built-in versions, such as Node . Or you can create your own.