Docker撰写开发和生产环境最佳工作流程 [英] Docker Compose Dev and Production Environments Best Workflow
问题描述
现在我想自动化流程并部署到生产中。
docker-compose .yml
可以扩展并定义多个环境。有关详细信息,请参阅 https://docs.docker.com/compose/extends/ 。 br> 但是,我的容器有Dockerfiles。对于开发环境,需要比生产中更多的软件包。
主要问题是我应该使用单独的dockerfiles作为 dev
和 prod
并在 docker-compose.yml
和 production.yml
?
单独的dockerfiles是简单的方法,但有代码重复。
另一个解决方案是使用环境变量,不知何故从bash脚本处理它们(可能是entrypoint?)。
我正在寻找其他想法。
在 docker-compose
version> = 1.5.0中,您可以使用环境变量,可能适合你吗?
I've built a simple Docker Compose project as a development environment. I have PHP-FPM, Nginx, MongoDB, and Code containers.
Now I want to automate the process and deploy to production.
The docker-compose.yml
can be extended and can define multiple environments. See https://docs.docker.com/compose/extends/ for more information.
However, there are Dockerfiles for my containers. And for the dev environment are needed more packages than in production.
The main question is should I use separate dockerfiles for dev
and prod
and manage them in docker-compose.yml
and production.yml
?
Separate dockerfiles are easy approach but there is code duplication.
The other solution is to use environment variables and somehow handle them from bash script (maybe as entrypoint ?).
I am searching for other ideas.
In docker-compose
version >= 1.5.0 you can use environment variables, may be this suits you?
这篇关于Docker撰写开发和生产环境最佳工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!