diff --git a/docker-compose/docker-compose.yaml b/docker-compose/docker-compose.yaml index 7239e7d6..77c7634b 100644 --- a/docker-compose/docker-compose.yaml +++ b/docker-compose/docker-compose.yaml @@ -1,3 +1,4 @@ +# This is an autogenerated file. Do not edit it manually. Use `python generate-config.py` instead. --- version: "3.7" services: @@ -204,46 +205,6 @@ services: - mariadb - crossbar - # master-libvirt: - # image: quay.io/mariadb-foundation/bb-master:master - # restart: unless-stopped - # container_name: master-libvirt - # volumes: - # - ./logs:/var/log/buildbot - # - ./buildbot/:/srv/buildbot/master - # entrypoint: - # - /bin/bash - # - -c - # - "/srv/buildbot/master/docker-compose/start.sh master-libvirt" - # networks: - # net_front: - # net_back: - # ports: - # - "127.0.0.1:8019:8019" - # depends_on: - # - mariadb - # - crossbar - - # master-nonlatent: - # image: quay.io/mariadb-foundation/bb-master:master - # restart: unless-stopped - # container_name: master-nonlatent - # volumes: - # - ./logs:/var/log/buildbot - # - ./buildbot/:/srv/buildbot/master - # entrypoint: - # - /bin/bash - # - -c - # - "/srv/buildbot/master/docker-compose/start.sh master-nonlatent" - # networks: - # net_front: - # net_back: - # ports: - # - "127.0.0.1:8020:8020" - # depends_on: - # - mariadb - # - crossbar - master-protected-branches: image: quay.io/mariadb-foundation/bb-master:master restart: unless-stopped @@ -259,7 +220,7 @@ services: net_front: net_back: ports: - - "127.0.0.1:8021:8021" + - "127.0.0.1:8019:8019" depends_on: - mariadb - crossbar diff --git a/docker-compose/generate-config.py b/docker-compose/generate-config.py index d1005966..f77f21ed 100755 --- a/docker-compose/generate-config.py +++ b/docker-compose/generate-config.py @@ -1,9 +1,5 @@ #!/usr/bin/env python3 -# TODO vlad: -# - generate directly into docker-compose.yaml file -# - generate only 1 blank lines between block (not 2) - master_directories = [ "autogen/aarch64-master-0", "autogen/amd64-master-0", @@ -13,11 +9,60 @@ "autogen/x86-master-0", "master-docker-nonstandard", "master-galera", - "master-libvirt", - "master-nonlatent", +# TODO Enable these once it's more clear what needs to be done +# "master-libvirt", +# "master-nonlatent", "master-protected-branches", ] +start_template = """ +--- +version: "3.7" +services: + mariadb: + image: mariadb:10.6 + restart: unless-stopped + container_name: mariadb + environment: + - MARIADB_ROOT_PASSWORD=password + - MARIADB_DATABASE=buildbot + - MARIADB_USER=buildmaster + - MARIADB_PASSWORD=password + networks: + net_back: + healthcheck: + test: ['CMD', "mariadb-admin", "--password=password", "--protocol", "tcp", "ping"] + volumes: + - ./db:/docker-entrypoint-initdb.d:ro + - ./mariadb:/var/lib/mysql:rw + # command: --tmpdir=/var/lib/mysql/tmp + + crossbar: + image: crossbario/crossbar + restart: unless-stopped + container_name: crossbar + networks: + net_back: + + master-web: + image: quay.io/mariadb-foundation/bb-master:master-web + restart: unless-stopped + container_name: master-web + volumes: + - ./logs:/var/log/buildbot + - ./buildbot/:/srv/buildbot/master + entrypoint: + - /srv/buildbot/master/docker-compose/start-bbm-web.sh + networks: + net_front: + net_back: + ports: + - "127.0.0.1:8010:8010" + depends_on: + - mariadb + - crossbar +""" + docker_compose_template = """ {master_name}: image: quay.io/mariadb-foundation/bb-master:master @@ -40,16 +85,44 @@ - crossbar """ +end_template = """ +networks: + net_front: + driver: bridge + ipam: + driver: default + config: + - subnet: 172.200.0.0/24 + driver_opts: + com.docker.network.enable_ipv6: "false" + com.docker.network.bridge.name: "br_bb_front" + net_back: + driver: bridge + internal: true + ipam: + driver: default + config: + - subnet: 172.16.201.0/24 + driver_opts: + com.docker.network.enable_ipv6: "false" + com.docker.network.bridge.name: "br_bb_back" +""" + # Generate startup scripts and Docker Compose pieces for each master directory -port = 8011 -for master_directory in master_directories: - master_name = master_directory.replace("/", "_") - - # Generate Docker Compose piece - docker_compose_piece = docker_compose_template.format( - master_name=master_name, - master_directory=master_directory, - port=port, - ) - port += 1 - print(docker_compose_piece) +with open("docker-compose.yaml", "w") as f: + f.write("# This is an autogenerated file. Do not edit it manually. Use `python generate-config.py` instead.") + f.write(start_template) + port = 8011 + for master_directory in master_directories: + master_name = master_directory.replace("/", "_") + + # Generate Docker Compose piece + docker_compose_piece = docker_compose_template.format( + master_name=master_name, + master_directory=master_directory, + port=port, + ) + port += 1 + + f.write(docker_compose_piece) + f.write(end_template)