Skip to content

Commit de09531

Browse files
authored
add deploy docker fullnode workflow (#51)
1 parent c0b13a5 commit de09531

31 files changed

+2262
-81
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Deploy new docker fullnode
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bucket-name:
7+
description: 'S3 bucket name to upload tron-docker.zip'
8+
required: true # Makes the input mandatory
9+
aws-region:
10+
description: 'AWS region for the S3 bucket (e.g., ap-southeast-1)'
11+
required: true # Makes the input mandatory
12+
13+
jobs:
14+
build-and-sign:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Zip files from tools/docker/codepipeline into tron-docker.zip (no directory structure)
21+
run: |
22+
# Ensure the directory exists
23+
if [ -d "tools/docker/codepipeline" ]; then
24+
cd tools/docker/codepipeline
25+
zip -r ../../../tron-docker.zip ./appspec.yml ./validate_service.sh ./start_service.sh ./prepare_environment.sh ./docker-compose.fullnode.nile.yml
26+
else
27+
echo "Error: tools/docker/codepipeline directory not found!"
28+
exit 1
29+
fi
30+
31+
- name: Configure AWS Credentials
32+
uses: aws-actions/configure-aws-credentials@v4
33+
with:
34+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
35+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
36+
aws-region: ${{ github.event.inputs.aws-region }} # Use input for region
37+
38+
- name: Upload tron-docker.zip to S3
39+
run: |
40+
aws s3 cp tron-docker.zip s3://${{ github.event.inputs.bucket-name }}/package/publish-latest.zip
41+
aws s3 cp tron-docker.zip s3://${{ github.event.inputs.bucket-name }}/package/publish-v0.1.1.zip

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ trond
2222
!trond/
2323
.DS_Store
2424
go
25+
gopath
2526
go1.*
2627
*FullNode_output-directory*
2728

build_trond.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ done
5959
# Check if Go is already installed on the system
6060
if command -v go &> /dev/null; then
6161
echo "Go is already installed on the system: $(go version)"
62-
SYSTEM_GO=true
62+
# SYSTEM_GO=true
63+
SYSTEM_GO=false
6364
else
6465
SYSTEM_GO=false
6566
fi
@@ -120,6 +121,12 @@ if [[ "$SYSTEM_GO" == false ]]; then
120121
GO_BIN="$(pwd)/go/bin"
121122
echo "Go binary path set to: $GO_BIN"
122123
export PATH="$GO_BIN:$PATH"
124+
125+
# Set GOPATH to a separate workspace directory
126+
GOPATH="$(pwd)/gopath"
127+
echo "GOPATH set to: $GOPATH"
128+
export GOPATH
129+
mkdir -p "$GOPATH/src" "$GOPATH/pkg" "$GOPATH/bin"
123130
else
124131
# Use the system Go binary location
125132
GO_BIN=$(dirname "$(command -v go)")

conf/private_net_layout.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# [database]
2+
# database_tar = "/path/to/database"
3+
4+
# [[nodes]]
5+
# node_ip = "192.168.1.1" # Remote node's IP
6+
# node_direcotry = "/path/to/direcotry" # Remote node's working direcotry for node
7+
# config_file = "/path/to/config" # Config file for remote node
8+
# node_type = "fullnode/sr" # Fullnode or SR node
9+
# ssh_port = 22
10+
# ssh_user = "user1"
11+
# ssh_password = "password1" # Optional; uncomment if using password auth
12+
# # ssh_key = "/path/to/key1" # Optional; uncomment if using key auth
13+
14+
# [[nodes]]
15+
# node_ip = "192.168.1.2" # Changed IP to demonstrate different nodes
16+
# node_direcotry = "/path/to/direcotry"
17+
# config_file = "/path/to/config"
18+
# node_type = "fullnode/sr"
19+
# ssh_port = 2222 # Custom SCP port for this node
20+
# ssh_user = "user2"
21+
# # No password or key; assumes SSH agent or pre-configured key
22+
23+
[database]
24+
database_tar = "/Users/barbatos/Downloads/hello.tgz"
25+
26+
[[nodes]]
27+
node_ip = "ec2-3-25-116-244.ap-southeast-2.compute.amazonaws.com"
28+
node_direcotry = "/home/ubuntu/mytest"
29+
config_file = "/Users/barbatos/Documents/code/md/mydev/tron-docker/conf/private_net_config_others.conf"
30+
node_type = "fullnode"
31+
ssh_port = 22
32+
ssh_user = "ubuntu"
33+
# ssh_password = "password1"
34+
ssh_key = "/Users/barbatos/Downloads/test-ci.pem" # Optional; uncomment if using key auth
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
tron-node-private:
3+
container_name: tron-node
4+
image: tronprotocol/java-tron:latest # Add specific tag if needed
5+
mem_limit: 6g
6+
ports:
7+
- "8090:8090"
8+
- "8091:8091"
9+
- "18888:18888"
10+
- "18888:18888/udp"
11+
- "50051:50051"
12+
volumes:
13+
- ../conf:/java-tron/conf
14+
- ../logs/private:/java-tron/logs
15+
- ../output-directory/private:/java-tron/output-directory
16+
command:
17+
- -jvm
18+
- "{-Xmx4g -Xms2g -XX:+UseConcMarkSweepGC}" # Using environment variable for JVM arguments
19+
- -c
20+
- /java-tron/conf/private_net_config_others.conf
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 0.0
2+
os: linux
3+
files:
4+
- source: docker-compose.fullnode.main.yml
5+
destination: /data/tron-node/tron-docker/
6+
hooks:
7+
BeforeInstall:
8+
- location: prepare_environment.sh
9+
timeout: 300
10+
runas: ubuntu
11+
ApplicationStart:
12+
- location: start_service.sh
13+
timeout: 180
14+
runas: ubuntu
15+
ValidateService:
16+
- location: validate_service.sh
17+
timeout: 300
18+
runas: ubuntu
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
tron-node-mainnet:
3+
container_name: tron-node
4+
image: tronprotocol/java-tron:v4.7.7 # Add specific tag if needed
5+
mem_limit: 16g
6+
ports:
7+
- "8090:8090"
8+
- "8091:8091"
9+
- "18888:18888"
10+
- "18888:18888/udp"
11+
- "50051:50051"
12+
volumes:
13+
- ./conf:/java-tron/conf
14+
- ./logs/mainnet:/java-tron/logs
15+
- ./output-directory/mainnet:/java-tron/output-directory
16+
command:
17+
- -jvm
18+
- "{-Xmx14g -Xms12g -XX:+UseConcMarkSweepGC}" # Using environment variable for JVM arguments
19+
- -c
20+
- /java-tron/conf/main_net_config.conf
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
tron-node-nile:
3+
container_name: tron-node
4+
image: java-tron:Nile_4.8.0 # Add specific tag if needed
5+
mem_limit: 6g
6+
ports:
7+
- "8090:8090"
8+
- "8091:8091"
9+
- "18888:18888"
10+
- "18888:18888/udp"
11+
- "50051:50051"
12+
volumes:
13+
- ./conf:/java-tron/conf
14+
- ./logs/nile:/java-tron/logs
15+
- ./output-directory/nile:/java-tron/output-directory
16+
command:
17+
- -jvm
18+
- "{-Xmx5g -Xms4g -XX:+UseConcMarkSweepGC}" # Using environment variable for JVM arguments
19+
- -c
20+
- /java-tron/conf/nile_net_config.conf
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
TARGET_DIR="/data/tron-node/tron-docker/"
4+
DOCKER_COMPOSE_FILE="docker-compose.fullnode.mail.yml"
5+
6+
cd ${TARGET_DIR} || exit
7+
./trond node run-single stop -t full-main -f ${DOCKER_COMPOSE_FILE}
8+
9+
# Wait and check if container is stopped
10+
max_attempts=30 # 2 minutes total (30 * 10 seconds)
11+
attempt=1
12+
13+
while [ $attempt -le $max_attempts ]; do
14+
if ! docker-compose -f ${DOCKER_COMPOSE_FILE} ps --services --filter "status=running" | grep -q "tron-node-mainnet"; then
15+
echo "Container successfully stopped"
16+
exit 0
17+
fi
18+
echo "Attempt $attempt of $max_attempts: Container still running, waiting 10 seconds..."
19+
sleep 10
20+
((attempt++))
21+
done
22+
23+
echo "Failed to stop container after 2 minutes"
24+
exit 1
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
TARGET_DIR="/data/tron-node/tron-docker/"
4+
DOCKER_COMPOSE_FILE="docker-compose.fullnode.mail.yml"
5+
6+
cd ${TARGET_DIR} || exit
7+
./trond node run-single -t full-main -f ${DOCKER_COMPOSE_FILE}
8+
9+
# Check if container is running
10+
max_attempts=12 # 2 minutes total (12 * 10 seconds)
11+
attempt=1
12+
13+
while [ $attempt -le $max_attempts ]; do
14+
if docker-compose -f ${DOCKER_COMPOSE_FILE} ps --services --filter "status=running" | grep -q "tron-node-mainnet"; then
15+
echo "Container is running, proceeding to API check"
16+
break
17+
fi
18+
echo "Attempt $attempt of $max_attempts: Container not running yet, waiting 10 seconds..."
19+
sleep 10
20+
((attempt++))
21+
done
22+
23+
if [ $attempt -gt $max_attempts ]; then
24+
echo "Container failed to start after 2 minutes"
25+
exit 1
26+
fi

0 commit comments

Comments
 (0)