简体   繁体   English

在CI / CD管道中使用Docker运行SonarQube

[英]Running SonarQube with Docker in CI/CD pipeline

I'm trying to get SonarQube stood up and scanning applications via Docker containers on an EC2 instance. 我试图让SonarQube站起来,并通过EC2实例上的Docker容器扫描应用程序。 I've spent the past day poring over SonarQube and Postgres documentation and am having very little luck. 我花了整整一天的时间仔细研究SonarQube和Postgres文档,但运气很少。

The most sensible guide I've found is the docker-sonarqube project maintained by SonarSource. 我找到的最明智的指南是SonarSource维护的docker -sonarqube项目 More specifically, I am following the SonarQube/Postgres guide using docker-compose . 更具体地说,我使用docker-compose遵循SonarQube / Postgres指南

My docker-compose.yml file looks identical to the one provided by SonarSource: docker-compose.yml文件看起来与docker-compose.yml文件相同:

sonarqube:
  build: "5.2"
  ports:
   - "9000:9000"
  links:
   - db
  environment:
   - SONARQUBE_JDBC_URL=jdbc:postgresql://db:5432/sonar
  volumes_from:
   - plugins

db:
  image: postgres
  volumes_from:
    - datadb
  environment:
   - POSTGRES_USER=sonar
   - POSTGRES_PASSWORD=sonar

datadb:
  image: postgres
  volumes:
    - /var/lib/postgresql
  command: /bin/true

plugins:
  build: "5.2"
  volumes:
   - /opt/sonarqube/extensions
   - /opt/sonarqube/lib/bundled-plugins
  command: /bin/true

docker ps -a yields: docker ps -a产生:

CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                           PORTS                    NAMES
2d003aef18f2        dockersonarqube_sonarqube   "./bin/run.sh"           47 seconds ago      Up 46 seconds                    0.0.0.0:9000->9000/tcp   dockersonarqube_sonarqube_1
c7d5043f4381        dockersonarqube_plugins     "./bin/run.sh /bin/tr"   48 seconds ago      Exited (0) 46 seconds ago                                 dockersonarqube_plugins_1
590c72b4a723        postgres                    "/docker-entrypoint.s"   48 seconds ago      Up 47 seconds                    5432/tcp                 dockersonarqube_db_1
c105e6aebe09        postgres                    "/docker-entrypoint.s"   49 seconds ago      Exited (0) 48 seconds ago                                 dockersonarqube_datadb_1

Latest output from the sonarqube_1 container is: sonarqube_1容器的最新输出为:

sonarqube_1 | 2016.01.20 17:49:09 INFO  web[o.s.s.a.TomcatAccessLog] Web server is started
sonarqube_1 | 2016.01.20 17:49:09 INFO  web[o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
sonarqube_1 | 2016.01.20 17:49:09 INFO  app[o.s.p.m.Monitor] Process[web] is up

What does concern me is the latest output from the db_1 container: 我关心的是db_1容器的最新输出:

PostgreSQL init process complete; ready for start up.

LOG:  database system was shut down at 2016-01-20 17:48:40 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
ERROR:  relation "schema_migrations" does not exist at character 21
STATEMENT:  select version from schema_migrations
ERROR:  relation "schema_migrations" does not exist at character 21
STATEMENT:  select version from schema_migrations
ERROR:  relation "schema_migrations" does not exist at character 21
STATEMENT:  select version from schema_migrations
ERROR:  relation "schema_info" does not exist at character 15
STATEMENT:  SELECT * FROM "schema_info"  LIMIT 1

Navigating to http://my.instance.ip:9000 is unsuccessful. 导航到http://my.instance.ip:9000不成功。 I am able to hit the respective ports of other running containers from the same machine. 我可以在同一台计算机上运行其他正在运行的容器的相应端口。

Could anyone help to point me in the right direction? 有人可以帮我指出正确的方向吗? Any other guides or documentation that may serve me better? 还有其他更适合我的指南或文档吗? I also see issues with the documentation stating that analyzing a project begins with mvn sonar:sonar , but I'll defer that for now. 我还看到文档中存在问题,这些问题表明分析项目始于mvn sonar:sonar ,但我暂时将其推迟。 Thank you very much in advance! 提前非常感谢您!

Use this image I modified this image to talk to a RDS instance. 使用此图像,我修改了此图像以与RDS实例通信。

EC2(docker-sonar)<==> RDS postgres EC2(泊坞声纳)<==> RDS postgres

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM