Skip to content

Commit

Permalink
docker: update java-tron docker deploy (tronprotocol#3330)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomatoishealthy authored Aug 11, 2020
1 parent 3d34e7d commit 8f99f3f
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
./*
!docker-entrypoint.sh

39 changes: 35 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
FROM tronprotocol/tron-gradle
FROM tronprotocol/centos7

ENV TMP_DIR="/tron-build"
ENV JDK_TAR="jdk-8u202-linux-x64.tar.gz"
ENV JDK_DIR="jdk1.8.0_202"
ENV JDK_MD5="0029351f7a946f6c05b582100c7d45b7"
ENV BASE_DIR="/java-tron"


RUN set -o errexit -o nounset \
&& yum -y install git wget \
&& wget -P /usr/local https://github.com/frekele/oracle-java/releases/download/8u202-b08/$JDK_TAR \
&& echo "$JDK_MD5 /usr/local/$JDK_TAR" | md5sum -c \
&& tar -zxf /usr/local/$JDK_TAR -C /usr/local\
&& rm /usr/local/$JDK_TAR \
&& export JAVA_HOME=/usr/local/$JDK_DIR \
&& export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar \
&& export PATH=$PATH:$JAVA_HOME/bin \
&& echo "git clone" \
&& mkdir -p $TMP_DIR \
&& cd $TMP_DIR \
&& git clone https://github.com/tronprotocol/java-tron.git \
&& cd java-tron \
&& gradle build
&& git checkout docker \
&& ./gradlew build -x test \
&& cd build/distributions \
&& unzip -o java-tron-1.0.0.zip \
&& mv java-tron-1.0.0 $BASE_DIR \
&& rm -rf $TMP_DIR \
&& rm -rf ~/.gradle \
&& mv $JAVA_HOME/jre /usr/local \
&& rm -rf $JAVA_HOME \
&& yum clean all

ENV JAVA_HOME="/usr/local/jre"
ENV PATH=$PATH:$JAVA_HOME/bin

COPY docker-entrypoint.sh $BASE_DIR/bin

WORKDIR /java-tron
WORKDIR $BASE_DIR

EXPOSE 18888
ENTRYPOINT ["./bin/docker-entrypoint.sh"]
6 changes: 6 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -eo pipefail
shopt -s nullglob

echo "./bin/FullNode $@" > command.txt
exec "./bin/FullNode" "$@"
26 changes: 25 additions & 1 deletion gradle/unixStartScript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,36 @@ if [ "\$cygwin" = "true" -o "\$msys" = "true" ] ; then
esac
fi

# Parse the jvm paramter from console
array=("\$@")
jvm_index=-1
for ((i=0;i<\${#array[@]};i++))
do
if [[ "-jvm" == \${array[\$i]} ]]; then
if [[ \${array[\$i+1]} =~ ^\\{.*\\}\$ ]]; then
jvm_args=\${array[\$i+1]}
len=\${#jvm_args}
jvm_args=\${jvm_args:1:\$len-2}
JAVA_OPTS="\$JAVA_OPTS \$jvm_args"
jvm_index=\$i
else
echo "jvm param format is not right"
exit -1
fi
fi
done

if [[ \$jvm_index -ge 0 ]]; then
unset array[jvm_index]
unset array[jvm_index+1]
fi

# Escape application args
save () {
for i do printf %s\\\\n "\$i" | sed "s/'/'\\\\\\\\''/g;1s/^/'/;\\\$s/\\\$/' \\\\\\\\/" ; done
echo " "
}
APP_ARGS=`save "\$@"`
APP_ARGS=`save \${array[*]}`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- \$DEFAULT_JVM_OPTS \$JAVA_OPTS \$${optsEnvironmentVar} <% if ( appNameSystemProperty ) { %>"\"-D${appNameSystemProperty}=\$APP_BASE_NAME\"" <% } %>-classpath "\"\$CLASSPATH\"" ${mainClassName} "\$APP_ARGS"
Expand Down
62 changes: 58 additions & 4 deletions quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,71 @@

## Introduction

This guide walks the user through the TRON Quickstart (v2.0.0) image setup.
The image exposes a Full Node, Solidity Node, and Event Server. Through TRON Quickstart, the user can deploy DApps, smart contracts, and interact with the TronWeb library.
More information about usage of [Quickstart:](https://github.com/TRON-US/docker-tron-quickstart)
This guide provides two ways for TRON quickstart:
- Set up a FullNode using the official tools: providing a wealth of configurable parameter to startup a FullNode
- Set up a complete private network for Tron development using a third-party tool: [docker-tron-quickstart](https://github.com/TRON-US/docker-tron-quickstart)

## Dependencies
## Dependencies

### Docker

Please refer to the Docker official website to download and install the latest Docker version:
* Docker Installation for [Mac](https://docs.docker.com/docker-for-mac/install/)
* Docker Installation for [Windows](https://docs.docker.com/docker-for-windows/install/)

## Quickstart for using the official tools

### Build the image from source with docker

#### Clone the java-tron repo

Pull the java-tron repo from github and change into the directory `java-tron`:
```
git clone https://github.com/tronprotocol/java-tron.git
cd java-tron
```

#### Build the image

Use the below command to start the build:
```
docker build -t tronprotocol/java-tron .
```

#### Using the official Docker images without building from source

If you'd like to use the already pre-built official images, it's as simple as downloading it from the Dockerhub registry with only one command:
```
docker pull tronprotocol/java-tron
```

### Run the container

You can just run the command below to start the java-tron:
```
docker run -it -d -p 8090:8090 -p 8091:8091 -p 18888:18888 -p 50051:50051 --restart always tronprotocol/java-tron
```

The `-p` flag defines the ports that the container needs to be mapped on the host machine. By default the container will start and join in the mainnet
using the built-in configuration file, you can specify another configuration file by mounting a directory and using the flag `-c`.
This image also supports custom some other startup parameters,here is an example for running a FullNode as an SR in production env:
```
docker run -it -d -p 8080:8080 -p 8090:8090 -p 18888:18888 -p 50051:50051 \
-v /Users/quan/tron/docker/conf:/java-tron/conf \
-v /Users/quan/tron/docker/datadir:/java-tron/data \
tronprotocol/java-tron \
-jvm "{-Xmx10g -Xms10g}" \
-c /java-tron/conf/config-localtest.conf \
-d /java-tron/data \
-w
```
Note: The directory `/Users/tron/docker/conf` shoud contain the file `config-localtest.conf`. The jvm parameters should be enclosed in double quotes and braces.

## Quickstart for using docker-tron-quickstart

The image exposes a Full Node, Solidity Node, and Event Server. Through TRON Quickstart, the user can deploy DApps, smart contracts, and interact with the TronWeb library.
More information about usage of [Quickstart:](https://github.com/TRON-US/docker-tron-quickstart)

### Node.JS Console
This will be used to interact with the Full and Solidity Nodes via Tron-Web.
[Node.JS](https://nodejs.org/en/) Console Download
Expand Down Expand Up @@ -139,6 +192,7 @@ If everything goes well, your terminal console output will look like following :
1. open your web browser
2. enter : http://127.0.0.1:9090/
3. there will be a response JSON data:

```
{"Welcome to":"TronGrid v2.2.8"}
```
Expand Down

0 comments on commit 8f99f3f

Please sign in to comment.