免费注册 查看新帖 |

ChinaUnix.net

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7084 | 回复: 0

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

论坛徽章:
30
CU大牛徽章
日期:2013-05-20 10:45:13数据库技术版块每日发帖之星
日期:2015-09-07 06:20:00每日论坛发贴之星
日期: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:29
发表于 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.

check.png

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.

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

本版积分规则 发表回复

数据风云,十年变迁
DTCC 第十届中国数据库技术大会已启航!

2019年5月8日~5月10日,由IT168旗下ITPUB企业社区平台主办的第十届中国数据库技术大会(DTCC2019),将在北京隆重召开。大会将邀请百余位行业专家,就热点技术话题进行分享,是广大数据领域从业人士的又一次年度盛会和交流平台。与SACC2018类似,本届大会将采用“3+2”模式:3天传统技术演讲+2天深度主题培训。大会不仅提供超100场的主题演讲,还会提供连续2天的深度课程培训,深化数据领域的项目落地实践方案。
DTCC2019,一场值得期待的数据技术盛会,殷切地希望您报名参与!

活动入口>>
  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP