简体   繁体   English

如何配置Gitlab CI码头工人以测试不同的需求(语言环境,数据库等)?

[英]How do you configure Gitlab CI dockers to test different requirements (Language env, database, etc.)?

I am creating an API that uses Python, Mongo, and Redis and I wanted to use Gitlab CI. 我正在创建一个使用Python,Mongo和Redis的API,我想使用Gitlab CI。

Do I have to build a Dockerfile with all these requirements? 我是否必须构建具有所有这些要求的Dockerfile? Or is there a way to just write some instructions in the .gitlab-ci.yml and call the different images in Dockerhub? 还是有一种方法可以只在.gitlab-ci.yml中编写一些指令并在Dockerhub中调用不同的映像?

Yes you should. 是的你应该。 Although this is not a Gitlab specific question (and thus answer) it is considered a best-practice to separate tasks and functions (in Docker terms; One concern per container). 尽管这不是Gitlab特定的问题(因此也不是答案),但它被认为是分离任务和功能的最佳实践(以Docker术语表示;每个容器一个关注点)。 I don't want to call it a micro-service approach but you should consider splitting all processes. 我不想称其为微服务方法,但您应该考虑拆分所有流程。

Some fundamental concepts to help you: 一些可以帮助您的基本概念:

Since you mention Python and API I suppose your application is writen in Python and you use MongoDB and Redis as persistent data stores? 既然您提到了Python和API,我想您的应用程序是用Python编写的,并且您将MongoDB和Redis用作持久性数据存储吗?

Take a look at the official Docker images and how to use them, this should make your life splitting concerns a lot easier: 看一下官方的Docker映像以及如何使用它们,这应该使您的生活分心更加容易:

There is also an official Python image to help you on your way. 还有一个官方的Python映像可以帮助您。 Just add your app code and get going! 只需添加您的应用代码即可开始!

I found that you can write in a .gitlab-ci.yml a tag: 我发现您可以在.gitlab-ci.yml中编写标签:

- services: - redis:4.0.2 - mongo:3.4.10

Which uses other services that are on Dockerhub. 它使用Dockerhub上的其他服务

https://docs.gitlab.com/ce/ci/docker/using_docker_images.html#how-to-use-other-images-as-services https://docs.gitlab.com/ce/ci/docker/using_docker_images.html#how-to-use-other-images-as-services

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM