说明:  我一次build 完 所以images 包 有1G多   可分层build   bash 环境一层   应用程序及启动脚本(shell.sh) 一层

步骤: 

         1     基础 Images 镜像  sairamnusetty/centos6.8-python2.7.13  

         2    从github  上 git  proect 下来并修改配置文件

        3    运行  install-project.sh  自动下载  git  proect   在次运行  自动构建docker-images  然后  run proect

整个目录文件

 

install-project.sh  代码如下:   第一次运行检查当下目录是否存在OpsManage 项目文件 如没有自动从github上git 下来 

#!/bin/bash
#author Mrchen 237356573@qq.com
PROCJECT="./OpsManage"
DOCKERFILE="./dockerfile" run_start() {
#run build-project-image
echo -e "\033[41;30m正在----Run build-Images-----\033[0m"
docker build -t python-django:opsmanage-v1 .
#run docker-images
echo -e "\033[41;30m正在----Docker---Run-Images-----\033[0m"
docker run --name project -p 80:8000 -d python-django:opsmanage-v1
} echo -e "\033[41;30m 正在检查文件 \033[0m"
if [ ! -d "$PROCJECT" ]; then
echo -e "\033[41;30m正在-----git clone https://github.com/welliamcao/OpsManage.git----\033[0m"
yum install wget git -y &&
git clone https://github.com/welliamcao/OpsManage.git
echo -e "\033[41;30m请先修改modify Redis-host-IP Mysql-host-IP user password db---\033[0m"
echo -e "\033[41;30m文件位置---./OpsManage/OpsManage/settings.py---\033[0m"
echo -e "\033[41;30m 在运行该脚本 \033[0m"
else
if [[ ! -f "$DOCKERFILE" ]]; then
cat > ./Dockerfile <<\EOF
# MAINTAINER Mrchen <237356573@qq.com>
# DOCKER-VERSION 1.0 FROM sairamnusetty/centos6.8-python2.7.13 MAINTAINER The CentOS Project <237356573.qq.com> RUN yum install wget gcc -y
RUN wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
RUN yum clean all
RUN yum install epel-release -y
RUN yum repolist #install django-base-server
RUN yum install zlib zlib-devel readline-devel sqlite-devel bzip2-devel openssl-devel gdbm-devel libdbi-devel ncurses-libs kernel-devel libxslt-devel libffi-devel python-devel mysql-devel zlib-devel mysql-server sshpass gcc wget git openssl-devel -y #install python-django-pip-base
COPY ./requirements.txt /mnt
RUN pip install -r /mnt/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/ #mount proect OpsManage VOLUME ["/mnt/OpsManage"] COPY OpsManage /mnt #run .sh .py COPY ./loading-mariadb.sh /mnt COPY ./start-proect.sh /mnt #开放8000端口
EXPOSE 8000 #load data
RUN chmod +x /mnt/start-proect.sh
#ENTRYPOINT ["/mnt/start-proect.sh"]
CMD ["/mnt/start-proect.sh"] EOF echo -e "new pip config" cat > ./requirements.txt <<\EOF
django==1.8.17
Celery==3.1.20
django-celery
celery-with-redis
djangorestframework==3.5.3
paramiko
ansible==2.2.2
redis
xlrd
supervisor
MySQL-python
DBUtils
EOF cat > ./start-proect.sh <<\EOF
#!/bin/bash
#237356573
OPS_DIR=/mnt #--------------RUN---Opsmange---------------------------
if [[ ! -d ${OPS_DIR}/OpsManage ]];then
echo "not proectj-DIR "
else
cd ${OPS_DIR}/OpsManage
python ${OPS_DIR}/manage.py migrate
STR=$?
if [[ ! STR -ne 0 ]];then
chmod +x /mnt/loading-mariadb.sh
bash /mnt/loading-mariadb.sh
sleep 1
python ${OPS_DIR}/manage.py runserver 0.0.0.0:8000
else
echo "----------------mysql----loading-----ERROR-------"
fi
fi
EOF #---------------------------RUN----------------------------------
echo -e "...new--all--files..................."
read -r -p "ls it running?[Y/n]" PROECT
case $PROECT in
[yY][eE][sS]|[yY])
run_start
;;
[nN][oO]|[nN])
echo "-----exit-----"
exit
;;
esac
else
read -r -p "all files exis ls it running?[Y/n]" PROECT
case $PROECT in
[yY][eE][sS]|[yY])
run_start
;;
[nN][oO]|[nN])
echo "-----exit-----"
exit
;;
esac
fi
fi

运行:   bash ./install-project.sh

        

vim ./OpsManage/OpsManage/settings.py   修改  redis  mariadb 及 port    我们修改为  172.16.0.200  

 mariadb 我们修改为:

 

修改完我们在来看一下  loading-mariadb.sh   该文件为启动时修改python-django  登陆时帐号及密码:

在次运行  bash ./install-project.sh

    坐等 查看:

访问 172.16.0.220   user:  chen   password : admin

          images 打包    docker save   e5c4cfc89496 > /mnt/opsmanage.ims

         images   loading进本地  仓库   docker load  <  /mnt/opsmanage.ims

         Tag          docker tag   e5c4cfc89496  python-django_opsmanage_v1

         push 到私有仓库  docker push 172.16.0.230:5000/python-django_opsmanage_v1

         还可以写个   compose  在加  swarm集群 也是我接下去要研究学习  还有 k8s  哦!

         container   (redis,mariadb,Opsmanages)下载地址:

                     

Docker 搭建开源 CMDB平台 之 “OpsManage”的更多相关文章

  1. Docker 搭建开源 CMDB平台 “OpsManage” 之 Mariadb

    整理了一下文档  今天来构建mariadb 主机还是 centos  172.16.0.200 构建第二个images   直接shell.sh 完成  #!/bin/bash echo " ...

  2. Docker 搭建开源 CMDB平台 “OpsManage” 之 Redis

    整体结构如下图   先来在 172.16.0.200 安装docker-ce (新)或 docker-io(旧)      0: Docker-ce  (新版本  Docker version 17. ...

  3. 【译文】用Spring Cloud和Docker搭建微服务平台

    by Kenny Bastani Sunday, July 12, 2015 转自:http://www.kennybastani.com/2015/07/spring-cloud-docker-mi ...

  4. Spring Cloud和Docker搭建微服务平台

    用Spring Cloud和Docker搭建微服务平台 This blog series will introduce you to some of the foundational concepts ...

  5. 基于docker搭建开源扫描器——伏羲

    基于docker搭建开源扫描器——伏羲 1.简介 项目地址 伏羲是一款开源的安全检测工具,适用于中小型企业对企业内部进行安全检测和资产统计. 功能一览: 基于插件的漏洞扫描功能(类似于巡风) 漏洞管理 ...

  6. Docker搭建代码检测平台SonarQube并检测maven项目

    1 前言 良好的代码习惯是一个优秀程序员应该具备的品质,但靠人的习惯与记忆来保证代码质量,始终不是一件靠谱的事.在计算机行业应该深知,只要是人为的,都会有操作风险.本文讲解如何通过Docker搭建代码 ...

  7. 企业安全建设之搭建开源SIEM平台

    https://www.freebuf.com/special/127172.html https://www.freebuf.com/special/127264.html https://www. ...

  8. 企业安全建设之搭建开源SIEM平台(上)

    前言 SIEM(security information and event management),顾名思义就是针对安全信息和事件的管理系统,针对大多数企业是不便宜的安全系统,本文结合作者的经验介绍 ...

  9. Docker 搭建开源跳板机_jumpserver (运维开源堡垒机_jumpserver) Centos_7.0

    最近看到一个开源项目(jumpserver)  很不错  还是用Docker  部署得 ... 抽了点时间拿来学习一下  部署    分析   简单使用一下  ....好了先搭起来 准备 工作:    ...

随机推荐

  1. Reversing-x64Elf-100----攻防世界

    题目来源:攻防世界 环境:win10 软件:pycharm.64位的ida 常规的操作ida打开查看,看到了main函数,

  2. 使用HttpURLConnection通过post请求服务器时,URLEncode编码的必要性

    通过Post提交表单数据时,数据类型为x-www-urlencoded,提交到服务器的数据服务器默认是通过URLEncoder.encode()编码过得,所以服务器处理时会用URLDecoder.de ...

  3. vue-cli 初始化项目时开发环境中的跨域问题

    最近刚刚完成自己的毕业设计(基于Vue的信息资讯展示与管理平台),于是想整理一下过程遇到的一些问题. 项目基于Vue开发,使用 Vue-cli 初始化项目文件目录时默认占用8080端口,而我又想使用 ...

  4. 【转载】如何快速转载CSDN中的博客

    前言   对于喜欢逛CSDN的人来说,看别人的博客确实能够对自己有不小的提高,有时候看到特别好的博客想转载下载,但是不能一个字一个字的敲了,这时候我们就想快速转载别人的博客,把别人的博客移到自己的空间 ...

  5. Java异常的限制

    Java异常的限制 我在看JAVA编程思想,讲到异常的限制,看的代码和解释,非常的难看下去,直接写了他的代码. java编程思想关于异常限制的逻辑 它以棒球比赛为例子. 定义了Inning(一局比赛) ...

  6. Linux命令:date命令

    date命令作用:显示和设置系统的日期和时间 一.设置系统日期时间 格式:date [MMDDhhmm[[CC]YY][.ss]] 举例:将当前系统时间改为 2020年10月1日12点10分 # da ...

  7. 想要转战CSDN了!!

    CSDN博客地址: https://blog.csdn.net/weixin_41559364

  8. DotNetSpeech----文本转wave语音文件

    wav操作引入dll(DotNetSpeech.dll),引入以后需要选中项目中引入的dll,鼠标右键,选择属性,把“嵌入互操作类型”设置为False.不然会提示无法嵌入互操作类型"Spee ...

  9. memcached 和 redis 性能测试比对

    网上很多关于memcached 和 redis 区别的介绍,大部分都是说redis比memcached支持的数据类型多的话题,而性能比对确很少,我专门针对两者进行了性能测试比对. 测试内容如下: 两者 ...

  10. AngularJs 禁止模板缓存

    因为AngularJs的特性(or 浏览器本身的缓存?),angular默认的HTML模板加载都会被缓存起来.导致每次修改完模板之后都得经常需要清除浏览器的缓存来保证浏览器去获得最新的html模板,自 ...