From ac81d642aac43b459431ba0e81159d590325cf1f Mon Sep 17 00:00:00 2001 From: David Boreham Date: Wed, 3 Aug 2022 20:37:16 -0600 Subject: [PATCH] Initial commit --- docker-compose-test.yaml | 36 ++++++++++++++++++++++ repository-list.txt | 8 +++++ setup-repositories.py | 55 ++++++++++++++++++++++++++++++++++ testcontainers-compose-test.py | 8 +++++ 4 files changed, 107 insertions(+) create mode 100644 docker-compose-test.yaml create mode 100644 repository-list.txt create mode 100644 setup-repositories.py create mode 100644 testcontainers-compose-test.py diff --git a/docker-compose-test.yaml b/docker-compose-test.yaml new file mode 100644 index 0000000..10153ef --- /dev/null +++ b/docker-compose-test.yaml @@ -0,0 +1,36 @@ +version: '3' + +services: + + # Postgresql DB + db: + image: timescale/timescaledb:latest-pg14 + command: -c work_mem=256MB + restart: unless-stopped + environment: + POSTGRES_PASSWORD: db + POSTGRES_USER: db + POSTGRES_DB: db + POSTGRES_HOST_AUTH_METHOD: trust + ports: + # Postgresql + - "5432" + + # Elastic + es: + restart: unless-stopped + image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0 + environment: + - xpack.security.enabled=false + - discovery.type=single-node + ulimits: + memlock: + soft: -1 + hard: -1 + nofile: + soft: 65536 + hard: 65536 + cap_add: + - IPC_LOCK + ports: + - 9200 diff --git a/repository-list.txt b/repository-list.txt new file mode 100644 index 0000000..f37ba48 --- /dev/null +++ b/repository-list.txt @@ -0,0 +1,8 @@ +vulcanize/ops +vulcanize/ipld-eth-db +vulcanize/go-ethereum +vulcanize/ipld-eth-server +vulcanize/eth-statediff-fill-service +vulcanize/ipld-eth-db-validator +vulcanize/ipld-eth-beacon-indexer +vulcanize/ipld-eth-beacon-db diff --git a/setup-repositories.py b/setup-repositories.py new file mode 100644 index 0000000..527d2b4 --- /dev/null +++ b/setup-repositories.py @@ -0,0 +1,55 @@ +# env vars: +# DEV_ROOT defaults to ~/vulcanize + +import os +import argparse +from pydoc import ispackage +from decouple import config +import git + +parser = argparse.ArgumentParser( + description="git clone the set of repositories required to build the complete system from source", + epilog="Config provided either in .env or settings.ini or env vars: DEV_ROOT (defaults to ~/vulcanize)" + ) +parser.add_argument("--verbose", action="store_true", help="increase output verbosity") +parser.add_argument("--quiet", action="store_true", help="don\'t print informational output") +parser.add_argument("--check-only", action="store_true", help="looks at what\'s already there and checks if it looks good") +parser.add_argument("--dry-run", action="store_true", help="don\'t do anything, just print the commands that would be executed") + +args = parser.parse_args() +print(args) + +verbose = args.verbose +quiet = args.quiet + +dev_root_path = config("DEV_ROOT", default="~/vulcanize") + +if not args.quiet: + print(f'Dev Root is: {dev_root_path}') + +with open("repository-list.txt") as repositoryListFile: + repos = repositoryListFile.read().splitlines() + +if verbose: + print (f'Repos: {repos}') + +# Ok, now we can go ahead and look to see which if any of the repos are already cloned + +def processRepo(repo): + full_github_repo_path = f'git@github.com:{repo}' + repoName = repo.split("/")[-1] + fullFilesystemRepoPath = os.path.join(dev_root_path, repoName) + isPresent = os.path.isdir(fullFilesystemRepoPath) + print(f'Checking: {fullFilesystemRepoPath}, exists: {isPresent}') + if not isPresent: + # Clone + if not quiet: + print(f'Running git clone for {full_github_repo_path} into {fullFilesystemRepoPath}') + if not args.check_only: + git.Repo.clone_from(full_github_repo_path, fullFilesystemRepoPath) + else: + print("(git clone skipped)") + + +for repo in repos: + processRepo(repo) diff --git a/testcontainers-compose-test.py b/testcontainers-compose-test.py new file mode 100644 index 0000000..e098cbe --- /dev/null +++ b/testcontainers-compose-test.py @@ -0,0 +1,8 @@ +from testcontainers.compose import DockerCompose +from testcontainers.core.docker_client import DockerClient +from testcontainers.core.exceptions import NoSuchPortExposed +from testcontainers.core.waiting_utils import wait_for_logs + +with DockerCompose(filepath=".", compose_file_name="docker-compose-test.yaml") as compose: + port = compose.get_service_port("db", 5432) + print(port)