From 35dd30f877fcf5fed5b8c5571a88780cfb9324f4 Mon Sep 17 00:00:00 2001 From: Nabarun Gogoi Date: Thu, 20 Apr 2023 10:49:19 +0530 Subject: [PATCH] Add container to mobymask-v2 stack for LXDAO mobymask-app (#347) * Add container to stack for lxdao mobymask-app * Remove shm_size * Use cerc-io scoped alias for lxdao app package * Change alias to @cerc-io/mobymask-ui-lxdao Former-commit-id: 46b36c3cb6e9b4cbbaf908052d49e498f6397f33 --- .../compose/docker-compose-mobymask-app.yml | 40 ++++++++++++++++++- .../cerc-mobymask-ui/Dockerfile | 9 +++-- .../cerc-mobymask-ui/start-serving-app.sh | 2 +- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/app/data/compose/docker-compose-mobymask-app.yml b/app/data/compose/docker-compose-mobymask-app.yml index 6df48130..f2b30a4b 100644 --- a/app/data/compose/docker-compose-mobymask-app.yml +++ b/app/data/compose/docker-compose-mobymask-app.yml @@ -13,6 +13,7 @@ services: CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT} CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL} CERC_RELAY_NODES: ${CERC_RELAY_NODES} + CERC_BUILD_DIR: "@cerc-io/mobymask-ui/build" working_dir: /scripts # Waits for watcher server to be up before app build # Required when running with watcher stack to get deployed contract address @@ -28,12 +29,47 @@ services: ports: - "0.0.0.0:3002:80" healthcheck: - test: ["CMD", "nc", "-v", "localhost", "80"] + test: ["CMD", "nc", "-vz", "localhost", "80"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + extra_hosts: + - "host.docker.internal:host-gateway" + + # Builds and serves the LXDAO version of MobyMask react-app + lxdao-mobymask-app: + restart: unless-stopped + image: cerc/mobymask-ui:local + env_file: + - ../config/watcher-mobymask-v2/mobymask-params.env + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_CHAIN_ID: ${CERC_CHAIN_ID} + CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT} + CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL} + CERC_RELAY_NODES: ${CERC_RELAY_NODES} + CERC_BUILD_DIR: "@cerc-io/mobymask-ui-lxdao/build" + working_dir: /scripts + # Waits for watcher server to be up before app build + # Required when running with watcher stack to get deployed contract address + command: + - sh + - -c + - ./wait-for-it.sh -h ${CERC_WATCHER_HOST:-$${DEFAULT_CERC_WATCHER_HOST}} -p ${CERC_WATCHER_PORT:-$${DEFAULT_CERC_WATCHER_PORT}} -s -t 0 -- ./mobymask-app-start.sh + volumes: + - ../config/wait-for-it.sh:/scripts/wait-for-it.sh + - ../config/watcher-mobymask-v2/mobymask-app-start.sh:/scripts/mobymask-app-start.sh + - peers_ids:/peers + - mobymask_deployment:/server + ports: + - "0.0.0.0:3004:80" + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "80"] interval: 20s timeout: 5s retries: 15 start_period: 10s - shm_size: '1GB' extra_hosts: - "host.docker.internal:host-gateway" diff --git a/app/data/container-build/cerc-mobymask-ui/Dockerfile b/app/data/container-build/cerc-mobymask-ui/Dockerfile index 3f04ec45..4ff202bc 100644 --- a/app/data/container-build/cerc-mobymask-ui/Dockerfile +++ b/app/data/container-build/cerc-mobymask-ui/Dockerfile @@ -31,7 +31,7 @@ RUN \ # Install additional OS packages. RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends jq bash + && apt-get -y install --no-install-recommends jq bash netcat # We do this to get a yq binary from the published container, for the correct architecture we're building here COPY --from=docker.io/mikefarah/yq:latest /usr/bin/yq /usr/local/bin/yq @@ -48,8 +48,11 @@ RUN mkdir -p /config # Install simple web server for now (use nginx perhaps later) RUN yarn global add http-server -# Globally install the payload web app package -RUN yarn global add @cerc-io/mobymask-ui +# Globally install both versions of the payload web app package +# Install old version of MobyMask web app +RUN yarn global add @cerc-io/mobymask-ui@0.1.2 +# Install the LXDAO version of MobyMask web app +RUN yarn global add @cerc-io/mobymask-ui-lxdao@npm:@cerc-io/mobymask-ui@0.1.2-lxdao-0.1.0 # Expose port for http EXPOSE 80 diff --git a/app/data/container-build/cerc-mobymask-ui/start-serving-app.sh b/app/data/container-build/cerc-mobymask-ui/start-serving-app.sh index 4e0a976c..0e11b447 100755 --- a/app/data/container-build/cerc-mobymask-ui/start-serving-app.sh +++ b/app/data/container-build/cerc-mobymask-ui/start-serving-app.sh @@ -4,6 +4,6 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then fi # TODO: Don't hard wire this: -webapp_files_dir=/usr/local/share/.config/yarn/global/node_modules/@cerc-io/mobymask-ui/build +webapp_files_dir="/usr/local/share/.config/yarn/global/node_modules/${CERC_BUILD_DIR}" /scripts/apply-webapp-config.sh /config/config.yml ${webapp_files_dir} MOBYMASK_HOSTED_CONFIG http-server -p 80 ${webapp_files_dir}