免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 29488 | 回复: 0
打印 上一主题 下一主题

Set up MongoDB on a Travis container [复制链接]

论坛徽章:
32
CU大牛徽章
日期:2013-05-20 10:45:13每日论坛发贴之星
日期:2015-09-07 06:20:00每日论坛发贴之星
日期:2015-09-07 06:20:00数据库技术版块每日发帖之星
日期:2015-12-13 06:20:0015-16赛季CBA联赛之江苏
日期:2016-03-03 11:56:13IT运维版块每日发帖之星
日期:2016-03-06 06:20:00fulanqi
日期:2016-06-17 17:54:25IT运维版块每日发帖之星
日期:2016-07-23 06:20:0015-16赛季CBA联赛之佛山
日期:2016-08-11 18:06:41JAVA
日期:2016-10-25 16:09:072017金鸡报晓
日期:2017-01-10 15:13:292017金鸡报晓
日期:2017-02-08 10:33:21
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-11-08 12:28 |只看该作者 |倒序浏览
The new Travis Docker infrastructure

Late December 2014, Travis announced the implementation of their new infrastructure based on Docker containers in order to improve build capacity, build start time, and resources usage. You can learn more about it on this very detailed article: Faster Builds with Container-Based Infrastructure and Docker

As we can read on the Travis documentation about how to use this infrastructure, adding one line only on our .travis.yml is necessary :

  sudo: false
Why simply not adding this line to my .travis.yml file?
As I had to use a specific MongoDB version that I couldn’t choose on the Travis apt-source-white-list, I was forced to install MongoDB as I found on this great article from Maxime Thoonsen and then fated to run my tests on the Travis legacy infrastructure

before_script:
  1.   - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
  2.   - echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
  3.   - sudo apt-get update
  4.   - sudo apt-get install -y mongodb-org=2.6.6 mongodb-org-server=2.6.6 mongodb-org-shell=2.6.6 mongodb-org-mongos=2.6.6 mongodb-org-tools=2.6.6
  5.   - sleep 15 #mongo may not respond immediatly
  6.   - mongo --version
复制代码
How to install it without sudo?
First, as we can find on the Travis documentation, we have to add this line at the beginning of our .travis.yml.

sudo: false

services:
  - docker
  - mongodb
Then, we specify the MongoDB version we want to use for our tests.

env:
  global:
    - MONGODB_VERSION=2.6.10
Finally, we can download the MongoDB archive we want and install it in a specific directory.

before_install:
  1.   - wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-$MONGODB_VERSION.tgz
  2.   - tar xfz mongodb-linux-x86_64-$MONGODB_VERSION.tgz
  3.   - export PATH=`pwd`/mongodb-linux-x86_64-$MONGODB_VERSION/bin:$PATH
  4.   - mkdir -p data/db
  5.   - mongod --dbpath=data/db &
  6.   - sleep 3
复制代码
Congrats, you are done with it !


If you want to check if your build has been successfully executed on the container infrastructure, look for the following lines on your Travis build logs.



The directs improvements we have seen
First, as advertised by Travis, our builds that sometimes needed several minutes to start, now systematically start within less than 10 seconds.

Secondly, the build speed itself has also increased sharply as you can see on the samples above.

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP