龙空技术网

持续集成CICD实战2—LNMP基础镜像构建,及harbor镜像仓库的部署

云在身边cloudhere 248

前言:

如今同学们对“centos65解压tar”都比较关心,大家都需要知道一些“centos65解压tar”的相关内容。那么小编也在网上网罗了一些有关“centos65解压tar””的相关内容,希望姐妹们能喜欢,同学们快快来学习一下吧!

第二阶段:LNMP基础镜像构建,及harbor镜像仓库的部署

实战内容分为阶段:

第一阶段:cicd的介绍,环境准备,dockers安装及代码仓库的建立(这里用的是svn)

第二阶段:LNMP基础镜像构建,及harbor镜像仓库的部署

第三阶段:jenkins部署及配置

第四阶段:发布代码到测试环境并构建镜像,部署wordpress测试网站

第五阶段:提交测试成功镜像到harbor镜像仓库

第六阶段:发布wordpress到生产环境

第七阶段:发布wordpress新代码到生产环境之后进行回滚

一、cicd节点——LNMP基础镜像构建

1、Nginx基础镜像构建

1.1、准备nginx-dockerfile及配置文件

1.2、编辑nginx-dockerfile

vim Dockerfile

FROM centos:latestMAINTAINER zhaoningRUN yum install -y gcc gcc-c++ make openssl-devel pcre-devel && \ yum clean allADD nginx-1.12.1.tar.gz /tmpRUN cd /tmp/nginx-1.12.1 && \ ./configure --prefix=/usr/local/nginx && \ make -j 2 && make install && \ rm -rf /tmp/nginx-1.12.1COPY nginx.conf /usr/local/nginx/conf EXPOSE 80CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]

1.3、编辑nginx-配置文件

vim nginx.conf

user root; worker_processes auto;  error_log logs/error.log info; pid logs/nginx.pid;   events { use epoll; } http {  include mime.types; default_type application/octet-stream;  log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';  access_log logs/access.log main; sendfile on; keepalive_timeout 65;  server { listen 80; server_name localhost; root html; index index.php index.html;  location ~ \.php$ { root html; fastcgi_pass php-cgi:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  include fastcgi_params; } }}

1.4、docker-build构建nginx镜像

docker build -t reg.yunwei.com/library/nginx:latest .

2、PHP基础镜像构建

2.1、准备php-dockerfile及配置文件

2.2、编辑php-dockerfile

vim Dockerfile

FROM centos:latestMAINTAINER zhaoningRUN yum install -y gcc gcc-c++ gd-devel libxml2-devel \ automake autoconf libtool make \ libcurl-devel libjpeg-devel libpng-devel openssl-devel && \ yum clean allADD php-5.6.31.tar.gz /tmp/RUN cd /tmp/php-5.6.31 && \ ./configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --with-mysql --with-mysqli \ --with-openssl --with-zlib --with-curl --with-gd \ --with-jpeg-dir --with-png-dir --with-iconv \ --enable-fpm --enable-zip --enable-mbstring && \ make -j 4 && make install && \ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf && \ sed -i "s/127.0.0.1/0.0.0.0/" /usr/local/php/etc/php-fpm.conf && \ cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm && \ chmod +x /etc/init.d/php-fpm && \ rm -rf /tmp/php-5.6.31 COPY php.ini /usr/local/php/etc EXPOSE 9000CMD /etc/init.d/php-fpm start && tail -F /var/log/messages

2.3、docker-build构建php镜像

docker build -t reg.yunwei.com/library/php:latest .

二、cicd节点——Harbor镜像创库构建1、cicd节点上传Harbor安装包,并解压

tar zxf harbor-offline-installer-v1.4.0.tgz && mv harbor /opt/

2、新建harbor工作目录

mkdir -p /date/harbor

3、上传harbor的cert证书压缩包4、cert.tar.gz解压移动到/data/harbor/cert目录下

tar zxf cert.tar.gz && mv cert /date/harbor/

5、到/opt/harbor目录下修改harbor配置文件

找到如下参数,并修为如下配置:

vim docker-compose.clair.yml

/data/harbor/notary-db:/var/lib/mysql:z

vim docker-compose.notary.yml

/data/harbor/notary-db:/var/lib/mysql:z

vim docker-compose.yml

/data/harbor/:/var/log/docker/:z/data/harbor/registry:/storage:z/data/harbor/database:/var/lib/mysql:z/data/harbor/config/:/etc/adminserver/config/:z/data/harbor/secretkey:/etc/adminserver/key:z/data/harbor/:/data/:z/data/harbor/secretkey:/etc/ui/key:z/data/harbor/ca_download/:/etc/ui/ca/:z/data/harbor/psc/:/etc/ui/token/:z/data/harbor/job_logs:/var/log/jobs:z/data/harbor/secretkey:/etc/jobservice/key:z

vim harbor.cfg

hostname = reg.yunwei.comui_url_protocol = httpsssl_cert = /data/harbor/cert/harbor.crtssl_cert_key = /data/harbor/cert/harbor.keysecretkey_path = /data/harborharbor_admin_password = admin

注意:

ssl_cert = /data/harbor/cert/harbor.crtssl_cert_key = /data/harbor/cert/harbor.key以上为ca证书名称,必须与实际文件同名secretkey_path = /data/harbor 为ca证书目录
6、打开web界面

标签: #centos65解压tar