Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/skalenetwork/skale-proxy
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
kladkogex committed Jun 4, 2021
2 parents 240367f + 9386435 commit b8a4330
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 2 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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: 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 skale-proxy ${GITHUB_SHA}
- name: deploy docker image
if: |
contains(github.ref, 'develop') || contains(github.ref, 'beta') ||
contains(github.ref, 'master')
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 skale-proxy
bash ./scripts/publish_image.sh skale-proxy
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

25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# skale-proxy
# Skale-proxy

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 SKL 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

or

https://proxy.skale.network/mainnet/CHAIN_NAME

For SKL 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

skale-proxy is a public service that provides proxied and load-balanced JSON-RPC endpoints for SKALE chains


# running
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.77.0
32 changes: 32 additions & 0 deletions scripts/build_image.sh
Original file line number Diff line number Diff line change
@@ -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"
42 changes: 42 additions & 0 deletions scripts/calculate_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +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
42 changes: 42 additions & 0 deletions scripts/docker_build.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
#
# @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
23 changes: 23 additions & 0 deletions scripts/publish_image.sh
Original file line number Diff line number Diff line change
@@ -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 $?

0 comments on commit b8a4330

Please sign in to comment.