From 41437647b035562baca49442d736474c01e7f443 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Fri, 25 Oct 2024 12:21:19 +0530 Subject: [PATCH 1/3] Create stack for laconic shopify --- .../docker-compose-laconic-shopify.yml | 20 +++++++++++++++++++ .../laconic-shopify/product_pricings.json | 6 ++++++ .../config/laconic-shopify/start-shopify.sh | 19 ++++++++++++++++++ .../cerc-laconic-shopify/Dockerfile | 9 +++++++++ .../cerc-laconic-shopify/build.sh | 5 +++++ .../stacks/laconic-shopify/README.md | 1 + .../stacks/laconic-shopify/stack.yml | 9 +++++++++ 7 files changed, 69 insertions(+) create mode 100644 stack-orchestrator/compose/docker-compose-laconic-shopify.yml create mode 100644 stack-orchestrator/config/laconic-shopify/product_pricings.json create mode 100755 stack-orchestrator/config/laconic-shopify/start-shopify.sh create mode 100644 stack-orchestrator/container-build/cerc-laconic-shopify/Dockerfile create mode 100755 stack-orchestrator/container-build/cerc-laconic-shopify/build.sh create mode 100644 stack-orchestrator/stacks/laconic-shopify/README.md create mode 100644 stack-orchestrator/stacks/laconic-shopify/stack.yml diff --git a/stack-orchestrator/compose/docker-compose-laconic-shopify.yml b/stack-orchestrator/compose/docker-compose-laconic-shopify.yml new file mode 100644 index 0000000..a832c60 --- /dev/null +++ b/stack-orchestrator/compose/docker-compose-laconic-shopify.yml @@ -0,0 +1,20 @@ +services: + shopify: + restart: unless-stopped + image: cerc/laconic-shopify:local + command: ["bash", "-c", "./start-faucet.sh"] + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_SHOPIFY_SHOP_NAME: ${CERC_SHOPIFY_SHOP_NAME} + CERC_SHOPIFY_ACCESS_TOKEN: ${CERC_SHOPIFY_ACCESS_TOKEN} + CERC_FETCH_ORDER_DELAY: ${CERC_FETCH_ORDER_DELAY} + CERC_FAUCET_URL: ${CERC_FAUCET_URL} + volumes: + - shopify-data:/app/data + - ../config/laconic-shopify/start-shopify.sh:/app/start-faucet.sh + - ../config/laconic-shopify/product_pricings.json:/app/config/product_pricings.json + extra_hosts: + - "host.docker.internal:host-gateway" + +volumes: + shopify-data: \ No newline at end of file diff --git a/stack-orchestrator/config/laconic-shopify/product_pricings.json b/stack-orchestrator/config/laconic-shopify/product_pricings.json new file mode 100644 index 0000000..75c4073 --- /dev/null +++ b/stack-orchestrator/config/laconic-shopify/product_pricings.json @@ -0,0 +1,6 @@ +{ + "10 webapp deployments": "100000", + "100 webapp deployments": "1000000", + "500 webapp deployments": "5000000", + "1000 webapp deployments": "10000000" +} \ No newline at end of file diff --git a/stack-orchestrator/config/laconic-shopify/start-shopify.sh b/stack-orchestrator/config/laconic-shopify/start-shopify.sh new file mode 100755 index 0000000..b25c3cb --- /dev/null +++ b/stack-orchestrator/config/laconic-shopify/start-shopify.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e +set -u +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +echo "Shopify shop name: $CERC_SHOPIFY_SHOP_NAME" +echo "Shopify access token: $CERC_SHOPIFY_ACCESS_TOKEN" +echo "Fetch order delay: $CERC_FETCH_ORDER_DELAY" +echo "Faucet URL: $CERC_FAUCET_URL" + +export SHOPIFY_SHOP_NAME=$CERC_SHOPIFY_SHOP_NAME +export SHOPIFY_ACCESS_TOKEN=$CERC_SHOPIFY_ACCESS_TOKEN +export FETCH_ORDER_DELAY=$CERC_FETCH_ORDER_DELAY +export FAUCET_URL=$CERC_FAUCET_URL + +yarn start \ No newline at end of file diff --git a/stack-orchestrator/container-build/cerc-laconic-shopify/Dockerfile b/stack-orchestrator/container-build/cerc-laconic-shopify/Dockerfile new file mode 100644 index 0000000..97c6636 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-laconic-shopify/Dockerfile @@ -0,0 +1,9 @@ +FROM node:20-bullseye + +WORKDIR /app + +COPY . . + +RUN yarn install + +CMD ["yarn", "start"] diff --git a/stack-orchestrator/container-build/cerc-laconic-shopify/build.sh b/stack-orchestrator/container-build/cerc-laconic-shopify/build.sh new file mode 100755 index 0000000..c383f4b --- /dev/null +++ b/stack-orchestrator/container-build/cerc-laconic-shopify/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Build cerc/laconic-faucet +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/laconic-shopify:local ${build_command_args} ${CERC_REPO_BASE_DIR}/laconic-shopify diff --git a/stack-orchestrator/stacks/laconic-shopify/README.md b/stack-orchestrator/stacks/laconic-shopify/README.md new file mode 100644 index 0000000..7727887 --- /dev/null +++ b/stack-orchestrator/stacks/laconic-shopify/README.md @@ -0,0 +1 @@ +# laconic-shopify diff --git a/stack-orchestrator/stacks/laconic-shopify/stack.yml b/stack-orchestrator/stacks/laconic-shopify/stack.yml new file mode 100644 index 0000000..3b5fcbf --- /dev/null +++ b/stack-orchestrator/stacks/laconic-shopify/stack.yml @@ -0,0 +1,9 @@ +version: "1.0" +name: laconic-shopify +description: "Service that integrates a Shopify app with the Laconic wallet." +repos: + - git.vdb.to/cerc-io/laconic-shopify +containers: + - cerc/laconic-shopify +pods: + - laconic-shopify -- 2.45.2 From b1d8dfa04182165f23f4038027004ad910777235 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Fri, 25 Oct 2024 15:02:20 +0530 Subject: [PATCH 2/3] Update README for shopify stack --- .../cerc-laconic-shopify/build.sh | 5 +- .../stacks/laconic-shopify/README.md | 93 +++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/stack-orchestrator/container-build/cerc-laconic-shopify/build.sh b/stack-orchestrator/container-build/cerc-laconic-shopify/build.sh index c383f4b..a7156f7 100755 --- a/stack-orchestrator/container-build/cerc-laconic-shopify/build.sh +++ b/stack-orchestrator/container-build/cerc-laconic-shopify/build.sh @@ -2,4 +2,7 @@ # Build cerc/laconic-faucet source ${CERC_CONTAINER_BASE_DIR}/build-base.sh -docker build -t cerc/laconic-shopify:local ${build_command_args} ${CERC_REPO_BASE_DIR}/laconic-shopify + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build -t cerc/laconic-shopify:local ${build_command_args} -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/laconic-shopify diff --git a/stack-orchestrator/stacks/laconic-shopify/README.md b/stack-orchestrator/stacks/laconic-shopify/README.md index 7727887..6bf8554 100644 --- a/stack-orchestrator/stacks/laconic-shopify/README.md +++ b/stack-orchestrator/stacks/laconic-shopify/README.md @@ -1 +1,94 @@ # laconic-shopify + +Instructions for running the laconic shopify + +## Setup + +* Clone the stack repo: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/testnet-laconicd-stack + ``` + +* Clone the laconic-shopify respository: + + ```bash + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify setup-repositories + ``` + +* Build the container image: + + ```bash + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify build-containers + ``` + + This should create the `cerc/laconic-shopify-faucet` image locally + +## Create a deployment + +* Create a spec file for the deployment: + + ```bash + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify deploy init --output laconic-shopify-spec.yml + ``` + +* Create a deployment from the spec file: + + ```bash + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify deploy create --spec-file laconic-shopify-spec.yml --deployment-dir laconic-shopify-deployment + ``` + +## Configuration + +* Inside the `laconic-shopify-deployment` deployment directory, open `config.env` file and set following env variables: + + ```bash + # Shopify shop name + CERC_SHOPIFY_SHOP_NAME= + + # Access token for Shopify API + CERC_SHOPIFY_ACCESS_TOKEN= + + # Delay for fetching orders in milliseconds + CERC_FETCH_ORDER_DELAY=10000 + + # URL for the laconic faucet + CERC_FAUCET_URL='http://host.docker.internal:3000/' + ``` + +## Start the deployment + + ```bash + laconic-so deployment --dir laconic-shopify-deployment start + ``` + +## Check status + +* To list down and monitor the running container: + + ```bash + # With status + docker ps + + # Check logs for a container + docker logs -f + ``` + +## Clean up + +* Stop the `laconic-shopify-faucet` service running in the background: + + ```bash + # Stop the docker container + laconic-so deployment --dir laconic-shopify-deployment stop + ``` + +* To stop the service and also delete data: + + ```bash + # Stop the docker containers + laconic-so deployment --dir laconic-shopify-deployment stop --delete-volumes + + # Remove deployment directory (deployment will have to be recreated for a re-run) + rm -r laconic-shopify-deployment + ``` -- 2.45.2 From c892c8811ea5edb4edc9e391497e0390c724f0ab Mon Sep 17 00:00:00 2001 From: Neeraj Date: Mon, 28 Oct 2024 12:54:16 +0530 Subject: [PATCH 3/3] Use default env values for shopify stack --- .../compose/docker-compose-laconic-shopify.yml | 5 +++-- .../config/laconic-shopify/product_pricings.json | 2 +- stack-orchestrator/config/laconic-shopify/start-shopify.sh | 6 ++++-- stack-orchestrator/stacks/laconic-shopify/README.md | 7 +++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/stack-orchestrator/compose/docker-compose-laconic-shopify.yml b/stack-orchestrator/compose/docker-compose-laconic-shopify.yml index a832c60..764f422 100644 --- a/stack-orchestrator/compose/docker-compose-laconic-shopify.yml +++ b/stack-orchestrator/compose/docker-compose-laconic-shopify.yml @@ -5,10 +5,11 @@ services: command: ["bash", "-c", "./start-faucet.sh"] environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} - CERC_SHOPIFY_SHOP_NAME: ${CERC_SHOPIFY_SHOP_NAME} + CERC_SHOPIFY_GRAPHQL_URL: ${CERC_SHOPIFY_GRAPHQL_URL} CERC_SHOPIFY_ACCESS_TOKEN: ${CERC_SHOPIFY_ACCESS_TOKEN} - CERC_FETCH_ORDER_DELAY: ${CERC_FETCH_ORDER_DELAY} + CERC_FETCH_ORDER_DELAY: ${CERC_FETCH_ORDER_DELAY:-10000} CERC_FAUCET_URL: ${CERC_FAUCET_URL} + CERC_ITEMS_PER_ORDER: ${CERC_ITEMS_PER_ORDER:-10} volumes: - shopify-data:/app/data - ../config/laconic-shopify/start-shopify.sh:/app/start-faucet.sh diff --git a/stack-orchestrator/config/laconic-shopify/product_pricings.json b/stack-orchestrator/config/laconic-shopify/product_pricings.json index 75c4073..91e1b5e 100644 --- a/stack-orchestrator/config/laconic-shopify/product_pricings.json +++ b/stack-orchestrator/config/laconic-shopify/product_pricings.json @@ -1,5 +1,5 @@ { - "10 webapp deployments": "100000", + "10 pre-paid webapp deployments": "100000", "100 webapp deployments": "1000000", "500 webapp deployments": "5000000", "1000 webapp deployments": "10000000" diff --git a/stack-orchestrator/config/laconic-shopify/start-shopify.sh b/stack-orchestrator/config/laconic-shopify/start-shopify.sh index b25c3cb..d7ec38e 100755 --- a/stack-orchestrator/config/laconic-shopify/start-shopify.sh +++ b/stack-orchestrator/config/laconic-shopify/start-shopify.sh @@ -6,14 +6,16 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi -echo "Shopify shop name: $CERC_SHOPIFY_SHOP_NAME" +echo "Shopify GraphQL URL: $CERC_SHOPIFY_GRAPHQL_URL" echo "Shopify access token: $CERC_SHOPIFY_ACCESS_TOKEN" echo "Fetch order delay: $CERC_FETCH_ORDER_DELAY" echo "Faucet URL: $CERC_FAUCET_URL" +echo "Number of line items per order: $CERC_ITEMS_PER_ORDER" -export SHOPIFY_SHOP_NAME=$CERC_SHOPIFY_SHOP_NAME +export SHOPIFY_GRAPHQL_URL=$CERC_SHOPIFY_GRAPHQL_URL export SHOPIFY_ACCESS_TOKEN=$CERC_SHOPIFY_ACCESS_TOKEN export FETCH_ORDER_DELAY=$CERC_FETCH_ORDER_DELAY export FAUCET_URL=$CERC_FAUCET_URL +export ITEMS_PER_ORDER=$CERC_ITEMS_PER_ORDER yarn start \ No newline at end of file diff --git a/stack-orchestrator/stacks/laconic-shopify/README.md b/stack-orchestrator/stacks/laconic-shopify/README.md index 6bf8554..4a3560a 100644 --- a/stack-orchestrator/stacks/laconic-shopify/README.md +++ b/stack-orchestrator/stacks/laconic-shopify/README.md @@ -43,8 +43,8 @@ Instructions for running the laconic shopify * Inside the `laconic-shopify-deployment` deployment directory, open `config.env` file and set following env variables: ```bash - # Shopify shop name - CERC_SHOPIFY_SHOP_NAME= + # Shopify GraphQL URL + CERC_SHOPIFY_GRAPHQL_URL='https://6h071x-zw.myshopify.com/admin/api/2024-10/graphql.json' # Access token for Shopify API CERC_SHOPIFY_ACCESS_TOKEN= @@ -54,6 +54,9 @@ Instructions for running the laconic shopify # URL for the laconic faucet CERC_FAUCET_URL='http://host.docker.internal:3000/' + + # Number of line items per order in Get Orders GraphQL query + CERC_ITEMS_PER_ORDER=10 ``` ## Start the deployment -- 2.45.2