内容简介:这次主要看下CICD中的CD功能。源码:https://github.com/limingios/docker/tree/master/No.11通过git clone 克隆到本地
这次主要看下CICD中的CD功能。源码:https://github.com/limingios/docker/tree/master/No.11
从gitlab中flask-demo下载代码到本地。
通过git clone 克隆到本地
### 修改.gitlab-ci.yml 增加部署代码
* 修改
stages:
- style
- test
- deploy
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-deploy:
stage: deploy
script:
- docker build -t flask-demo .
- docker run -d -p 5000:5000 flask-demo
tags:
- demo
- 提交到自建的gitlab上 commit push
- 增加了pipline
想想一下场景
gitlab-ci.yml是否有问题,假如有人修改代码,提交代码,重新CICD的时候
#执行这句没问题 docker build -t flask-demo . #执行这句就有问题了,之前已经有一个了之前的端口号就是5000,部署肯定报错的,解决方案,可以先将之前的remove掉,在起一个新的。可以写一些简单的脚本。 docker run -d -p 5000:5000 flask-demo
- 先将刚才创建的remove掉
sudo docker ps sudo docker rm -f 容器名称
-
修改yml
>.gitlab-ci.yml 然后commit push到服务器上
stages:
- style
- test
- deploy
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-deploy:
stage: deploy
script:
- docker build -t flask-demo .
- if [ $( docker ps -aq --filter name=web) ]; then docker rm -f web;fi
- docker run -d -p 5000:5000 --name web flask-demo
tags:
- test1
PS:基本的流程就是开发人员提交代码,自动构建,然后可以在ci服务器上访问,整个流程基本就是这样。
>>原创文章,欢迎转载。转载请注明:转载自IT人故事会,谢谢!
>>原文链接地址:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 『中级篇』docker之CI/CD持续集成—真实Python项目的CI演示(72)
- 『中级篇』docker之CI/CD持续集成—真实JAVA-Maven项目的CI演示(73)
- 堆排序动画演示,Python代码演示,看不懂你砍我!
- GraphQL案例演示
- Kubernetes身份验证机制演示
- 中心极限定理的Matlab演示
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Don't Make Me Think
Steve Krug / New Riders Press / 18 August, 2005 / $35.00
Five years and more than 100,000 copies after it was first published, it's hard to imagine anyone working in Web design who hasn't read Steve Krug's "instant classic" on Web usability, but people are ......一起来看看 《Don't Make Me Think》 这本书的介绍吧!