From 7625939f13156fba13757402c9da26598cac19f6 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 6 Nov 2022 09:40:10 -0700 Subject: [PATCH 1/6] Initial commit --- container-build/cerc-watcher-mobymask/build.sh | 0 container-image-list.txt | 1 + 2 files changed, 1 insertion(+) create mode 100755 container-build/cerc-watcher-mobymask/build.sh diff --git a/container-build/cerc-watcher-mobymask/build.sh b/container-build/cerc-watcher-mobymask/build.sh new file mode 100755 index 0000000..e69de29 diff --git a/container-image-list.txt b/container-image-list.txt index 80cef72..65c1c54 100644 --- a/container-image-list.txt +++ b/container-image-list.txt @@ -12,4 +12,5 @@ cerc/laconicd cerc/laconic-cns-cli cerc/fixturenet-eth-geth cerc/fixturenet-eth-lighthouse +cerc/watcher-mobymask cerc/test-container From f5f262cea3ecf6b41d3b34d3999012d68e97e22b Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 6 Nov 2022 09:49:05 -0700 Subject: [PATCH 2/6] Add repo and compose from repo --- compose/docker-compose-watcher-mobymask.yml | 63 +++++++++++++++++++++ repository-list.txt | 1 + stacks/mobymask/stack.yml | 7 +++ 3 files changed, 71 insertions(+) create mode 100644 compose/docker-compose-watcher-mobymask.yml create mode 100644 stacks/mobymask/stack.yml diff --git a/compose/docker-compose-watcher-mobymask.yml b/compose/docker-compose-watcher-mobymask.yml new file mode 100644 index 0000000..89892b3 --- /dev/null +++ b/compose/docker-compose-watcher-mobymask.yml @@ -0,0 +1,63 @@ +version: '3.2' + +services: + + watcher-db: + restart: unless-stopped + image: postgres:14-alpine + environment: + - POSTGRES_USER=vdbm + - POSTGRES_MULTIPLE_DATABASES=mobymask-watcher,mobymask-watcher-job-queue + - POSTGRES_EXTENSION=mobymask-watcher-job-queue:pgcrypto + - POSTGRES_PASSWORD=password + volumes: + - ../common/initdb.d/multiple-postgressql-databases.sh:/docker-entrypoint-initdb.d/multiple-postgressql-databases.sh + - watcher_db_data:/var/lib/postgresql/data + ports: + - "0.0.0.0:15432:5432" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "5432"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + + mobymask-watcher-server: + restart: unless-stopped + depends_on: + watcher-db: + condition: service_healthy + build: + context: ../common/watcher-ts + command: ["sh", "-c", "yarn server"] + volumes: + - ../common/watcher-ts/mobymask-watcher.toml:/app/packages/mobymask-watcher/environments/local.toml + ports: + - "0.0.0.0:3001:3001" + - "0.0.0.0:9001:9001" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3001"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + + mobymask-watcher-job-runner: + restart: unless-stopped + depends_on: + mobymask-watcher-server: + condition: service_healthy + watcher-db: + condition: service_healthy + build: + context: ../common/watcher-ts + command: ["sh", "-c", "yarn job-runner"] + volumes: + - ../common/watcher-ts/mobymask-watcher.toml:/app/packages/mobymask-watcher/environments/local.toml + ports: + - "0.0.0.0:9000:9000" + +volumes: + indexer_db_data: + watcher_db_data: + \ No newline at end of file diff --git a/repository-list.txt b/repository-list.txt index 01e178a..97dfb41 100644 --- a/repository-list.txt +++ b/repository-list.txt @@ -9,3 +9,4 @@ vulcanize/ipld-eth-beacon-indexer vulcanize/ipld-eth-beacon-db cerc-io/laconicd cerc-io/laconic-cns-cli +cerc-io/mobymask-watcher diff --git a/stacks/mobymask/stack.yml b/stacks/mobymask/stack.yml new file mode 100644 index 0000000..3dd4e79 --- /dev/null +++ b/stacks/mobymask/stack.yml @@ -0,0 +1,7 @@ +name: mobymask-watcher +repos: + - cerc-io/mobymask-watcher +containers: + - cerc/watcher-mobymask +pods: + - watcher-mobymask \ No newline at end of file From 81066905d455534b41f36fe4124e901ac6d6e3a6 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 6 Nov 2022 10:11:42 -0700 Subject: [PATCH 3/6] Add container build --- container-build/cerc-watcher-mobymask/Dockerfile | 8 ++++++++ container-build/cerc-watcher-mobymask/build.sh | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 container-build/cerc-watcher-mobymask/Dockerfile diff --git a/container-build/cerc-watcher-mobymask/Dockerfile b/container-build/cerc-watcher-mobymask/Dockerfile new file mode 100644 index 0000000..fd3e66d --- /dev/null +++ b/container-build/cerc-watcher-mobymask/Dockerfile @@ -0,0 +1,8 @@ +# TODO: move this into the cerc-io/mobymask-watcher repo +FROM node:16.17.1-alpine3.16 + +WORKDIR /app + +COPY . . + +RUN apk --update --no-cache add git && yarn && yarn build diff --git a/container-build/cerc-watcher-mobymask/build.sh b/container-build/cerc-watcher-mobymask/build.sh index e69de29..74782c9 100755 --- a/container-build/cerc-watcher-mobymask/build.sh +++ b/container-build/cerc-watcher-mobymask/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# Build cerc/watcher-mobymask + +# See: https://stackoverflow.com/a/246128/1701505 +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build -t cerc/watcher-mobymask:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/mobymask-watcher From acf3877caa617e233f6c0ffb5537fb0bfe6016a1 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 6 Nov 2022 17:17:48 -0700 Subject: [PATCH 4/6] Working container build --- .../cerc-watcher-mobymask/Dockerfile | 19 +++++++++++++++++-- .../cerc-watcher-mobymask/build.sh | 3 ++- repository-list.txt | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/container-build/cerc-watcher-mobymask/Dockerfile b/container-build/cerc-watcher-mobymask/Dockerfile index fd3e66d..48cf124 100644 --- a/container-build/cerc-watcher-mobymask/Dockerfile +++ b/container-build/cerc-watcher-mobymask/Dockerfile @@ -1,8 +1,23 @@ # TODO: move this into the cerc-io/mobymask-watcher repo FROM node:16.17.1-alpine3.16 +RUN apk --update --no-cache add git python3 alpine-sdk + WORKDIR /app -COPY . . +COPY assemblyscript assemblyscript +COPY watcher-ts watcher-ts -RUN apk --update --no-cache add git && yarn && yarn build +# TODO: needs branch ng-integrate-asyncify +# TODO: why are we mixing npm and yarn below? +RUN echo "Building assemblyscript" && \ + cd assemblyscript && \ + npm install && npm run build && yarn link + +# TODO: needs branch v0.2.13 +RUN echo "Building watcher-ts" && \ + cd watcher-ts/packages/graph-node && yarn remove @vulcanize/assemblyscript && \ + yarn add https://github.com/vulcanize/assemblyscript.git#ng-integrate-asyncify && \ + cd ../../../watcher-ts && yarn && yarn link "@vulcanize/assemblyscript" && yarn build + +WORKDIR /app/watcher-ts/packages/mobymask-watcher diff --git a/container-build/cerc-watcher-mobymask/build.sh b/container-build/cerc-watcher-mobymask/build.sh index 74782c9..a4a97cd 100755 --- a/container-build/cerc-watcher-mobymask/build.sh +++ b/container-build/cerc-watcher-mobymask/build.sh @@ -4,4 +4,5 @@ # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/watcher-mobymask:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/mobymask-watcher +# TODO: add a mechanism to pass two repos into a container rather than the parent directory as below +docker build -t cerc/watcher-mobymask:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR} diff --git a/repository-list.txt b/repository-list.txt index 97dfb41..6bc5970 100644 --- a/repository-list.txt +++ b/repository-list.txt @@ -10,3 +10,5 @@ vulcanize/ipld-eth-beacon-db cerc-io/laconicd cerc-io/laconic-cns-cli cerc-io/mobymask-watcher +cerc-io/watcher-ts +vulcanize/assemblyscript From c5895bed0ddd5cda413f6cd0ace8c91666e1ac4e Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 6 Nov 2022 17:45:32 -0700 Subject: [PATCH 5/6] Fix up compose file --- compose/docker-compose-watcher-mobymask.yml | 6 ++---- stacks/mobymask/stack.yml | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/compose/docker-compose-watcher-mobymask.yml b/compose/docker-compose-watcher-mobymask.yml index 89892b3..38ea0cc 100644 --- a/compose/docker-compose-watcher-mobymask.yml +++ b/compose/docker-compose-watcher-mobymask.yml @@ -27,8 +27,7 @@ services: depends_on: watcher-db: condition: service_healthy - build: - context: ../common/watcher-ts + image: cerc/watcher-mobymask:local command: ["sh", "-c", "yarn server"] volumes: - ../common/watcher-ts/mobymask-watcher.toml:/app/packages/mobymask-watcher/environments/local.toml @@ -49,8 +48,7 @@ services: condition: service_healthy watcher-db: condition: service_healthy - build: - context: ../common/watcher-ts + image: cerc/watcher-mobymask:local command: ["sh", "-c", "yarn job-runner"] volumes: - ../common/watcher-ts/mobymask-watcher.toml:/app/packages/mobymask-watcher/environments/local.toml diff --git a/stacks/mobymask/stack.yml b/stacks/mobymask/stack.yml index 3dd4e79..c7b4eea 100644 --- a/stacks/mobymask/stack.yml +++ b/stacks/mobymask/stack.yml @@ -1,6 +1,7 @@ name: mobymask-watcher repos: - - cerc-io/mobymask-watcher + - cerc-io/watcher-ts/v0.2.13 + - vulcanize/assemblyscript/ng-integrate-asyncify containers: - cerc/watcher-mobymask pods: From e6859c03ad8514c891e60dde4e0049ff0dda954e Mon Sep 17 00:00:00 2001 From: David Boreham Date: Mon, 7 Nov 2022 20:23:52 -0700 Subject: [PATCH 6/6] Fix build for yarn insanity --- .../cerc-watcher-mobymask/Dockerfile | 12 ++++++++---- stacks/mobymask/README.md | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/container-build/cerc-watcher-mobymask/Dockerfile b/container-build/cerc-watcher-mobymask/Dockerfile index 48cf124..b27c6f9 100644 --- a/container-build/cerc-watcher-mobymask/Dockerfile +++ b/container-build/cerc-watcher-mobymask/Dockerfile @@ -9,15 +9,19 @@ COPY assemblyscript assemblyscript COPY watcher-ts watcher-ts # TODO: needs branch ng-integrate-asyncify -# TODO: why are we mixing npm and yarn below? +# We use a mixture of npm and yarn below because the upstream +# project checked in an npm package-log.json file RUN echo "Building assemblyscript" && \ cd assemblyscript && \ npm install && npm run build && yarn link # TODO: needs branch v0.2.13 -RUN echo "Building watcher-ts" && \ +# The shenanigans below is due to yarn and lerna being a dumpster-fire +RUN echo "Linking watcher-ts to local assemblyscript" && \ cd watcher-ts/packages/graph-node && yarn remove @vulcanize/assemblyscript && \ - yarn add https://github.com/vulcanize/assemblyscript.git#ng-integrate-asyncify && \ - cd ../../../watcher-ts && yarn && yarn link "@vulcanize/assemblyscript" && yarn build + yarn add https://github.com/vulcanize/assemblyscript.git#ng-integrate-asyncify + +RUN echo "Building watcher-tst" && \ + cd watcher-ts && yarn && yarn link "@vulcanize/assemblyscript" && yarn build WORKDIR /app/watcher-ts/packages/mobymask-watcher diff --git a/stacks/mobymask/README.md b/stacks/mobymask/README.md index 542064d..b3263d8 100644 --- a/stacks/mobymask/README.md +++ b/stacks/mobymask/README.md @@ -2,3 +2,22 @@ ## Set up a Mobymask Watcher +## Clone required repositories +``` +$ laconic-so setup-repositories +``` +Checkout required branches: +``` +$ cd ~/cerc/assemblyscript +$ git checkout ng-integrate-asyncify +$ cd ~/cerc/watcher-ts +$ git checkout v0.2.13 +``` +## Build the watcher container +``` +$ laconic-sh build-containers --include cerc/watcher-mobymask +``` +## Deploy the stack +``` +$ laconic-sh deploy-system --include watcher-mobymask +``` \ No newline at end of file