上次主要说了在githubCI的服务器,并且也演示了github的runner执行CICD,这次通过真实的 python 项目来演示下CICD。项目通过gitlab和gitlabCI进行CICD。
源码地址:https://github.com/limingios/docker-cloud-flask-demo
随便找一个开源的python的在github项目。添加到gitlab上。
copy到gitlab上
- new project
-
Git repository URL
https://github.com/limingios/docker-cloud-flask-demo
- 点击create project
思考
上次注册了ci的runner,其实这个runner就是一个shell,通过命令的形式在ci服务器上运行该运行的程序。有可能ci服务器没有装python2 或者python3,我们可以在ci服务器里面装python2或者python3,但是如果想一下,这个ci服务器有很多人在用的话,python有很多环境,python有很多不同的依赖,如果环境全部都装在这个 shell 里面是不是很混乱,不光是python项目,如果有 java 项目啊,js的项目都装一下包肯定会很乱很乱,怎么去解决这个问题,看来只能通过 docker 了。
runner管理新的flask-demo
python2.7的环境
sudo gitlab-ci-multi-runner register
python3.4的环境
sudo gitlab-ci-multi-runner register
sudo gitlab-ci-multi-runner verify
新建github-ci 文件
stages:
- style
- test
pep8:
stage: style
script:
- pip install tox
- tox -e pep8
tags:
- python2.7
unittest-py27:
stage: test
script:
- pip install tox
- tox -e py27
tags:
- python2.7
unittest-py34:
stage: test
script:
- pip install tox
- tox -e py34
tags:
- python3/4
本地docker没有提前拉取镜像,下载python2.7 和 python3.4的比较慢,我直接增加了加速器
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://b81aace9.m.daocloud.io sudo systemctl restart docker
结果还是报错了,开始分析:
Cloning repository... Cloning into '/builds/root/flask-demo'... fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.example.com/root/flask-demo.git/': Couldn't resolve host 'gitlab.example.com' ERROR: Job failed: exit code 1
Runner启动的docker容器里无法访问到 gitlab.example.com 这个地址(能访问到才怪)。这一般是由于我们的测试环境没有使用域名导致的, gitlab论坛 里也不少人讨论这个问题,如果你是在部署正式的gitlab环境,那你自然会有一个域名来使用。不过我这里只是搭建测试环境,所以我使用了一种投机的方法:
修改Runner的 /etc/gitlab-runner/config.toml 文件,在其中的 [runner.docker] 下增加:
sudo vi /etc/gitlab-runner/config.toml
成功了 重新Retry
PS:这次主要给大家简单的介绍下CI,还没设计到CD。下次吧!
>>原创文章,欢迎转载。转载请注明:转载自IT人故事会,谢谢!
>>原文链接地址:
以上所述就是小编给大家介绍的《『中级篇』docker之CI/CD持续集成—真实Python项目的CI演示(72)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 『中级篇』docker之CI/CD持续集成-CD演示(74)
- 『中级篇』docker之CI/CD持续集成—真实JAVA-Maven项目的CI演示(73)
- 堆排序动画演示,Python代码演示,看不懂你砍我!
- GraphQL案例演示
- Kubernetes身份验证机制演示
- 中心极限定理的Matlab演示
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Beginning ARKit for iPhone and iPad
Wallace Wang / Apress / 2018-11-5 / USD 39.99
Explore how to use ARKit to create iOS apps and learn the basics of augmented reality while diving into ARKit specific topics. This book reveals how augmented reality allows you to view the screen on ......一起来看看 《Beginning ARKit for iPhone and iPad》 这本书的介绍吧!