代码检测docker-sonarqube

Posted g2thend

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了代码检测docker-sonarqube相关的知识,希望对你有一定的参考价值。

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

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'

未测试。
参考:
https://yq.aliyun.com/articles/711488?spm=a2c4e.11155435.0.0.16cc2eb4nWOrV4
https://www.ibm.com/developerworks/cn/java/j-lo-sonar/

以上是关于代码检测docker-sonarqube的主要内容,如果未能解决你的问题,请参考以下文章

如何使用模块化代码片段中的LeakCanary检测内存泄漏?

十条实用的jQuery代码片段

Android:使用Tab检测单个片段viewpager

高效Web开发的10个jQuery代码片段

在 Python 多处理进程中运行较慢的 OpenCV 代码片段

Python代码阅读(第13篇):检测列表中的元素是否都一样