Dockerfile自建jenkins镜像

Dockerfile

FROM centos:centos7

WORKDIR /etc/yum.repos.d

RUN mkdir bak && mv ./*.repo bak/; \
    curl -o CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo; \
    sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo; \
    yum -y install epel-release.noarch bash-completion net-tools wget unzip  git freetype fontconfig; \
    mkdir /root/jenkins

WORKDIR /usr/local/

ADD ./apache-maven-3.9.5-bin.zip ./
ADD ./apache-ant-1.10.14-bin.tar.gz ./
ADD ./jdk-8u212-linux-x64.tar.gz ./

RUN unzip apache-maven-3.9.5-bin.zip


ENV MAVEN_HOME=/usr/local/apache-maven-3.9.5 \
    JAVA_HOME=/usr/local/jdk1.8.0_212 \
    CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/ \
    ANT_HOME=/usr/local/apache-ant-1.10.14 \
    PATH=${MAVEN_HOME}/bin:${ANT_HOME}/bin:${JAVA_HOME}/bin:${PATH}

RUN echo 'export PATH="${MAVEN_HOME}/bin:${ANT_HOME}/bin:${JAVA_HOME}/bin:${PATH}"' >> ~/.bashrc


WORKDIR /root/jenkins

COPY ./jenkins.war ./ 
COPY ./jenkins.sh  ./
COPY ./checkstyle-10.12.4-all.jar ./
COPY ./change_file/myConf.tar ./
COPY ./change_file/plugins.tar ./
COPY ./change_file/tools.tar ./

EXPOSE 8080
ENTRYPOINT [ "/bin/bash", "/root/jenkins/jenkins.sh" ]

jenkins.sh

#!/bin/bash
source /root/.bashrc
cd /root/jenkins && nohup java -jar -Dhudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION=true ./jenkins.war  &
sleep 5
pkill java 

tar -xf myConf.tar -C /root/.jenkins/
tar -xf plugins.tar -C /root/.jenkins/
tar -xf tools.tar -C /root/.jenkins/

java -jar -Dhudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION=true ./jenkins.war
docker build -t jenkins_test:2.190.2 .
docker commit -a jx -m 'jenkins_test' focused_vaughan my_jenkins:test

你可能感兴趣的:(docker相关记录随笔,jenkins,运维,docker,centos)