docker部署sonarqube

  1. 云栖社区>
  2. 博客>
  3. 正文

docker部署sonarqube

流浪的猪猪 2019-07-28 21:14:15 浏览206
展开阅读全文

gitlab-ce + gitlab-runner + sonarqube,在提交代码时对代码质量进行检测,对不符合要求的代码不允许提交到gitlab

1、配置docker-compose.yml

version: '3.1'
services:

  gitlab-ce:
    image: 'gitlab/gitlab-ce:latest'
    container_name: gitlab-ce
    restart: always
    hostname: 'gitlab.localhost.com'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://192.168.31.109'
    ports:
      - '80:80'
      - '443:443'
      - '10022:22'
    volumes:
      - '/root/gitlab-ce/home/config:/etc/gitlab'
      - '/root/gitlab-ce/home/logs:/var/log/gitlab'
      - '/root/gitlab-ce/home/data:/var/opt/gitlab'
    networks:
      - 'default'

  gitlab-runner:
    image: 'gitlab/gitlab-runner:latest'
    container_name: gitlab-runner
    depends_on:
      - 'gitlab-ce'
    restart: always
    volumes:
      - '/root/gitlab-ce/runnerconfig:/etc/gitlab-runner'
      - '/var/run/docker.sock:/var/run/docker.sock'
    networks:
      - 'default'
    links:
      - 'gitlab-ce:gitlab.localhost.com'

  mysql:
    image: mysql:5.7.27
    container_name: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    ports:
      - 3306:3306
    volumes:
      - /root/gitlab-ce/mysql/data:/var/lib/mysql
      - /root/gitlab-ce/mysql/logs:/logs
      - /root/gitlab-ce/mysql/init:/docker-entrypoint-initdb.d
    environment:
      MYSQL_ROOT_PASSWORD: root@123456
      MYSQL_USER: test   #创建test用户
      MYSQL_PASSWORD: test  #设置test用户的密码
    networks:
      - 'default'

  sonarqube:
    image: sonarqube:7.7-community
#    image: sonarqube:latest
    container_name: sonarqube
    ports:
      - "9000:9000"
      - "9002:9002"
    volumes:
      - "/root/gitlab-ce/sonarqube/conf:/opt/sonarqube/conf"
      - "/root/gitlab-ce/sonarqube/extensions:/opt/sonarqube/extensions"
      - "/root/gitlab-ce/sonarqube/logs:/opt/sonarqube/logs"
      - "/etc/sysctl.conf:/etc/sysctl.conf"
#     - "/root/gitlab-ce/sonarqube/data:/opt/sonarqube/data"
    environment:
      sonar.jdbc.username: root   #root管理员用户密码
      sonar.jdbc.password: root@123456   #创建test用户
      sonar.jdbc.url: "jdbc:mysql://mysql:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false"
    restart: always
    depends_on:
      - mysql
    links:
      - mysql
    networks:
      - 'default'

    sysctls:
      - net.core.somaxconn=1024
    ulimits:
      nproc: 65536
      nofile:
        soft: 65536
        hard: 65536  

networks:
  default:
    driver: 'bridge'

网友评论

登录后评论
0/500
评论
流浪的猪猪
+ 关注