```services: jenkins: image: jenkins:latest ...
# pact-broker
d
Copy code
services:
  jenkins:
    image: jenkins:latest
    container_name: jenkins
    user: root
    restart: unless-stopped
    volumes:
      - jenkins_data:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - sonarnet
    ports:
      - 8080:8080
      - 50000:50000
    

  sonarqube:
    image: sonarqube:7.7-community
    container_name: sonarqube
    restart: unless-stopped
    volumes:
      - sonarqube_conf:/opt/sonarqube/conf
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_extensions:/opt/sonarqube/extensions
      - sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
    networks:
      - sonarnet
    ports:
     - 9000:9000
    environment:
      - sonar.jdbc.username=sonar
      - sonar.jdbc.password=sonar
      - sonar.jdbc.url=jdbc:<postgresql://db:5432/sonar>
      - SONAR_WEB_PORT=9000

  db:
    image: postgres
    container_name: postgres
    restart: unless-stopped
    networks:
      - sonarnet
    environment:
      - POSTGRES_USER=sonar
      - POSTGRES_PASSWORD=sonar
    volumes:
      - postgresql:/var/lib/postgresql
      - postgresql_data:/var/lib/postgresql/data

  nginx:
    image: nginx
    container_name: nginx
    restart: unless-stopped
    networks:
      - sonarnet
    volumes:
      - /home/ec2-user/ci/nginx:/etc/nginx
    ports:
      - 443:443


  brokerdb:
    image: postgres
    container_name: brokerdb
    restart: unless-stopped
    networks:
      - sonarnet
    volumes:
      - postgres-volume:/var/lib/brokerdb/data
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=postgres

  pact-broker:
    image: pactfoundation/pact-broker:2.110.0-pactbroker2.107.1
    ports:
      - "9292:9292"
    container_name: pact-broker
    networks:
      - sonarnet
    depends_on:
      - brokerdb
    environment:
      PACT_BROKER_PORT: '9292'
      PACT_BROKER_DATABASE_URL: "<postgres://postgres:password@brokerdb/postgres>"
      PACT_BROKER_LOG_LEVEL: DEBUG
      PACT_BROKER_SQL_LOG_LEVEL: DEBUG
      PACT_BROKER_HTTP_DEBUG_LOGGING_ENABLED: "True"
      # PACT_BROKER_DATABASE_CONNECT_MAX_RETRIES is only needed for docker-compose
      # because the database takes longer to start up than the puma process
      # Should not be needed in production.
      PACT_BROKER_DATABASE_CONNECT_MAX_RETRIES: "5"
      # The list of allowed base URLs (not setting this makes the app vulnerable to cache poisoning)
      # This list allows the app to be addressed from the host and from within another docker container correctly
      # Ngnix config below makes the app accessible on ports 443 and 80, while the Ruby application itself runs on port 9292
#      PACT_BROKER_BASE_URL: '<https://localhost> <http://localhost> <http://localhost:9292> <http://pact-broker:9292> <https://host.docker.internal> <http://host.docker.internal> <http://host.docker.internal:9292>'

networks:
  sonarnet:
    driver: bridge

volumes:
  sonarqube_conf:
  sonarqube_data:
  sonarqube_extensions:
  sonarqube_bundled-plugins:
  postgresql:
  postgresql_data:
  jenkins_data:
  postgres-volume: