From 945d7d5b71c2a73aaaa352c5f92cc8e42a018bca Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:18:04 +0300 Subject: [PATCH 01/15] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c953254..ffd9b75 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # skale-proxy -skale-proxy is a public service that provides proxied and load-balanced JSON-RPC endpoints for SKALE chains +skale-proxy is a public service that provides proxied and load-balanced JSON-RPC endpoints for SKALE chains. +It is based on Nginx reverse proxy. From 43a41d1a0c38e28d52c2cc1e17565a61558620b5 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:19:25 +0300 Subject: [PATCH 02/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ffd9b75..fe4a6e3 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ skale-proxy is a public service that provides proxied and load-balanced JSON-RPC endpoints for SKALE chains. -It is based on Nginx reverse proxy. +It is based on Nginx reverse proxy that receives SKALE chain names and IP addresses of SKALE nodes from SKALE manager. From 5cb9d299052132796ed63f8c9a09a240944cf4c5 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:21:24 +0300 Subject: [PATCH 03/15] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index fe4a6e3..ca1594d 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,17 @@ skale-proxy is a public service that provides proxied and load-balanced JSON-RPC endpoints for SKALE chains. It is based on Nginx reverse proxy that receives SKALE chain names and IP addresses of SKALE nodes from SKALE manager. + +# Endpoints + +For SKALE mainnet the endpoints that proxy provides are in the form of + +http://proxy.skale.network/mainnet/CHAIN_NAME +https://proxy.skale.network/mainnet/CHAIN_NAME + +For SKALE testnet the endpoints that proxy provides are in the form of + +http://proxy.skale.network/testnet/CHAIN_NAME +https://proxy.skale.network/testnet/CHAIN_NAME + + From 288a76bf200d41239d61a712df8abf443f730f78 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:21:51 +0300 Subject: [PATCH 04/15] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ca1594d..6d05e77 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,17 @@ It is based on Nginx reverse proxy that receives SKALE chain names and IP addres For SKALE mainnet the endpoints that proxy provides are in the form of http://proxy.skale.network/mainnet/CHAIN_NAME + +or + https://proxy.skale.network/mainnet/CHAIN_NAME For SKALE testnet the endpoints that proxy provides are in the form of http://proxy.skale.network/testnet/CHAIN_NAME + +or + https://proxy.skale.network/testnet/CHAIN_NAME From 3cf84db079df969037ef2e64e98af7886f6c1df7 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:22:47 +0300 Subject: [PATCH 05/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d05e77..3539fb6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# skale-proxy +# Skale-proxy skale-proxy is a public service that provides proxied and load-balanced JSON-RPC endpoints for SKALE chains. From b710b83ad97a4d902ba095446ff52ab45a8058f9 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:23:44 +0300 Subject: [PATCH 06/15] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3539fb6..a6c7302 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Skale-proxy -skale-proxy is a public service that provides proxied and load-balanced JSON-RPC endpoints for SKALE chains. +skale-proxy is a public service that provides proxied and load-balanced JSON-RPC endpoints for SKL chains. -It is based on Nginx reverse proxy that receives SKALE chain names and IP addresses of SKALE nodes from SKALE manager. +It is based on Nginx reverse proxy that receives SKALE chain names and IP addresses of SKL nodes from SKALE manager. # Endpoints @@ -14,7 +14,7 @@ or https://proxy.skale.network/mainnet/CHAIN_NAME -For SKALE testnet the endpoints that proxy provides are in the form of +For SKL testnet the endpoints that proxy provides are in the form of http://proxy.skale.network/testnet/CHAIN_NAME From 7ec1d3a09c6c5db6348d8342e8b1ed0bc95cb095 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:30:54 +0300 Subject: [PATCH 07/15] Create build_docker.yml --- .github/workflows/build_docker.yml | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/build_docker.yml diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml new file mode 100644 index 0000000..95fa42d --- /dev/null +++ b/.github/workflows/build_docker.yml @@ -0,0 +1,52 @@ +name: Build and push skale-proxy container +on: + workflow_dispatch: + push: +jobs: + build: + runs-on: ubuntu-18.04 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + steps: + - name: Fail, if older Github Actions machine. Click "Re-run jobs" + run: cat /proc/cpuinfo | grep avx512 + - name: Login to docker + run: docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD} + - uses: actions/checkout@v1 + - name: submodule update + run: git submodule update --init --recursive + - name: build and deploy test image + run: python3 scripts/docker_build.py Dockerfile sgxwallet ${GITHUB_SHA} + - name: deploy docker image + if: | + contains(github.ref, 'develop') || contains(github.ref, 'beta') || + contains(github.ref, 'master') || + contains(github.ref, 'SECURE_ENCLAVE_CHANGES') + run : | + export BRANCH=${GITHUB_REF##*/} + echo "Branch $BRANCH" + export VERSION=$(cat VERSION) + echo "Version $VERSION" + export VERSION=$(bash ./scripts/calculate_version.sh $BRANCH $VERSION) + echo "::set-env name=VERSION::$VERSION" + echo "Version $VERSION" + export RELEASE=true + echo "::set-env name=RELEASE::$RELEASE" + bash ./scripts/build_image.sh Dockerfile sgxwallet + bash ./scripts/publish_image.sh sgxwallet + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + - name: Create Release + if: contains(github.ref, 'develop') || contains(github.ref, 'beta') || contains(github.ref, 'master') + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.VERSION }} + release_name: ${{ env.VERSION }} + draft: false + prerelease: true + From aa678e7e5513fa1d180f8939bad773438a662946 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:31:57 +0300 Subject: [PATCH 08/15] Update build_docker.yml --- .github/workflows/build_docker.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index 95fa42d..f6a5d52 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -10,8 +10,6 @@ jobs: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} steps: - - name: Fail, if older Github Actions machine. Click "Re-run jobs" - run: cat /proc/cpuinfo | grep avx512 - name: Login to docker run: docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD} - uses: actions/checkout@v1 @@ -22,8 +20,7 @@ jobs: - name: deploy docker image if: | contains(github.ref, 'develop') || contains(github.ref, 'beta') || - contains(github.ref, 'master') || - contains(github.ref, 'SECURE_ENCLAVE_CHANGES') + contains(github.ref, 'master') run : | export BRANCH=${GITHUB_REF##*/} echo "Branch $BRANCH" From 0cbcedab1024993e04c38668a2a209260adc4ba1 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:33:39 +0300 Subject: [PATCH 09/15] Create docker_build.py --- scripts/docker_build.py | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 scripts/docker_build.py diff --git a/scripts/docker_build.py b/scripts/docker_build.py new file mode 100644 index 0000000..7bfeaea --- /dev/null +++ b/scripts/docker_build.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +# Copyright (C) 2019-Present SKALE Labs +# +# This file is part of sgxwallet. +# +# sgxwallet is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# sgxwallet is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with sgxwallet. If not, see . +# +# @file docker_build.py +# @author Stan Kladko +# @date 2020 +# + +import sys, os, subprocess, time + +os.chdir("..") +topDir = os.getcwd() + "/skale-proxy" +DOCKER_FILE_NAME = sys.argv[1] +IMAGE_NAME = sys.argv[2] +COMMIT_HASH = sys.argv[3] + +FULL_IMAGE_TAG = "skalenetwork/" + IMAGE_NAME + ":" + COMMIT_HASH + +print("Starting build", flush=True) + +assert subprocess.call(["pwd"]) == 0 + +assert subprocess.call(["docker", "build", topDir, "--file", topDir + "/" + DOCKER_FILE_NAME, "--tag", + FULL_IMAGE_TAG]) == 0 + +assert subprocess.call(["docker", "push", FULL_IMAGE_TAG]) == 0 From adecc867b8ff17737a44ca653b8f25d87d279127 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:34:28 +0300 Subject: [PATCH 10/15] Create calculate_version.sh --- scripts/calculate_version.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/calculate_version.sh diff --git a/scripts/calculate_version.sh b/scripts/calculate_version.sh new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/scripts/calculate_version.sh @@ -0,0 +1 @@ + From 9b312ff16e2e12e59be810734cf6d843bdad84c4 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:34:56 +0300 Subject: [PATCH 11/15] Update calculate_version.sh --- scripts/calculate_version.sh | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/scripts/calculate_version.sh b/scripts/calculate_version.sh index 8b13789..98ba49d 100644 --- a/scripts/calculate_version.sh +++ b/scripts/calculate_version.sh @@ -1 +1,42 @@ +#!/bin/bash +BRANCH=$1 +VERSION=$2 + +if [ -z "$BRANCH" ] +then + echo "A branch is not set." + exit 1 +fi + +if [ -z "$VERSION" ] +then + echo "The base version is not set." + exit 1 +fi + +git fetch --tags + +if [ "$BRANCH" = "master" ] +then + echo "$VERSION" + exit 0 +fi + +LABEL="develop" +if [ "$BRANCH" = "stable" ] +then + LABEL="stable" +elif [ "$BRANCH" = "beta" ] +then + LABEL="beta" +fi + +for (( VERSION_NUMBER=0; ; VERSION_NUMBER++ )) +do + RESULT_VERSION="$VERSION-$LABEL.$VERSION_NUMBER" + if ! [[ $(git tag -l | grep $RESULT_VERSION) ]]; then + echo "$RESULT_VERSION" | tr / - + break + fi +done From 42fd8afcf8caed03d168ce9917d4c10d115a4e31 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:36:41 +0300 Subject: [PATCH 12/15] Update build_docker.yml --- .github/workflows/build_docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index f6a5d52..0df9789 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -16,7 +16,7 @@ jobs: - name: submodule update run: git submodule update --init --recursive - name: build and deploy test image - run: python3 scripts/docker_build.py Dockerfile sgxwallet ${GITHUB_SHA} + run: python3 scripts/docker_build.py Dockerfile skale-proxy ${GITHUB_SHA} - name: deploy docker image if: | contains(github.ref, 'develop') || contains(github.ref, 'beta') || @@ -31,8 +31,8 @@ jobs: echo "Version $VERSION" export RELEASE=true echo "::set-env name=RELEASE::$RELEASE" - bash ./scripts/build_image.sh Dockerfile sgxwallet - bash ./scripts/publish_image.sh sgxwallet + bash ./scripts/build_image.sh Dockerfile skale-proxy + bash ./scripts/publish_image.sh skale-proxy env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true - name: Create Release From f4b6e325ed465fb3dd8f3dc43d61bfbc634d1045 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:37:56 +0300 Subject: [PATCH 13/15] Create build_image.sh --- scripts/build_image.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scripts/build_image.sh diff --git a/scripts/build_image.sh b/scripts/build_image.sh new file mode 100644 index 0000000..16ca923 --- /dev/null +++ b/scripts/build_image.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -e +set -x + +DOCKERFILE=$1 +CONTAINER_NAME=$2 + +: "${VERSION?Need to set VERSION}" +: "${BRANCH?Need to set BRANCH}" + +REPO_NAME=skalenetwork/$CONTAINER_NAME +IMAGE_NAME=$REPO_NAME:$VERSION + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# Build image + +echo "Building $IMAGE_NAME..." +docker build -f "${DIR}"/../"${DOCKERFILE}" -t "${IMAGE_NAME}" . || exit $? + +if [ "${BRANCH}" = "stable" ]; +then + LATEST_IMAGE_NAME=$REPO_NAME:latest + docker tag "${IMAGE_NAME}" "${LATEST_IMAGE_NAME}" +else + LATEST_IMAGE_NAME=$REPO_NAME:$BRANCH-latest + docker tag "${IMAGE_NAME}" "${LATEST_IMAGE_NAME}" +fi + +echo "=========================================================================================" +echo "Built $IMAGE_NAME" From caac67c1f25a6092e929cf906ef56109fc730495 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:39:03 +0300 Subject: [PATCH 14/15] Create publish_image.sh --- scripts/publish_image.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts/publish_image.sh diff --git a/scripts/publish_image.sh b/scripts/publish_image.sh new file mode 100644 index 0000000..6705409 --- /dev/null +++ b/scripts/publish_image.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e +set -x + +CONTAINER_NAME=$1 + +: "${VERSION?Need to set VERSION}" +: "${BRANCH?Need to set BRANCH}" + +REPO_NAME=skalenetwork/$CONTAINER_NAME +IMAGE_NAME=$REPO_NAME:$VERSION + +LATEST_IMAGE_NAME=$REPO_NAME:$BRANCH-latest +docker tag "${IMAGE_NAME}" "${LATEST_IMAGE_NAME}" + +: "${DOCKER_USERNAME?Need to set DOCKER_USERNAME}" +: "${DOCKER_PASSWORD?Need to set DOCKER_PASSWORD}" + +echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin + +docker push "$IMAGE_NAME" || exit $? +docker push "$LATEST_IMAGE_NAME" || exit $? From 938643542075a3c983057a4fabb0c5f69bbfe9a5 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:43:43 +0300 Subject: [PATCH 15/15] Create VERSION --- VERSION | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..79e15fd --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.77.0