Docker撰写开发和生产环境最佳工作流程 [英] Docker Compose Dev and Production Environments Best Workflow

查看:302
本文介绍了Docker撰写开发和生产环境最佳工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个简单的Docker Compose项目作为开发环境。我有PHP-FPM,Nginx,MongoDB和Code容器。

现在我想自动化流程并部署到生产中。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆