国内网络环境使用docker快速搭建jenkins环境

docker 11个月前 will
631 0

国内网络环境使用docker快速搭建jenkins环境

主机目录规划:

基础设置目录: /opt/infra/jenkins

容器中目录规划:
jenkins服务内的所有文件暴露到主机: ./.storage/jenkins/jenkins_home

mkdir -p /opt/infra/jenkins
cd /opt/infra/jenkins
mkdir -p ./.storage/etc
mkdir -p ./.storage/jenkins/jenkins_home/
chown  -R 1000:1000 ./.storage/jenkins/jenkins_home

tee storage/jenkins/jenkins_home/hudson.model.UpdateCenter.xml <<- EOF
<?xml version='1.1' encoding='UTF-8'?>
<sites>
  <site>
    <id>default</id>
    <url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
  </site>
</sites>
EOF

mkdir -p ./.storage/jenkins/jenkins_home

chown  -R 1000:1000 ./.storage/jenkins/jenkins_home
### 添加 /usr/bin/git 到容器中

tee ./Dockerfile <<-EOF
FROM jenkins/jenkins:2.220
# if we want to install via apt
USER root
RUN apt-get install -y git wget curl 
# drop back to the regular jenkins user - good practice
USER jenkins
EOF
#docker build . -t minlia/jenkins:2.220

# 合并 主机 m2 与容器中的 m2
mkdir -p /opt/maven/.m2
chmod -R 0777 /opt/maven/.m2
\mv /root/.m2 /root/.m2_old
ln -s /opt/maven/.m2 /root/.m2

# 开始创建 jenkins 容器
tee ./docker-compose.yml <<- EOF
version: '3'
services:
  docker_jenkins:
    networks:
      - docker_jenkins_network
    restart: always
    image: "jenkins/jenkins:2.220"
    container_name: docker_jenkins
    dns:
      - "8.8.8.8"
      - "1.1.1.1"
    ports:
      - '3030:8080'
      # - '50000:50000'
      - '3000:5000'
    volumes:
      - "./.storage/jenkins/jenkins_home:/var/jenkins_home"
      - "/opt/maven/.m2:/var/jenkins_home/.m2"
      - /var/run/docker.sock:/var/run/docker.sock
      - /usr/bin/docker:/usr/bin/docker
      - /usr/lib/x86_64-linux-gnu/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7
      # - "./storage/etc/hudson.model.UpdateCenter.xml:/var/jenkins_home/hudson.model.UpdateCenter.xml"
networks:
  docker_jenkins_network:
    driver: bridge
    #driver_opts:
    #  com.docker.network.driver.mtu: 1450
EOF

版权声明:will 发表于 2020-02-19 11:50:24。
转载请注明:国内网络环境使用docker快速搭建jenkins环境 | 敏利雅

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...