From a264ca77175ec648007a588913e3691f5aab7109 Mon Sep 17 00:00:00 2001 From: nabarun Date: Tue, 21 Mar 2023 14:28:41 +0530 Subject: [PATCH] Add web app services to docker compose file --- .../docker-compose-watcher-mobymask-v2.yml | 37 ++++++++++++++++++- .../mobymask-app-config.json | 11 ++++++ .../{config.json => test-app-config.json} | 0 .../cerc-mobymask-ui/Dockerfile | 2 + .../cerc-react-peer/Dockerfile | 4 +- .../cerc-watcher-mobymask-v2/Dockerfile | 2 +- app/data/stacks/mobymask-v2/README.md | 28 ++++++++++++++ app/data/stacks/mobymask-v2/stack.yml | 1 + 8 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 app/data/config/watcher-mobymask-v2/mobymask-app-config.json rename app/data/config/watcher-mobymask-v2/{config.json => test-app-config.json} (100%) diff --git a/app/data/compose/docker-compose-watcher-mobymask-v2.yml b/app/data/compose/docker-compose-watcher-mobymask-v2.yml index 750b4e90..2236d3d3 100644 --- a/app/data/compose/docker-compose-watcher-mobymask-v2.yml +++ b/app/data/compose/docker-compose-watcher-mobymask-v2.yml @@ -37,11 +37,46 @@ services: - "0.0.0.0:9001:9001" - "0.0.0.0:9090:9090" healthcheck: - test: ["CMD", "nc", "-v", "localhost", "9090"] + test: ["CMD", "busybox", "nc", "localhost", "9090"] interval: 20s timeout: 5s retries: 15 start_period: 5s + mobymask-app: + depends_on: + mobymask-watcher-server: + condition: service_healthy + image: cerc/mobymask-ui:local + command: ["sh", "-c", "npm run build && serve -s build"] + volumes: + - ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/config.json + ports: + - "0.0.0.0:3002:3000" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3000"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + + peer-test-app: + depends_on: + mobymask-watcher-server: + condition: service_healthy + image: cerc/react-peer:local + working_dir: /app/packages/test-app + command: ["sh", "-c", "yarn build && serve -s build"] + volumes: + - ../config/watcher-mobymask-v2/test-app-config.json:/app/packages/test-app/src/config.json + ports: + - "0.0.0.0:3003:3000" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3000"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + volumes: mobymask_watcher_db_data: diff --git a/app/data/config/watcher-mobymask-v2/mobymask-app-config.json b/app/data/config/watcher-mobymask-v2/mobymask-app-config.json new file mode 100644 index 00000000..6adabc42 --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/mobymask-app-config.json @@ -0,0 +1,11 @@ +{ + "address": "0xF1Ec16Eedc547A60574EAD530AA120f1e108a9f4", + "name": "MobyMask", + "chainId": 9000, + "relayNodes": [ + "/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t" + ], + "peer": { + "enableDebugInfo": true + } +} diff --git a/app/data/config/watcher-mobymask-v2/config.json b/app/data/config/watcher-mobymask-v2/test-app-config.json similarity index 100% rename from app/data/config/watcher-mobymask-v2/config.json rename to app/data/config/watcher-mobymask-v2/test-app-config.json diff --git a/app/data/container-build/cerc-mobymask-ui/Dockerfile b/app/data/container-build/cerc-mobymask-ui/Dockerfile index 86a056b7..d0557330 100644 --- a/app/data/container-build/cerc-mobymask-ui/Dockerfile +++ b/app/data/container-build/cerc-mobymask-ui/Dockerfile @@ -6,6 +6,8 @@ WORKDIR /app COPY . . +RUN npm install -g serve + RUN echo "Building mobymask-ui" && \ npm install diff --git a/app/data/container-build/cerc-react-peer/Dockerfile b/app/data/container-build/cerc-react-peer/Dockerfile index 2511d623..d035fb44 100644 --- a/app/data/container-build/cerc-react-peer/Dockerfile +++ b/app/data/container-build/cerc-react-peer/Dockerfile @@ -6,7 +6,9 @@ WORKDIR /app COPY . . +RUN yarn global add serve + RUN echo "Building react-peer" && \ - yarn && yarn workspace @cerc-io/react-peer build + yarn && yarn build --ignore @cerc-io/test-app WORKDIR /app diff --git a/app/data/container-build/cerc-watcher-mobymask-v2/Dockerfile b/app/data/container-build/cerc-watcher-mobymask-v2/Dockerfile index 501c8f10..f3184b39 100644 --- a/app/data/container-build/cerc-watcher-mobymask-v2/Dockerfile +++ b/app/data/container-build/cerc-watcher-mobymask-v2/Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update \ && apt-get install -y curl gnupg build-essential \ && curl --silent --location https://deb.nodesource.com/setup_18.x | bash - \ && apt-get update \ - && apt-get install -y nodejs git \ + && apt-get install -y nodejs git busybox \ && node -v RUN corepack enable \ diff --git a/app/data/stacks/mobymask-v2/README.md b/app/data/stacks/mobymask-v2/README.md index 82886783..ece80f09 100644 --- a/app/data/stacks/mobymask-v2/README.md +++ b/app/data/stacks/mobymask-v2/README.md @@ -10,6 +10,14 @@ Clone required repositories: laconic-so --stack mobymask-v2 setup-repositories ``` +Checkout to the required branch in mobymask-ui + +```bash +cd ~/cerc/mobymask-ui + +git checkout laconic +``` + Build the container images: ```bash @@ -52,6 +60,26 @@ Run the peer tests: docker exec -w /app/packages/peer $CONTAINER_ID yarn test ``` +## Web Apps + +Check that the status for web-app containers are healthy by using `docker ps` + +### mobymask-app + +The mobymask-app should be running at http://localhost:3002 + +### peer-test-app + +The peer-test-app should be running at http://localhost:3003 + +## Details + +* The relay node for p2p network is running at http://localhost:9090 + +* The [peer package](https://github.com/cerc-io/watcher-ts/tree/main/packages/peer) (published in [gitea](https://git.vdb.to/cerc-io/-/packages/npm/@cerc-io%2Fpeer)) can be used in client code for connecting to the network + +* The [react-peer package](https://github.com/cerc-io/react-peer/tree/main/packages/react-peer) (published in [gitea](https://git.vdb.to/cerc-io/-/packages/npm/@cerc-io%2Freact-peer)) which uses the peer package can be used in react app for connecting to the network + ## Clean up To stop all the services running in background run: diff --git a/app/data/stacks/mobymask-v2/stack.yml b/app/data/stacks/mobymask-v2/stack.yml index c9b13aa5..ed7b3372 100644 --- a/app/data/stacks/mobymask-v2/stack.yml +++ b/app/data/stacks/mobymask-v2/stack.yml @@ -6,6 +6,7 @@ repos: - cerc-io/mobymask-ui containers: - cerc/watcher-mobymask-v2 + - cerc/react-peer - cerc/mobymask-ui pods: - watcher-mobymask-v2