-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Dockerized the TCK server, added taskfile to execute all prereq…
…uisites for the tests to run, added README Signed-off-by: ivaylogarnev-limechain <ivaylo.garnev@limechain.tech>
- Loading branch information
1 parent
d1651eb
commit 7c4a897
Showing
7 changed files
with
218 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM node:20-slim | ||
|
||
WORKDIR /app | ||
|
||
# Copy package files | ||
COPY package.json pnpm-lock.yaml* ./ | ||
|
||
# Install pnpm | ||
RUN npm install -g pnpm | ||
|
||
# Override the local SDK dependency with the npm version and add missing dependencies | ||
RUN pnpm add @hashgraph/sdk@^2.58.0 long@^5.2.3 @hashgraph/proto@^2.16.0-beta.8 | ||
|
||
# Install dependencies | ||
RUN pnpm install | ||
|
||
ENV RUNNING_IN_DOCKER=true | ||
|
||
# Copy TCK source code | ||
COPY . . | ||
|
||
# Expose the port used by the server | ||
EXPOSE 8544 | ||
|
||
# Start the server | ||
CMD ["pnpm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# TCK Server Start-Up Guide 🛠️ | ||
|
||
This guide will help you set up, start, and test the TCK server using Docker and Node.js. Follow the steps below to ensure a smooth setup. | ||
|
||
# ⚡ TCK Server Start-Up | ||
|
||
## Prerequisites | ||
|
||
Before you begin, make sure you have: | ||
|
||
- Node.js → Version 20 or higher | ||
|
||
- npm → Version 10 or higher | ||
|
||
## 🚀 Start the TCK Server | ||
|
||
Run the following commands to install dependencies and start the server: | ||
|
||
```bash | ||
npm install | ||
npm run start | ||
``` | ||
|
||
Once started, your TCK server will be up and running! 🚦 | ||
|
||
# Start All TCK Tests with Docker 🐳 | ||
|
||
This guide will help you set up and start the TCK server, local node and run all TKC tests using Docker. Follow these steps to ensure all dependencies are installed and the server runs smoothly. | ||
|
||
## Prerequisites | ||
|
||
Before you begin, ensure you have the following installed: | ||
|
||
- **Node.js**: Version 20 or higher | ||
- **npm**: Version 10 or higher | ||
- **Docker**: Latest version | ||
- **Docker Compose**: Latest version | ||
|
||
## 🔧 Setup Instructions | ||
|
||
### 1. Check Node.js and npm | ||
|
||
Verify that Node.js and npm are installed and meet the version requirements: | ||
|
||
```bash | ||
node -v | ||
npm -v | ||
``` | ||
|
||
### 2. Install Hedera Local Node CLI | ||
|
||
If not already installed, run the following command: | ||
|
||
```bash | ||
npm install @hashgraph/hedera-local -g | ||
``` | ||
|
||
### 3. Start the Local Hedera Network | ||
|
||
Run the following command to start the local Hedera network: | ||
|
||
```bash | ||
task start-local-node | ||
``` | ||
|
||
### 4. Build the Docker Image | ||
|
||
Build the Docker image for the TCK JS server: | ||
|
||
```bash | ||
task build-tck-js-server | ||
``` | ||
|
||
### 5. Start All Services | ||
|
||
Now, let’s fire up all the services using Docker Compose: | ||
|
||
```bash | ||
task start-all-tests | ||
``` | ||
|
||
This will: | ||
|
||
- Spin up the TCK server | ||
|
||
- Start required containers | ||
|
||
- Run all tests automatically | ||
|
||
Sit back and let Docker do the magic! | ||
|
||
### 🎉 All Done! | ||
|
||
Your TCK server is now running inside Docker! 🚀 You can now execute tests and validate the system. | ||
|
||
Need help? Reach out to the team! 💬👨💻 | ||
|
||
Happy coding! 💻✨ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
version: "3" | ||
|
||
tasks: | ||
check-node: | ||
desc: "Check if Node.js is installed and meets the version requirement" | ||
silent: true | ||
cmds: | ||
- echo "Checking Node.js version..." | ||
- | | ||
if ! command -v node &> /dev/null || [ "$(node -v | cut -d'.' -f1)" -lt "v20" ]; then | ||
echo "Node.js v20 or higher is required. Please install it." | ||
exit 1 | ||
fi | ||
check-npm: | ||
desc: "Check if npm is installed and meets the version requirement" | ||
silent: true | ||
cmds: | ||
- echo "Checking npm version..." | ||
- | | ||
if ! command -v npm &> /dev/null || [ "$(npm -v | cut -d'.' -f1)" -lt "10" ]; then | ||
echo "NPM v10 or higher is required. Please install it." | ||
exit 1 | ||
fi | ||
install-hedera-local: | ||
desc: "Install Hedera Local Node CLI tool if not installed" | ||
silent: true | ||
cmds: | ||
- echo "Checking for Hedera Local Node CLI..." | ||
- | | ||
if ! command -v hedera &> /dev/null; then | ||
echo "Hedera Local Node CLI not found, installing..." | ||
npm install @hashgraph/hedera-local -g | ||
else | ||
echo "Hedera Local Node CLI is already installed." | ||
fi | ||
start-local-node: | ||
desc: "Start the local Hedera network" | ||
silent: true | ||
deps: [check-node, check-npm, install-hedera-local] | ||
cmds: | ||
- echo "Starting local Hedera network..." | ||
- hedera start | ||
|
||
build-tck-js-server: | ||
desc: "Build the Docker image for tck-js-server" | ||
silent: true | ||
cmds: | ||
- echo "Building Docker image for tck-js-server..." | ||
- docker build -t tck-js-server . | ||
|
||
start-all-tests: | ||
desc: "Start Docker Compose services" | ||
silent: true | ||
deps: [start-local-node, build-tck-js-server] | ||
cmds: | ||
- echo "Starting Docker Compose services..." | ||
- docker compose up | ||
|
||
default: | ||
desc: "Start local node and Docker Compose" | ||
silent: true | ||
deps: [start-all-tests] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
services: | ||
tck-server: | ||
image: tck-js-server | ||
build: | ||
context: . | ||
ports: | ||
- "8544:8544" | ||
networks: | ||
- tck-network | ||
tck-client: | ||
image: ivaylogarnev/tck-client | ||
depends_on: | ||
- tck-server | ||
networks: | ||
- tck-network | ||
networks: | ||
tck-network: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
import { Client } from "../lib"; | ||
import { Client, AccountId } from "@hashgraph/sdk"; | ||
|
||
export const sdk = { | ||
client: null, | ||
getClient(): Client { | ||
if (this.client == null) { | ||
throw new Error("Client not set up"); | ||
} | ||
|
||
if (process.env.RUNNING_IN_DOCKER) { | ||
this.client.setNetwork({ | ||
"host.docker.internal:50211": new AccountId(3), | ||
}); | ||
} | ||
|
||
return this.client; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters