1.编写Dokcerfile
FROM centos:7
MAINTAINER huangkai<[email protected]>
RUN yum -y install vim \
&& yum -y install net-tools \
&& yum install dejavu-sans-fonts fontconfig -y
ADD jdk-11_linux-x64_bin.tar.gz /usr/local/
ADD apache-tomcat-9.0.75.tar.gz /usr/local/
ADD apache-jmeter-5.5.tgz /usr/local/
ADD apache-ant-1.10.13-bin.tar.gz /usr/local/
ENV MYPATH /usr/local
WORKDIR $MYPATH
COPY jenkins.war ./apache-tomcat-9.0.75/webapps/
COPY jmeter.results.shanhe.me.xsl ./apache-jmeter-5.5/extras/
RUN cp ./apache-jmeter-5.5/extras/ant-jmeter-1.1.1.jar ./apache-ant-1.10.13/lib/
RUN mkdir -p /usr/local/testcases /usr/local/testcases/case /usr/local/testcases/report
COPY mysql-connector-java-5.1.44-bin.jar ./apache-jmeter-5.5/lib/mysql-connector-java-5.1.44-bin.jar
COPY build.xml ./testcases
ENV JAVA_HOME /usr/local/jdk-11
ENV ANT_HOME /usr/local/apache-ant-1.10.13
ENV JMETER_HOME /usr/local/apache-jmeter-5.5
ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.75
ENV CATALINA_BASE /usr/local/apache-tomcat-9.0.75
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$ANT_HOME/lib:$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin:$CATALINA_HOME/lib:$ANT_HOME/bin:$JMETER_HOME/bin
EXPOSE 8080
CMD /usr/local/apache-tomcat-9.0.75/bin/startup.sh && tail -F /usr/local/apache-tomcat-9.0.75/bin/logs/catalina.out
2.编写docker-compose.yml
3.将需要的安装包(jdk、tomcat、jmeter、ant、Jenkins)统一和docker-compose放在同一个文件夹下
执行 docker-compose up -d,就可以启动容器了
停止所有docker-compose生成的容器 ,在docker-compose.yml文件目录下执行docker-compose stop,删除所有的容器执行docker-compose down
4.build.xml文档配置
5.jenkins配置
打开链接http://ip:8080/jenkins,一开始会报错,在上面的Dockerfile文件中安装了yum install dejavu-sans-fonts fontconfig -y就可以了
cat /root/.jenkins/secrets/initialAdminPassword 获取密码,然后选择”选择插件来安装“
选择0个插件,直接下一步
创建好用户后,进入系统管理-插件管理-Advanced settings页面
更改为https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
方法:进入default.json所在目录 执行以下命令,
sed -i 's#updates.jenkins.io/download/plugins#mirrors.tuna.tsinghua.edu.cn/jenkins/plugins#g' default.json
sed -i 's#www.google.com#www.baidu.com#g' default.json
标签:bin,compose,jdk,tomcat,usr,apache,HOME,jmeter,local From: https://www.cnblogs.com/orangeha/p/17447640.html