In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Docker deployment of continuous integration environment
Deployment preparation
Jenkins Server 10.1.2.183
Docker Server 10.1.2.184
Git/Harbor Server 10.1.2.182
Each service version
CentOS 7.4_x64
Maven 3.5
Tomcat 8
JDK 1.8
Jenkins 2.6
DockerCE 17.06
On the Git server
1. Install Git
Yum install git
2. Create Git users
Useradd gitpasswd git
3. Create a warehouse
Su-gitmkdir solo.git
Cd / home/git/solo.git
Git-bare init
Install the docker service on the git server and the jenkins server to add the domestic mirror source and add the trust to the harbor host in the / etc/docker/daemon.json of the two servers, as follows
{"registry-mirrors": ["https://registry.docker-cn.com"],"
"insecure-registries": ["10.1.2.182"]}
On the jenkins server
Install git, using git's client
Yum install git
Install openjdk1.8
Tar zxvf jdk-8u45-linux-x64.tar.gz & & mv jdk1.8.0_45 / usr/local/
Download the empty project on the git server and create a blank sample repository locally
Git clone 10.1.2.182:/home/git/solo.git # set up a blank warehouse locally
Download the sample project on github
Git clone https://github.com/lizhenliang/tomcat-java-demo
Extract the downloaded sample project, copy the content to the blank warehouse and submit it to the local git repository
Unzip solo-master.zip & & cp-r solo-master/* solo/ & & git add. & & git commit-m "all" # in this case, the simulation is to pull down, modify, and upload the code to the git server.
Remote git server that mentions the soho project
Git push origin master
On the jekins server
Install the jenkins,dockerfile file using dockerfile as follows
Mkdir / root/jenkins;cd / root/jenkins
Cat Dockerfile
FROM jenkins
USER root
RUN echo 'Acquire::Check-Valid-Until no;' > / etc/apt/apt.conf.d/99no-check-valid-until
RUN apt-get clean
RUN echo'> / etc/apt/sources.list\
& & echo 'deb http://security.debian.org/ jessie/updates main > > / etc/apt/sources.list\
& & echo 'deb-src http://security.debian.org/ jessie/updates main > > / etc/apt/sources.list\
& & echo 'deb http://archive.debian.org/debian/ jessie-backports non-free > > / etc/apt/sources.list\
& & echo 'deb-src http://archive.debian.org/debian/ jessie-backports non-free > > / etc/apt/sources.list\
& & echo 'deb http://archive.debian.org/debian/ jessie main contrib non-free > > / etc/apt/sources.list\
& & echo 'deb-src http://archive.debian.org/debian/ jessie main contrib non-free > > / etc/apt/sources.list
RUN apt-get update & & apt-get install-y git libltdl-dev
Build a jenkins image
Docker build-t jenkins:v1
Start jenkins
Docker run-d\
-- name jenkins\
-p 808014 080\
-v / var/jenkins_home/:/var/jenkins_home\
-v / usr/local/apache-maven-3.5.0:/usr/local/maven\
-v / usr/local/jdk1.8.0_45:/usr/local/jdk\
-v / var/run/docker.sock:/var/run/docker.sock\
-v $(which docker): / usr/bin/docker\
-v ~ / .ssh:/root/.ssh\
Jenkins:v1
Configure docker and jenkins the login-free configuration for harbor is used for push and pull between git
Ssh-keygen
Ssh-copy-id 10.1.2.182
Visit 10.1.2.183 8080 for jenkins installation
Configure jenkins
Modify jenkins domestic upgrade source
Https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/current/update-center.json
System Management-Global tool configuration
Configure jdk,maven,git
Configure key login to docker hosts on jenkins
Ssh-copy-id 10.1.2.184
Add credentials on the jenkins page credential management
Copy the contents of the / root/.ssh/id_rsa file on the jenkins host into Private Key
Add remote host
System Management-system Settings
Select the ROOT user you added earlier
Deploy the project
Create a new maven project
To configure Git, credentials do not need to be selected, because the jenkins server has been configured to avoid interaction with the git server
PS: in the figure above, if the git account cannot be used, use the root account.
Build option
Build a test to see if maven is finished.
Next, we will package the built package into an image and upload it to the harbor repository.
Build the tomcat basic image on jenkins, and then build the project based on this basic image
Mkdir / root/solo
Cat Dockerfile
FROM centos:7
MAINTAINER www.aliangedu.com
RUN yum install unzip iproute-y
ENV JAVA_HOME / usr/local/jdk
ADD apache-tomcat-8.0.46.tar.gz / usr/local
RUN mv / usr/local/apache-tomcat-8.0.46 / usr/local/tomcat
WORKDIR / usr/local/tomcat
EXPOSE 8080
ENTRYPOINT [". / bin/catalina.sh", "run"]
Construction
Docker build-t 10.1.2.182/test/tomcat:v1. # when building here, mark it directly and push it directly to the warehouse later.
Push
Create a test project in harbor and set the project member chench permission to project administrator or development permission, otherwise you will not be able to push
Docker push 10.1.2.182/test/tomcat:v1
Choose to build the execution script, use Dockfile to build the image in the script, and then upload the image to the GIt repository
Select ssh to execute the shell script to the remote host
Pull the image from Git repository to docker server and run it
The browser accesses the docker host ip:8888 to see if the startup is successful.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.