An overview of
the Docker release version should be as consistent as possible with the existing version release, refer to the version release process of jenkins; I think there are many similarities between the maven library and the docker library, so the packaging process refers to the maven packaging process; focus on docker automatic packaging, Control of push, pull, run, kill related processes.
2. Requirements analysis
1. The deployment process is basically the same as the current jenkins release process. The trigger conditions for the current version release are: timed release, manual release, and the release process includes: download code, build, stop tomcat, clear cache, current version, upload war Package, upload and replace configuration files, start tomcat and other steps.
2. For those who use docker containers, the process of building an image and uploading an image needs to be added.
3. Deployment diagram
jekins and web server need to have docker environment, including docker and docker-compose
4. Overall process
5. Detailed design
1. Download code package
1) The configuration file information of each environment should be included under the code path, as shown below:
2 Docker image version Define
the current version of the docker image using ${BUILD_NUMBER}, the previous version using $$((${BUILD_NUMBER}-1))
3 Prepare materials
Compress the environment configuration file as evnconfig.zip, copy it to the Dockerfile directory;
copy the war package to Dockefile content.
4 Dockerfile build image
Dockerfile is as follows: #Parent
image
FROM centos7-tomcat7-jdk7:1.0 #Maintainer
MAINTAINER
luo tian "[email protected] #Sync
material
ADD document.war.tar /root/tomcat7/webapp
ADD envconfig.tar /root/tomcat7/webapp #Expose
access port
EXPOSE 8080 #Startup
service
ENTRYPOINT sh /root/tomcat7/bin/startup.sh The
build command is as follows: docker build -t xx.com/ecf/document.war:v1.xx .
Note: The image name is part of the composition: warehouse url/project Name/image name: image version
Push image #Log
in to the warehouse
docker login yy.com #Upload the
image
docker push xx.com/ecf/document.war:v1.xx
docker warehouse view image
5 The target server executes the shell command #Stop
the container
docker kill document.war #delete the
container
docker rm document.war #start
a new container
docker run -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock -v /root/tomcat7/logs:/var/tomcat7/logs --name document.war -d xx.com/document.war:1.xx
#删除旧镜像
docker rmi xx.com/document.war:1.xx
完整Dockerfile代码
[java] view plain copy
1.FROM y.com/test/centos7-jdk7-tomcat8:2.0.1
2.MAINTAINER luo,ten <[email protected]>
3.
4.# Install war
5.RUN mkdir /apps/document.war
6.RUN mkdir /apps/tomcat8/conf/Catalina
7.RUN mkdir /apps/tomcat8/conf/Catalina/localhost
8.RUN mkdir /apps/document.war_work
9.COPY target/document.war /apps/document.war
10.ADD document.war.xml /apps/tomcat8/conf/Catalina/localhost
The code executed by the complete docker image compilation server
[java] view plain copy
1.cd /root/jenkins_home/workspace/DEV-DOCUMENT/document.war/target/
2.unzip document.war-0.0.1-SNAPSHOT.war -d document.war
3.cd ../
4.docker build -t y.com/test/document.war:${BUILD_NUMBER} .
5.docker login -p admin123 -u admin y.com
6.docker push y.com /test/document.war:${BUILD_NUMBER}
7.docker rmi y.com/test/document.war:${BUILD_NUMBER} The
complete docker application says the execution code on the server:
[java] view plain copy
1.docker kill document .war
2.docker rm -f document.war
3.docker rmi y.com/test/document.war:$((${BUILD_NUMBER}-1))
4. docker run -v /root/document.war/logs:/apps/tomcat8/logs --name document.war -p 8081:8080 -itd --privileged y.com/test/document.war:${BUILD_NUMBER } /usr/sbin/init
Six problems to be solved
1. At present, many system kernels do not comply with docker deployment
FATA[0001] Your Linux kernel version 2.6.32-504.el6.x86_64 is not supported for running docker. Please upgrade your kernel to 3.10.0 or newer.
2. Important configuration of docker
1. to increase the internal image warehouse, configuration file or startup command to increase: ADD_REGISTRY='--add-registry yy.com'
2. The internal and external warehouses adopt http method, configuration file or startup Command addition: INSECURE_REGISTRY='--insecure-registry yy.com' (/usr/lib/systemd/system/docker.service)
Third, docker, jenkins, git, svn and other installations may encounter network problems because they need to be installed Some related dependencies
3. The application must be packaged with maven or ant
Use Docker to build a Docker cluster with continuous integration and automatic deployment
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326152648&siteId=291194637
Recommended
Ranking