Skip to content

Commit

Permalink
Add docker for RPC Proxy (#958)
Browse files Browse the repository at this point in the history
* feat: add docker option to RPC Proxy

* fix: update README.md
  • Loading branch information
fabiorigam authored Jun 6, 2024
1 parent 4b52224 commit 3f49de6
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#VeChain SDK
# VeChain SDK

Welcome to the official documentation for the JavaScriptVeChain SDK!
Welcome to the official documentation for the JavaScript VeChain SDK!

This SDK provides developers with tools and resources to integrate VeChain blockchain functionality into their applications with ease. Whether you're building decentralized applications (dApps), managing digital assets, or exploring blockchain-based solutions, this SDK offers a comprehensive set of features to interact with the VeChainThor blockchain.

Expand Down
3 changes: 3 additions & 0 deletions packages/rpc-proxy/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
Dockerfile
dist
17 changes: 17 additions & 0 deletions packages/rpc-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use the official Node.js image as the base image
FROM node:18-alpine

# Set the working directory in the container
WORKDIR /app

# Copy the dependencies file to the working directory
COPY ./ /app

# Install all the dependencies
RUN yarn install

# Build the app
RUN yarn build

# Serve the app
ENTRYPOINT ["yarn", "start"]
29 changes: 24 additions & 5 deletions packages/rpc-proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@
Welcome to the **RPC Proxy** of the VeChain SDK!

## Introduction
This project is designed to bridge the gap between Thor's RESTful API and Ethereum's JSON-RPC, for example to support the Remix IDE. By leveraging this proxy, users can seamlessly interact with the VeChainThor blockchain via RPC calls.

# Usage
The RPC Proxy is designed to bridge the gap between Thor's RESTful API and Ethereum's JSON-RPC, enabling seamless interaction with the VeChainThor blockchain through RPC calls. It is particularly useful for integrating with tools such as the Remix IDE.

The RPC proxy is very simple to use. To run it:
## Installation

To install the RPC proxy, use the following command:
``` bash
yarn add @vechain/sdk-rpc-proxy
rpc-proxy
```

By default the Proxy is configured to be used with a solo node running in your local machine. If you want to change the default behaviour, simply create a `config.json` file and pass it to the command when launching the RPC Proxy:
## Usage

The RPC proxy is simple to use. To start it, run:
``` bash
rpc-proxy
```

By default, the proxy is configured to be used with a solo node running on your local machine. If you want to change the default behavior, create a config.json file and pass it to the command when launching the RPC Proxy:
``` bash
rpc-proxy -c <json config file>
```
Expand All @@ -22,6 +30,16 @@ Or:
rpc-proxy --config <json config file>
```

# Run as Docker Container

To run the RPC proxy as a Docker container, follow these steps:
``` bash
docker build . -t vechain-rpc-proxy
docker run -d -p 8545:8545 -v ./config.json:/app/config.json -t vechain-rpc-proxy
```

If you do not pass a config.json file, the default solo network standard configuration will be used. Make sure to provide your desired configuration file.

## Configuration

The `config.json` file is used to configure the proxy server. It contains the following fields:
Expand All @@ -33,7 +51,8 @@ The `config.json` file is used to configure the proxy server. It contains the fo
- `debug`: Whether to enable debug mode.
- `enableDelegation`: Whether to enable delegation.

As an example:
### Example Configuration

``` json
{
"url": "http://127.0.0.1:8669",
Expand Down
8 changes: 5 additions & 3 deletions packages/rpc-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@
"start": "node dist/index.js"
},
"dependencies": {
"@vechain/sdk-network": "1.0.0-beta.14",
"@vechain/sdk-logging": "1.0.0-beta.14",
"@vechain/sdk-network": "1.0.0-beta.14",
"commander": "^12.1.0",
"cors": "^2.8.5",
"express": "^4.19.2"
"express": "^4.19.2",
"tsup": "^8.1.0",
"typescript": "^5.4.5"
},
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/node": "^20.14.1"
}
}
}
56 changes: 55 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,11 @@
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.4.tgz#11ef0398f9abee161193461910a507ef0d4c0c32"
integrity sha512-sywLRD3UK/qRJt0oBwdpYLBibk7KiRfbswmWRDabuncQYSlf8aLEEUor/oP6KRz8KEG+HoiVLBhPRD5JWjS8Sg==

"@esbuild/[email protected]":
version "0.21.4"
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.4.tgz#11ef0398f9abee161193461910a507ef0d4c0c32"
integrity sha512-sywLRD3UK/qRJt0oBwdpYLBibk7KiRfbswmWRDabuncQYSlf8aLEEUor/oP6KRz8KEG+HoiVLBhPRD5JWjS8Sg==

"@eslint-community/eslint-utils@^4.1.2", "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
Expand Down Expand Up @@ -3528,6 +3533,35 @@ esbuild@^0.21.4:
"@esbuild/win32-ia32" "0.21.4"
"@esbuild/win32-x64" "0.21.4"

esbuild@^0.21.4:
version "0.21.4"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.21.4.tgz#ceb501def8edb12a5bfd9c55f3a96db698edf022"
integrity sha512-sFMcNNrj+Q0ZDolrp5pDhH0nRPN9hLIM3fRPwgbLYJeSHHgnXSnbV3xYgSVuOeLWH9c73VwmEverVzupIv5xuA==
optionalDependencies:
"@esbuild/aix-ppc64" "0.21.4"
"@esbuild/android-arm" "0.21.4"
"@esbuild/android-arm64" "0.21.4"
"@esbuild/android-x64" "0.21.4"
"@esbuild/darwin-arm64" "0.21.4"
"@esbuild/darwin-x64" "0.21.4"
"@esbuild/freebsd-arm64" "0.21.4"
"@esbuild/freebsd-x64" "0.21.4"
"@esbuild/linux-arm" "0.21.4"
"@esbuild/linux-arm64" "0.21.4"
"@esbuild/linux-ia32" "0.21.4"
"@esbuild/linux-loong64" "0.21.4"
"@esbuild/linux-mips64el" "0.21.4"
"@esbuild/linux-ppc64" "0.21.4"
"@esbuild/linux-riscv64" "0.21.4"
"@esbuild/linux-s390x" "0.21.4"
"@esbuild/linux-x64" "0.21.4"
"@esbuild/netbsd-x64" "0.21.4"
"@esbuild/openbsd-x64" "0.21.4"
"@esbuild/sunos-x64" "0.21.4"
"@esbuild/win32-arm64" "0.21.4"
"@esbuild/win32-ia32" "0.21.4"
"@esbuild/win32-x64" "0.21.4"

escalade@^3.1.1, escalade@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27"
Expand Down Expand Up @@ -7414,6 +7448,26 @@ tsup@^8.1.0:
sucrase "^3.20.3"
tree-kill "^1.2.2"

tsup@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/tsup/-/tsup-8.1.0.tgz#354ce9def1721f5029564382ea2a42dc67fbb489"
integrity sha512-UFdfCAXukax+U6KzeTNO2kAARHcWxmKsnvSPXUcfA1D+kU05XDccCrkffCQpFaWDsZfV0jMyTsxU39VfCp6EOg==
dependencies:
bundle-require "^4.0.0"
cac "^6.7.12"
chokidar "^3.5.1"
debug "^4.3.1"
esbuild "^0.21.4"
execa "^5.0.0"
globby "^11.0.3"
joycon "^3.0.1"
postcss-load-config "^4.0.1"
resolve-from "^5.0.0"
rollup "^4.0.2"
source-map "0.8.0-beta.0"
sucrase "^3.20.3"
tree-kill "^1.2.2"

tty-table@^4.1.5:
version "4.2.3"
resolved "https://registry.yarnpkg.com/tty-table/-/tty-table-4.2.3.tgz#e33eb4007a0a9c976c97c37fa13ba66329a5c515"
Expand Down Expand Up @@ -7595,7 +7649,7 @@ typedoc@^0.25.13:
minimatch "^9.0.3"
shiki "^0.14.7"

typescript@^5.4.4:
typescript@^5.4.4, typescript@^5.4.5:
version "5.4.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611"
integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==
Expand Down

0 comments on commit 3f49de6

Please sign in to comment.