diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..d171944d877 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +./* +!docker-entrypoint.sh + diff --git a/Dockerfile b/Dockerfile index 608cd1d6929..6d7706b6adf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ No newline at end of file +ENTRYPOINT ["./bin/docker-entrypoint.sh"] \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 00000000000..d3c5d4c65c8 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -eo pipefail +shopt -s nullglob + +echo "./bin/FullNode $@" > command.txt +exec "./bin/FullNode" "$@" \ No newline at end of file diff --git a/gradle/unixStartScript.txt b/gradle/unixStartScript.txt index f2b5096f634..48cdff8c5f4 100644 --- a/gradle/unixStartScript.txt +++ b/gradle/unixStartScript.txt @@ -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" diff --git a/quickstart.md b/quickstart.md index 45d6e3bd82b..e6afb4b82f1 100644 --- a/quickstart.md +++ b/quickstart.md @@ -2,11 +2,11 @@ ## 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 @@ -14,6 +14,59 @@ Please refer to the Docker official website to download and install the latest D * 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 @@ -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"} ```