Jenkins testing with multiple containers

polaris · 2017-09-25 01:00:12 · 638 次点击    
这是一个分享于 2017-09-25 01:00:12 的资源,其中的信息可能已经有所发展或是发生改变。

Typically we have an app that consitutes multiple Docker containers (service A, service B, Redis, Postgre, etc), how would you instanitate this environment and execute testing during a Jenkins build? e.g. simply run docker-compose within the Jenkins master?

any tips on testing over a dockerzied Jenkins will be appreciated


评论:

shott85:

I'd suggest adding an agent (f.k.a. slave) to Jenkins instead of installing any tools on the master or using on-master executors. This approach is better for several reasons including performance, security, and scalability.

Install Docker, Docker Compose, and other required tools (Git, etc.) on the agent and then invoke your build process using [power]shell scripts. You don't need any Docker plugins to do this.

Keep the agent clean by running Docker cleanup scripts on a CRON schedule, or as a post-build action like this.

If the agent itself is a container, then you'll need to install Docker and Docker Compose inside the container and bind mount /var/run/docker.sock (Docker on Docker), similar to what I've done in this example right here and here.

weitzj:

Install Docker compose and docker in a slave. Add a docker and docker compose tag to this node. And then in your job use a bash script with docker-compose up -d and an exit trap on the bash script with

```bash function stopDocker { docker-compose stop }

trap stopDocker EXIT ```

themissedsymphony:

You can do this either the docker plugin, a configured host machine or the kubernetes plugin. But in general, it's very difficult and every so often, you will have to clean up a lot of bad state (containers left running, full hard drives etc)

For this reason I recommend either Google Container Builder, CircleCI or indeed TravisCI as they can run all of the above and clean up after themselves. I had some success with Wercker but it's very limiting when you want to build a special image (say, with libvips or c libs)


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

638 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传