Ubuntu 虚拟机实现jenkins+maven+docker+tomcat+github打包部署

1.环境: ubuntu 16.0.4

2. 利用docker-compose(jenkins+tomcat+tomcat+mysql+redis+nginx),java+maven直接在虚拟机里搭建。

3.docker-compose文件:

version: "3"

services:
  redis:
    # 指定镜像
    image: redis
    container_name: redis
    ports:
      # 端口映射
      - 6379:6379
    restart: always
    volumes:
      # 目录映射
      - "./redis/conf:/usr/local/etc/redis"
      - "./redis/data:/data"
    command:
      # 执行的命令
      redis-server --appendonly yes
  db:
    image: mysql
    container_name: mysql
    environment:
      MYSQL_ROOT_PASSWORD: "123456"
    volumes:
      - "./mysql/conf:/etc/mysql/conf.d"
      - "./mysql/logs:/logs"
      - "./mysql/data:/var/lib/mysql"
    ports:
      - "3306:3306"
  nginx:
    container_name: nginx
    restart: always
    image: nginx
    ports:
      - "80:80"
      - "443:443"
      - "5050:5050"
      - "4040:4040"
    volumes:
      - "./nginx/conf/nginx.conf:/etc/nginx/nginx.conf"
      - "./nginx/conf.d:/etc/nginx/conf.d"
      - "./nginx/logs/:/var/log/nginx/"
      - "./nginx/www:/usr/share/nginx/html:rw"
    depends_on:
      - tomcat                                                
  tomcat:
    container_name: tomcat
    restart: always
    image: tomcat
    ports:
      - 8080:8080
      - 8009:8009
    volumes:
      - "./tomcat/conf/server.xml:/usr/local/tomcat/conf/server.xml"
      - "./tomcat/webapps:/usr/local/tomcat/webapps"
      - "./tomcat/logs/:/usr/local/tomcat/logs/"
      - "./tomcat/conf/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml"
    depends_on:
      - db
  jenkins:
    restart: always
    image: jenkins/jenkins
    container_name: jenkins
    ports:
      - 9090:8080
      - 50000:50000
    environment:
      TZ: Asia/Shanghai
    volumes:
      - "./jenkins/jenkins_home:/var/jenkins_home"
      #外部的Java和maven路径,这个需要挂载到jenkins里,要不然在设置jenkins的时候会提示找不到Java,maven路径		
      - "/usr/local/java/jdk1.8.0_211/bin/java:/usr/java/jdk1.8.0_211/bin/java"
      - "/usr/local/java/jdk1.8.0_211:/usr/java/jdk1.8.0_211"
      - "/usr/local/apache-maven-3.6.3:/usr/local/apache-maven-3.6.3"

jenkins配置注意点1:

Ubuntu 虚拟机实现jenkins+maven+docker+tomcat+github打包部署_第1张图片

 

你可能感兴趣的:(Ubuntu 虚拟机实现jenkins+maven+docker+tomcat+github打包部署)