Jenkins testing with multiple containers

polaris · · 255 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>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? </p> <p>any tips on testing over a dockerzied Jenkins will be appreciated</p> <hr/>**评论:**<br/><br/>shott85: <pre><p>I&#39;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.</p> <p>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&#39;t need any Docker plugins to do this.</p> <p>Keep the agent clean by running Docker cleanup scripts on a CRON schedule, or as a post-build action like <a href="" rel="nofollow">this</a>.</p> <p>If the agent itself is a container, then you&#39;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&#39;ve done in <a href="" rel="nofollow">this example</a> right <a href="" rel="nofollow">here</a> and <a href="" rel="nofollow">here</a>.</p></pre>weitzj: <pre><p>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 </p> <p>```bash function stopDocker { docker-compose stop }</p> <p>trap stopDocker EXIT ```</p></pre>themissedsymphony: <pre><p>You can do this either the docker plugin, a configured host machine or the kubernetes plugin. But in general, it&#39;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)</p> <p>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&#39;s very limiting when you want to build a special image (say, with libvips or c libs)</p></pre>

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

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