From 156e3611a0191f320ffc8f752bf20de3f2e3e049 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 30 Nov 2023 10:40:45 +0530 Subject: [PATCH] Add a service for uniswap app deployment to urbit --- .../compose/docker-compose-uniswap-interface.yml | 15 +++++++++++++++ .../data/compose/docker-compose-urbit.yml | 6 ++++-- .../data/config/uniswap-frontend/build.sh | 6 +++--- .../config/uniswap-frontend/deploy-to-urbit.sh | 14 ++++++++++++++ .../cerc-uniswap-urbit-deployment/Dockerfile | 7 +++++++ .../cerc-uniswap-urbit-deployment/build.sh | 9 +++++++++ .../data/stacks/uniswap-frontend/README.md | 1 + .../data/stacks/uniswap-frontend/stack.yml | 1 + 8 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 stack_orchestrator/data/config/uniswap-frontend/deploy-to-urbit.sh create mode 100644 stack_orchestrator/data/container-build/cerc-uniswap-urbit-deployment/Dockerfile create mode 100755 stack_orchestrator/data/container-build/cerc-uniswap-urbit-deployment/build.sh diff --git a/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml b/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml index 4df1a89c..77c22c7f 100644 --- a/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml +++ b/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml @@ -19,5 +19,20 @@ services: retries: 15 start_period: 5s + uniswap-urbit-deployment: + image: cerc/uniswap-urbit-deployment:local + restart: unless-stopped + depends_on: + uniswap-interface: + condition: service_completed_successfully + # environment: + # - REACT_APP_INFURA_KEY=${CERC_INFURA_KEY} + command: ["./deploy-to-urbit.sh"] + volumes: + - uniswap_build:/app/build + - pier_data: /app/pier + - ../config/uniswap-frontend/deploy-to-urbit.sh:/app/deploy-to-urbit.sh + volumes: uniswap_build: + pier_data: diff --git a/stack_orchestrator/data/compose/docker-compose-urbit.yml b/stack_orchestrator/data/compose/docker-compose-urbit.yml index 8e4a9f1c..aee61a9e 100644 --- a/stack_orchestrator/data/compose/docker-compose-urbit.yml +++ b/stack_orchestrator/data/compose/docker-compose-urbit.yml @@ -5,6 +5,8 @@ services: restart: unless-stopped image: tloncorp/vere entrypoint: ["bash", "-c", "urbit -t -F zod"] + volumes: + - pier_data:/urbit/zod/ ports: - "8080:80" - "12321:12321" @@ -15,5 +17,5 @@ services: retries: 15 start_period: 10s -# volumes: - # pier: +volumes: + pier_data: diff --git a/stack_orchestrator/data/config/uniswap-frontend/build.sh b/stack_orchestrator/data/config/uniswap-frontend/build.sh index a258ab54..16c517ea 100755 --- a/stack_orchestrator/data/config/uniswap-frontend/build.sh +++ b/stack_orchestrator/data/config/uniswap-frontend/build.sh @@ -8,7 +8,7 @@ fi yarn build # Create symlink to host built files with correct URL path -mkdir -p /app/urbit/apps -ln -s /app/build /app/urbit/apps/uniswap +# mkdir -p /app/urbit/apps +# ln -s /app/build /app/urbit/apps/uniswap -node_modules/.bin/serve urbit -s -l 3000 +# node_modules/.bin/serve urbit -s -l 3000 diff --git a/stack_orchestrator/data/config/uniswap-frontend/deploy-to-urbit.sh b/stack_orchestrator/data/config/uniswap-frontend/deploy-to-urbit.sh new file mode 100644 index 00000000..56ab2445 --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-frontend/deploy-to-urbit.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +tail -f /dev/null + +# TODO: +# Take urbit endpoint from env +# Check if urbit endpoint is up +# Fire curl requests to create/mount a uniswap desk +# Copy over build to desk data dir diff --git a/stack_orchestrator/data/container-build/cerc-uniswap-urbit-deployment/Dockerfile b/stack_orchestrator/data/container-build/cerc-uniswap-urbit-deployment/Dockerfile new file mode 100644 index 00000000..7a3ca9b7 --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-uniswap-urbit-deployment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.13.0a2-alpine3.18 + +RUN apk --update --no-cache add alpine-sdk jq bash curl wget + +WORKDIR /app + +ENTRYPOINT [ "bash" ] diff --git a/stack_orchestrator/data/container-build/cerc-uniswap-urbit-deployment/build.sh b/stack_orchestrator/data/container-build/cerc-uniswap-urbit-deployment/build.sh new file mode 100755 index 00000000..65192d95 --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-uniswap-urbit-deployment/build.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Build the uniswap-urbit-deployment image + +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + +# See: https://stackoverflow.com/a/246128/1701505 +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build -t cerc/uniswap-urbit-deployment:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} diff --git a/stack_orchestrator/data/stacks/uniswap-frontend/README.md b/stack_orchestrator/data/stacks/uniswap-frontend/README.md index a4508a66..17a91886 100644 --- a/stack_orchestrator/data/stacks/uniswap-frontend/README.md +++ b/stack_orchestrator/data/stacks/uniswap-frontend/README.md @@ -26,6 +26,7 @@ laconic-so --stack uniswap-frontend build-containers ## Create a deployment First, create a spec file for the deployment, which will map the stack's ports and volumes to the host: + ```bash laconic-so --stack uniswap-frontend deploy init --output uniswap-frontend-spec.yml ``` diff --git a/stack_orchestrator/data/stacks/uniswap-frontend/stack.yml b/stack_orchestrator/data/stacks/uniswap-frontend/stack.yml index 476fd3b3..061d52a6 100644 --- a/stack_orchestrator/data/stacks/uniswap-frontend/stack.yml +++ b/stack_orchestrator/data/stacks/uniswap-frontend/stack.yml @@ -6,6 +6,7 @@ repos: - github.com/cerc-io/uniswap-interface@pm-urbit-hosting containers: - cerc/uniswap-interface + - cerc/uniswap-urbit-deployment # TODO: Add container for urbit pods: - uniswap-interface