前言:
经前面三篇,我们搭建了基于docker和centos7的基础应用架构:代码仓库、应用仓库、yum本地源,本篇用一个python flask-uwsgi-nginx环境开发的学籍查询系统,来演示使用gitlab、registry、yum本地源完成持续集成与发布的过程
查询:
文中提到的程序和脚本见:https://github.com/Thomas-YangHT/python/tree/master/python_gitlab_example/
step1 应用环境dockerfile.python
-
首先,需要一个docker的应用环境:
-
dockerfile:
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/dockerfile.python
-
-
nginx配置:
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/conf.d/uwsgi.cf
扫描二维码关注公众号,回复: 4075015 查看本文章 -
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/conf.d/upstream.conf
-
-
uwsgi配置:
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/testflk.ini
-
-
一段示例python程序:(下载后改名为testflk.py)
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/testflk.py.hello
-
-
-
其次,build一下看一看:
-
build脚本:
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/docker-build.sh
-
-
docker_run脚本:
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/docker-run.sh
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/startpython.sh
-
-
-
第三,tag&push到应用仓库:
-
docker tag python 192.168.100.222:5000/python
-
docker push 192.168.100.222:5000/python
-
step2 编写python程序
-
一段python-flask-uwsgi程序,完成学生成绩和基本信息的查询:
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/testflk.py
-
-
需要导入mysql数据库,并修改python程序testflk.py中mysql相关的设定:
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/students_database.sql
-
-
重新build&run一下看看:
step3 将写好的.gitlab-ci.yml加到项目根目录
-
.gitlab-ci.yml:
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/.gitlab-ci.yml
-
-
git 提交:
-
https://raw.githubusercontent.com/Thomas-YangHT/python/master/python_gitlab_example/git_commit.sh
-
-
看看能否自动构建和步署:
END
Linux命令速查: 输入命令如 lsof, 返回参考链接
help ---更多分类索引