diff --git a/README.md b/README.md index 94436051f4..aa97630352 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ Run the tool from source code Run the tool from release ```shell -java -jar app-0.0.1-SNAPSHOT-all.jar offset --bootstrap.servers 192.168.50.178:19993 +./docker/start_kafka_tool.sh offset --bootstrap.servers 192.168.50.178:19993 ``` ### Offset Explorer Configurations @@ -253,17 +253,17 @@ Run the tool from source code Run the tool from release ```shell # fetch every Mbeans from specific JMX server. -java -jar app-0.0.1-SNAPSHOT-all.jar metrics --jmx.server 192.168.50.178:1099 +./docker/start_kafka_tool.sh metrics --jmx.server 192.168.50.178:1099 # fetch any Mbean that its object name contains property "type=Memory". -java -jar app-0.0.1-SNAPSHOT-all.jar metrics --jmx.server 192.168.50.178:1099 --property type=Memory +./docker/start_kafka_tool.sh metrics --jmx.server 192.168.50.178:1099 --property type=Memory # fetch any Mbean that belongs to "kafka.network" domain name, # and it's object name contains two properties "request=Metadata" and "name=LocalTimeMs". -java -jar app-0.0.1-SNAPSHOT-all.jar metrics --jmx.server 192.168.50.178:1099 --domain kafka.network --property request=Metadata --property name=LocalTimeMs +./docker/start_kafka_tool.sh metrics --jmx.server 192.168.50.178:1099 --domain kafka.network --property request=Metadata --property name=LocalTimeMs # list all Mbeans' object name on specific JMX server. -java -jar app-0.0.1-SNAPSHOT-all.jar metrics --jmx.server 192.168.50.178:1099 --view-object-name-list +./docker/start_kafka_tool.sh metrics --jmx.server 192.168.50.178:1099 --view-object-name-list ``` ### Metric Explorer Configurations diff --git a/app/build.gradle b/app/build.gradle index 654fd43080..6aa56e20d3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,6 @@ plugins { // Apply the application plugin to add support for building a CLI application in Java. id 'application' - id 'com.github.johnrengelman.shadow' version '7.1.0' id 'maven-publish' } @@ -41,8 +40,8 @@ dependencies { application { // Define the main class for the application. - mainClass = 'org.astraea.App' - applicationDefaultJvmArgs = ["-server", "-XX:+UseG1GC", "-Djava.awt.headless=true", "-Xms4G", "-Xmx4G"] + mainClass = 'org.astraea.app.App' + applicationDefaultJvmArgs = ["-server", "-XX:+UseG1GC", "-Djava.awt.headless=true"] } java { diff --git a/docker/start_kafka_tool.sh b/docker/start_kafka_tool.sh index 1678b132d7..e13612d17d 100755 --- a/docker/start_kafka_tool.sh +++ b/docker/start_kafka_tool.sh @@ -26,13 +26,7 @@ function showHelp() { function generateDockerfile() { echo "# this dockerfile is generated dynamically -FROM ubuntu:22.04 AS build - -# Do not ask for confirmations when running apt-get, etc. -ENV DEBIAN_FRONTEND noninteractive - -# install tools -RUN apt-get update && apt-get install -y openjdk-11-jdk git curl +FROM ghcr.io/skiptests/astraea/deps AS build # clone repo WORKDIR /tmp @@ -43,7 +37,7 @@ WORKDIR /tmp/astraea RUN git checkout $VERSION RUN ./gradlew clean build -x test --no-daemon RUN mkdir /opt/astraea -RUN cp \$(find ./app/build/libs/ -maxdepth 1 -type f -name app-*-all.jar) /opt/astraea/app.jar +RUN tar -xvf \$(find ./app/build/distributions/ -maxdepth 1 -type f -name app-*.tar) -C /opt/astraea/ --strip-components=1 FROM ubuntu:22.04 @@ -99,10 +93,11 @@ function runContainer() { docker run --rm --init \ $background \ + -e JAVA_OPTS="$JMX_OPTS $HEAP_OPTS" \ -p $JMX_PORT:$JMX_PORT \ $need_to_bind_web \ "$IMAGE_NAME" \ - /bin/bash -c "java $JMX_OPTS $HEAP_OPTS -jar /opt/astraea/app.jar $args" + /opt/astraea/bin/app $args } # ===================================[main]===================================