Docker Compose Dev and Production Environments Best Workflow

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.

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.

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.

+4
source share
4 answers

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.

+1
source

docker-compose version >= 1.5.0 , ?

+1

, , (.. ), Dockerfile, , , .

, docker-compose.yml, , development.yml , .

0

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.

0
source

All Articles