From 5a31d03fb0037e93171261b35ca2f258e8b0c3ae Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 5 Dec 2023 18:52:08 +0530 Subject: [PATCH] Use proxy server from watcher-ts --- proxy-server-deployment/stack.yml | 8 ++ .../compose/docker-compose-proxy-server.yml | 19 +++++ .../docker-compose-uniswap-gql-proxy.yml | 15 ---- .../data/stacks/proxy-server/README.md | 74 +++++++++++++++++++ .../data/stacks/proxy-server/stack.yml | 8 ++ .../data/stacks/uniswap-gql-proxy/README.md | 64 ---------------- .../data/stacks/uniswap-gql-proxy/stack.yml | 8 -- .../data/stacks/uniswap-urbit-app/stack.yml | 2 +- 8 files changed, 110 insertions(+), 88 deletions(-) create mode 100644 proxy-server-deployment/stack.yml create mode 100644 stack_orchestrator/data/compose/docker-compose-proxy-server.yml delete mode 100644 stack_orchestrator/data/compose/docker-compose-uniswap-gql-proxy.yml create mode 100644 stack_orchestrator/data/stacks/proxy-server/README.md create mode 100644 stack_orchestrator/data/stacks/proxy-server/stack.yml delete mode 100644 stack_orchestrator/data/stacks/uniswap-gql-proxy/README.md delete mode 100644 stack_orchestrator/data/stacks/uniswap-gql-proxy/stack.yml diff --git a/proxy-server-deployment/stack.yml b/proxy-server-deployment/stack.yml new file mode 100644 index 00000000..313a7f91 --- /dev/null +++ b/proxy-server-deployment/stack.yml @@ -0,0 +1,8 @@ +version: "0.1" +name: proxy-server +repos: + - github.com/cerc-io/watcher-ts@v0.2.78 +containers: + - cerc/watcher-ts +pods: + - proxy-server diff --git a/stack_orchestrator/data/compose/docker-compose-proxy-server.yml b/stack_orchestrator/data/compose/docker-compose-proxy-server.yml new file mode 100644 index 00000000..370d6b7e --- /dev/null +++ b/stack_orchestrator/data/compose/docker-compose-proxy-server.yml @@ -0,0 +1,19 @@ +version: "3.2" + +services: + proxy-server: + image: cerc/watcher-ts:local + restart: unless-stopped + working_dir: /app/packages/cli + environment: + PROXY_UPSTREAM: ${CERC_PROXY_UPSTREAM} + PROXY_ORIGIN_HEADER: ${CERC_PROXY_ORIGIN_HEADER} + command: ["sh", "-c", "yarn proxy"] + ports: + - "4000" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "4000"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s diff --git a/stack_orchestrator/data/compose/docker-compose-uniswap-gql-proxy.yml b/stack_orchestrator/data/compose/docker-compose-uniswap-gql-proxy.yml deleted file mode 100644 index 65e79a47..00000000 --- a/stack_orchestrator/data/compose/docker-compose-uniswap-gql-proxy.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: "3.2" - -services: - uniswap-gql-proxy: - image: cerc/uniswap-interface:local - restart: on-failure - command: ["bash", "-c", "yarn proxy-gql"] - ports: - - "4000" - healthcheck: - test: ["CMD", "nc", "-v", "localhost", "4000"] - interval: 20s - timeout: 5s - retries: 15 - start_period: 10s diff --git a/stack_orchestrator/data/stacks/proxy-server/README.md b/stack_orchestrator/data/stacks/proxy-server/README.md new file mode 100644 index 00000000..f3efbbdc --- /dev/null +++ b/stack_orchestrator/data/stacks/proxy-server/README.md @@ -0,0 +1,74 @@ +# Proxy Server + +Instructions to setup and deploy a HTTP proxy server + +## Setup + +Clone required repository: + +```bash +laconic-so --stack proxy-server setup-repositories --pull + +# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command +``` + +Build the container image: + +```bash +laconic-so --stack proxy-server build-containers +``` + +## Create a deployment + +* First, create a spec file for the deployment, which will allow mapping the stack's ports and volumes to the host: + + ```bash + laconic-so --stack proxy-server deploy init --output proxy-server-spec.yml + ``` + +* Edit `network` in spec file to map container ports to same ports in host: + + ```yml + ... + network: + ports: + proxy-server: + - '4000:4000' + ... + ``` + +* Once you've made any needed changes to the spec file, create a deployment from it: + + ```bash + laconic-so --stack proxy-server deploy create --spec-file proxy-server-spec.yml --deployment-dir proxy-server-deployment + ``` + +* Inside the deployment directory, open the file `config.env` and set the following env variables: + + ```bash + # Upstream endpoint + CERC_PROXY_UPSTREAM= + + # Origin header to be used (Optional) + CERC_PROXY_ORIGIN_HEADER= + ``` + +## Start the stack + +Start the deployment: + +```bash +laconic-so deployment --dir proxy-server-deployment start +``` + +* List and check the health status of the container using `docker ps` + +* The proxy server will now be listening at http://localhost:4000 + +## Clean up + +To stop the service running in background: + +```bash +laconic-so deployment --dir proxy-server-deployment stop +``` diff --git a/stack_orchestrator/data/stacks/proxy-server/stack.yml b/stack_orchestrator/data/stacks/proxy-server/stack.yml new file mode 100644 index 00000000..313a7f91 --- /dev/null +++ b/stack_orchestrator/data/stacks/proxy-server/stack.yml @@ -0,0 +1,8 @@ +version: "0.1" +name: proxy-server +repos: + - github.com/cerc-io/watcher-ts@v0.2.78 +containers: + - cerc/watcher-ts +pods: + - proxy-server diff --git a/stack_orchestrator/data/stacks/uniswap-gql-proxy/README.md b/stack_orchestrator/data/stacks/uniswap-gql-proxy/README.md deleted file mode 100644 index 93e74a70..00000000 --- a/stack_orchestrator/data/stacks/uniswap-gql-proxy/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# Uniswap GQL Proxy - -Instructions to setup and deploy a Uniswap GQL proxy server - -## Setup - -Clone required repository: - -```bash -laconic-so --stack uniswap-gql-proxy setup-repositories --pull - -# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command -``` - -Build the container image: - -```bash -laconic-so --stack uniswap-gql-proxy build-containers -``` - -## Create a deployment - -First, create a spec file for the deployment, which will allow mapping the stack's ports and volumes to the host: - -```bash -laconic-so --stack uniswap-gql-proxy deploy init --output uniswap-gql-proxy-spec.yml -``` - -Edit `network` in spec file to map container ports to same ports in host: - -``` -... -network: - ports: - uniswap-gql-proxy: - - '4000:4000' -... -``` - -Once you've made any needed changes to the spec file, create a deployment from it: - -```bash -laconic-so --stack uniswap-gql-proxy deploy create --spec-file uniswap-gql-proxy-spec.yml --deployment-dir uniswap-gql-proxy-deployment -``` - -## Start the stack - -Start the deployment: - -```bash -laconic-so deployment --dir uniswap-gql-proxy-deployment start -``` - -* List and check the health status of the container using `docker ps` - -* The Uniswap GQL server will now be listening at http://localhost:4000 - -## Clean up - -To stop the service running in background: - -```bash -laconic-so deployment --dir uniswap-gql-proxy-deployment stop -``` diff --git a/stack_orchestrator/data/stacks/uniswap-gql-proxy/stack.yml b/stack_orchestrator/data/stacks/uniswap-gql-proxy/stack.yml deleted file mode 100644 index dee96df5..00000000 --- a/stack_orchestrator/data/stacks/uniswap-gql-proxy/stack.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: "0.1" -name: uniswap-gql-proxy -repos: - - github.com/cerc-io/uniswap-interface@laconic # TODO: Use release -containers: - - cerc/uniswap-interface -pods: - - uniswap-gql-proxy diff --git a/stack_orchestrator/data/stacks/uniswap-urbit-app/stack.yml b/stack_orchestrator/data/stacks/uniswap-urbit-app/stack.yml index 13e8bc4f..5339e574 100644 --- a/stack_orchestrator/data/stacks/uniswap-urbit-app/stack.yml +++ b/stack_orchestrator/data/stacks/uniswap-urbit-app/stack.yml @@ -7,5 +7,5 @@ containers: - cerc/urbit-globs-host pods: - uniswap-interface - - uniswap-gql-proxy + - proxy-server - uniswap-urbit