This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 67576cd5d [type:feat] log directly to the console (#3976)
67576cd5d is described below

commit 67576cd5dbb55de2d17ba2a0f298fdc86781d993
Author: Luke.Z <[email protected]>
AuthorDate: Fri Sep 23 10:32:35 2022 +0800

    [type:feat] log directly to the console (#3976)
    
    * update entrypoint.sh
    
    * add logback.xml for docker
    
    * update
    
    * fix
---
 .github/workflows/docker-publish-dockerhub.yml     |  2 +
 .github/workflows/docker-publish.yml               |  2 +
 .github/workflows/e2e.yaml                         |  2 +
 Makefile                                           | 13 ++++---
 .../shenyu-admin-dist/{ => docker}/Dockerfile      |  3 +-
 .../docker}/entrypoint.sh                          | 15 +++++++-
 shenyu-dist/shenyu-admin-dist/docker/logback.xml   | 43 ++++++++++++++++++++++
 shenyu-dist/shenyu-admin-dist/pom.xml              |  2 +
 .../shenyu-bootstrap-dist/{ => docker}/Dockerfile  |  3 +-
 .../docker}/entrypoint.sh                          | 16 +++++++-
 .../shenyu-bootstrap-dist/docker/logback.xml       | 43 ++++++++++++++++++++++
 shenyu-dist/shenyu-bootstrap-dist/pom.xml          |  2 +
 12 files changed, 136 insertions(+), 10 deletions(-)

diff --git a/.github/workflows/docker-publish-dockerhub.yml 
b/.github/workflows/docker-publish-dockerhub.yml
index 56ac47cd5..d968343e3 100644
--- a/.github/workflows/docker-publish-dockerhub.yml
+++ b/.github/workflows/docker-publish-dockerhub.yml
@@ -73,6 +73,7 @@ jobs:
         uses: docker/build-push-action@v3
         with:
           context: ./shenyu-dist/shenyu-admin-dist
+          file: ./shenyu-dist/shenyu-admin-dist/docker/Dockerfile
           build-args: APP_NAME=apache-shenyu-*-admin-bin
           platforms: linux/amd64,linux/arm64
           push: true
@@ -84,6 +85,7 @@ jobs:
         uses: docker/build-push-action@v3
         with:
           context: ./shenyu-dist/shenyu-bootstrap-dist
+          file: ./shenyu-dist/shenyu-bootstrap-dist/docker/Dockerfile
           build-args: APP_NAME=apache-shenyu-*-bootstrap-bin
           platforms: linux/amd64,linux/arm64
           push: true
diff --git a/.github/workflows/docker-publish.yml 
b/.github/workflows/docker-publish.yml
index a37a63058..ae64ac4be 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -77,6 +77,7 @@ jobs:
         uses: docker/build-push-action@v3
         with:
           context: ./shenyu-dist/shenyu-admin-dist
+          file: ./shenyu-dist/shenyu-admin-dist/docker/Dockerfile
           build-args: APP_NAME=apache-shenyu-*-admin-bin
           platforms: linux/amd64,linux/arm64
           push: true
@@ -88,6 +89,7 @@ jobs:
         uses: docker/build-push-action@v3
         with:
           context: ./shenyu-dist/shenyu-bootstrap-dist
+          file: ./shenyu-dist/shenyu-bootstrap-dist/docker/Dockerfile
           build-args: APP_NAME=apache-shenyu-*-bootstrap-bin
           platforms: linux/amd64,linux/arm64
           push: true
diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml
index 09a5b32b4..416a691bb 100644
--- a/.github/workflows/e2e.yaml
+++ b/.github/workflows/e2e.yaml
@@ -66,6 +66,7 @@ jobs:
         uses: docker/build-push-action@v3
         with:
           context: ./shenyu-dist/shenyu-admin-dist
+          file: ./shenyu-dist/shenyu-admin-dist/docker/Dockerfile
           build-args: APP_NAME=apache-shenyu-*-admin-bin
           tags: shenyu/admin:latest
           outputs: type=docker,dest=/tmp/apache-shenyu-admin.tar
@@ -74,6 +75,7 @@ jobs:
         uses: docker/build-push-action@v3
         with:
           context: ./shenyu-dist/shenyu-bootstrap-dist
+          file: ./shenyu-dist/shenyu-bootstrap-dist/docker/Dockerfile
           build-args: APP_NAME=apache-shenyu-*-bootstrap-bin
           tags: shenyu/bootstrap:latest
           outputs: type=docker,dest=/tmp/apache-shenyu-bootstrap.tar
diff --git a/Makefile b/Makefile
index adbaf65ec..efe985c6b 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ VERSION := "2.5.1-SNAPSHOT"
 REGISTRY = "docker.io"
 REPOSITORY_PREF := "apache/shenyu"
 ADMIN_REPOSITORY := "${REPOSITORY_PREF}-admin"
-BOOTSTRAP_REPOSITORY := "${REPOSITORY_PREF}-admin"
+BOOTSTRAP_REPOSITORY := "${REPOSITORY_PREF}-bootstrap"
 
 TAG := latest
 
@@ -59,7 +59,7 @@ build-admin-image: build-admin ## build admin image for local
        @echo "build admin image"
        @docker buildx build --load \
                -t ${REGISTRY}/${ADMIN_REPOSITORY}:${TAG} \
-               -f ${SHENYU_HOME}/shenyu-dist/shenyu-admin-dist/Dockerfile \
+               -f 
${SHENYU_HOME}/shenyu-dist/shenyu-admin-dist/docker/Dockerfile \
                --build-arg APP_NAME=apache-shenyu-${VERSION}-admin-bin \
                ${SHENYU_HOME}/shenyu-dist/shenyu-admin-dist
 
@@ -67,7 +67,7 @@ build-bootstrap-image: build-bootstrap ## build bootstrap 
image for local
        @echo "build bootstrap image"
        @docker buildx build --load \
                -t ${REGISTRY}/${BOOTSTRAP_REPOSITORY}:${TAG} \
-               -f ${SHENYU_HOME}/shenyu-dist/shenyu-bootstrap-dist/Dockerfile \
+               -f 
${SHENYU_HOME}/shenyu-dist/shenyu-bootstrap-dist/docker/Dockerfile \
                --build-arg APP_NAME=apache-shenyu-${VERSION}-bootstrap-bin \
                ${SHENYU_HOME}/shenyu-dist/shenyu-bootstrap-dist
 
@@ -80,20 +80,21 @@ init:
        @docker buildx use shenyu
 
 publish-admin-image: build-admin
-       @docker buildx rm shenyu
+       @echo "build and push admin image"
        @docker buildx build --push \
                --platform=linux/arm64,linux/amd64 \
                -t ${REGISTRY}/${ADMIN_REPOSITORY}:latest \
                -t ${REGISTRY}/${ADMIN_REPOSITORY}:${VERSION} \
                --build-arg APP_NAME=apache-shenyu-${VERSION}-admin-bin \
-               -f ${SHENYU_HOME}/shenyu-dist/shenyu-admin-dist/Dockerfile \
+               -f 
${SHENYU_HOME}/shenyu-dist/shenyu-admin-dist/docker/Dockerfile \
                ${SHENYU_HOME}/shenyu-dist/shenyu-admin-dist
 
 publish-bootstrap-image: build-bootstrap
+       @echo "build and push bootstrap image"
        @docker buildx build --push \
                --platform=linux/arm64,linux/amd64 \
                -t ${REGISTRY}/${BOOSTRAP_REPOSITORY}:latest \
                -t ${REGISTRY}/${BOOSTRAP_REPOSITORY}:${VERSION} \
                --build-arg APP_NAME=apache-shenyu-${VERSION}-bootstrap-bin \
-               -f ${SHENYU_HOME}/shenyu-dist/shenyu-bootstrap-dist/Dockerfile \
+               -f 
${SHENYU_HOME}/shenyu-dist/shenyu-bootstrap-dist/docker/Dockerfile \
                ${SHENYU_HOME}/shenyu-dist/shenyu-bootstrap-dist
diff --git a/shenyu-dist/shenyu-admin-dist/Dockerfile 
b/shenyu-dist/shenyu-admin-dist/docker/Dockerfile
similarity index 91%
rename from shenyu-dist/shenyu-admin-dist/Dockerfile
rename to shenyu-dist/shenyu-admin-dist/docker/Dockerfile
index 1d9ee3822..1ee5a2113 100644
--- a/shenyu-dist/shenyu-admin-dist/Dockerfile
+++ b/shenyu-dist/shenyu-admin-dist/docker/Dockerfile
@@ -26,7 +26,8 @@ RUN apk --no-cache add procps
 ADD target/${APP_NAME}.tar.gz /opt
 RUN mv /opt/${APP_NAME} ${LOCAL_PATH}
 
-COPY entrypoint.sh ${LOCAL_PATH}/entrypoint.sh
+COPY docker/logback.xml ${LOCAL_PATH}/conf/logback.xml
+COPY docker/entrypoint.sh ${LOCAL_PATH}/entrypoint.sh
 RUN chmod +x ${LOCAL_PATH}/entrypoint.sh
 
 WORKDIR /opt/shenyu-admin
diff --git a/shenyu-dist/shenyu-bootstrap-dist/entrypoint.sh 
b/shenyu-dist/shenyu-admin-dist/docker/entrypoint.sh
similarity index 52%
rename from shenyu-dist/shenyu-bootstrap-dist/entrypoint.sh
rename to shenyu-dist/shenyu-admin-dist/docker/entrypoint.sh
index e4c003cef..7241bafcc 100644
--- a/shenyu-dist/shenyu-bootstrap-dist/entrypoint.sh
+++ b/shenyu-dist/shenyu-admin-dist/docker/entrypoint.sh
@@ -18,5 +18,18 @@
 
 [[ -d ./conf-ext ]] && cp -f ./conf-ext/* ./conf
 
-/bin/sh ${LOCAL_PATH}/bin/start.sh $1 && tail -f 
${LOCAL_PATH}/logs/shenyu-bootstrap.log
+DEPLOY_DIR=$(pwd)
+EXT_LIB=${DEPLOY_DIR}/ext-lib
 
+CLASS_PATH=.:${DEPLOY_DIR}/conf:${DEPLOY_DIR}/lib/*:${EXT_LIB}/*
+if [ -z "${ADMIN_JVM}" ]; then
+    JAVA_OPTS=" -server -Xmx2g -Xms2g -Xmn1g -Xss256k -XX:+DisableExplicitGC  
-XX:LargePageSizeInBytes=128m"
+    JAVA_OPTS="${JAVA_OPTS} -XX:+UseFastAccessorMethods  
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled 
-XX:+UseCMSInitiatingOccupancyOnly  -XX:CMSInitiatingOccupancyFraction=70"
+    echo "Use default jvm options: $JAVA_OPTS"
+else
+    JAVA_OPTS=${ADMIN_JVM}
+    echo "Start with the environment variable JAVA_OPTS set: $JAVA_OPTS"
+fi
+
+echo "Starting the Apache ShenYu Admin ..."
+exec ${JAVA_HOME}/bin/java ${JAVA_OPTS} -classpath ${CLASS_PATH} 
org.apache.shenyu.admin.ShenyuAdminBootstrap "$@"
diff --git a/shenyu-dist/shenyu-admin-dist/docker/logback.xml 
b/shenyu-dist/shenyu-admin-dist/docker/logback.xml
new file mode 100644
index 000000000..ea86d783e
--- /dev/null
+++ b/shenyu-dist/shenyu-admin-dist/docker/logback.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<configuration>
+
+    <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
+    <statusListener 
class="ch.qos.logback.core.status.OnConsoleStatusListener"/>
+    <property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] 
%-5level %logger - %msg%n"/>
+    <property name="ASYNC_DISCARDING_THRESHOLD" 
value="${log.async.discarding-threshold:-0}"/>
+    <property name="ASYNC_LOG_QUEUE_SIZE" 
value="${log.async.queue-size:-256}"/>
+
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>${LOG_PATTERN}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="ASYNC_STDOUT" class="ch.qos.logback.classic.AsyncAppender">
+        
<discardingThreshold>${ASYNC_DISCARDING_THRESHOLD}</discardingThreshold>
+        <queueSize>${ASYNC_LOG_QUEUE_SIZE}</queueSize>
+        <includeCallerData>true</includeCallerData>
+        <appender-ref ref="STDOUT"/>
+    </appender>
+
+    <root level="INFO">
+        <appender-ref ref="ASYNC_STDOUT"/>
+    </root>
+</configuration>
diff --git a/shenyu-dist/shenyu-admin-dist/pom.xml 
b/shenyu-dist/shenyu-admin-dist/pom.xml
index 26e8bb7ef..30f5ccd40 100644
--- a/shenyu-dist/shenyu-admin-dist/pom.xml
+++ b/shenyu-dist/shenyu-admin-dist/pom.xml
@@ -110,12 +110,14 @@
                                     <name>apache/shenyu-admin:latest</name>
                                     <build>
                                         
<contextDir>${project.basedir}</contextDir>
+                                        
<dockerFile>${project.basedir}/docker/Dockerfile</dockerFile>
                                     </build>
                                 </image>
                                 <image>
                                     
<name>apache/shenyu-admin:${project.version}</name>
                                     <build>
                                         
<contextDir>${project.basedir}</contextDir>
+                                        
<dockerFile>${project.basedir}/docker/Dockerfile</dockerFile>
                                     </build>
                                 </image>
                             </images>
diff --git a/shenyu-dist/shenyu-bootstrap-dist/Dockerfile 
b/shenyu-dist/shenyu-bootstrap-dist/docker/Dockerfile
similarity index 91%
rename from shenyu-dist/shenyu-bootstrap-dist/Dockerfile
rename to shenyu-dist/shenyu-bootstrap-dist/docker/Dockerfile
index f54f85d88..a59370b1b 100644
--- a/shenyu-dist/shenyu-bootstrap-dist/Dockerfile
+++ b/shenyu-dist/shenyu-bootstrap-dist/docker/Dockerfile
@@ -26,7 +26,8 @@ RUN apk --no-cache add procps
 ADD target/${APP_NAME}.tar.gz /opt
 RUN mv /opt/${APP_NAME} ${LOCAL_PATH}
 
-COPY entrypoint.sh ${LOCAL_PATH}/entrypoint.sh
+COPY docker/logback.xml ${LOCAL_PATH}/conf/logback.xml
+COPY docker/entrypoint.sh ${LOCAL_PATH}/entrypoint.sh
 RUN chmod +x ${LOCAL_PATH}/entrypoint.sh
 
 WORKDIR ${LOCAL_PATH}
diff --git a/shenyu-dist/shenyu-admin-dist/entrypoint.sh 
b/shenyu-dist/shenyu-bootstrap-dist/docker/entrypoint.sh
similarity index 52%
rename from shenyu-dist/shenyu-admin-dist/entrypoint.sh
rename to shenyu-dist/shenyu-bootstrap-dist/docker/entrypoint.sh
index a292fd7ca..d8262aebd 100644
--- a/shenyu-dist/shenyu-admin-dist/entrypoint.sh
+++ b/shenyu-dist/shenyu-bootstrap-dist/docker/entrypoint.sh
@@ -18,4 +18,18 @@
 
 [[ -d ./conf-ext ]] && cp -f ./conf-ext/* ./conf
 
-/bin/sh ${LOCAL_PATH}/bin/start.sh && tail -f 
${LOCAL_PATH}/logs/shenyu-admin.log
\ No newline at end of file
+DEPLOY_DIR=$(pwd)
+EXT_LIB=${DEPLOY_DIR}/ext-lib
+
+CLASS_PATH=.:${DEPLOY_DIR}/conf:${DEPLOY_DIR}/lib/*:${EXT_LIB}/*
+if [ -z "${BOOT_JVM}" ]; then
+    JAVA_OPTS=" -server -Xmx2g -Xms2g -Xmn1g -Xss512k -XX:+DisableExplicitGC   
-XX:LargePageSizeInBytes=128m"
+    JAVA_OPTS="${JAVA_OPTS} -XX:+UseFastAccessorMethods  
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled 
-XX:+UseCMSInitiatingOccupancyOnly  -XX:CMSInitiatingOccupancyFraction=70"
+    echo "Use default jvm options: $JAVA_OPTS"
+else
+    JAVA_OPTS=${BOOT_JVM}
+    echo "Start with the environment variable JAVA_OPTS set: $JAVA_OPTS"
+fi
+
+echo "Starting the Apache ShenYu Bootstrap ..."
+exec ${JAVA_HOME}/bin/java ${JAVA_OPTS} -classpath ${CLASS_PATH} 
org.apache.shenyu.bootstrap.ShenyuBootstrapApplication "$@"
diff --git a/shenyu-dist/shenyu-bootstrap-dist/docker/logback.xml 
b/shenyu-dist/shenyu-bootstrap-dist/docker/logback.xml
new file mode 100644
index 000000000..ea86d783e
--- /dev/null
+++ b/shenyu-dist/shenyu-bootstrap-dist/docker/logback.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<configuration>
+
+    <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
+    <statusListener 
class="ch.qos.logback.core.status.OnConsoleStatusListener"/>
+    <property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] 
%-5level %logger - %msg%n"/>
+    <property name="ASYNC_DISCARDING_THRESHOLD" 
value="${log.async.discarding-threshold:-0}"/>
+    <property name="ASYNC_LOG_QUEUE_SIZE" 
value="${log.async.queue-size:-256}"/>
+
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>${LOG_PATTERN}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="ASYNC_STDOUT" class="ch.qos.logback.classic.AsyncAppender">
+        
<discardingThreshold>${ASYNC_DISCARDING_THRESHOLD}</discardingThreshold>
+        <queueSize>${ASYNC_LOG_QUEUE_SIZE}</queueSize>
+        <includeCallerData>true</includeCallerData>
+        <appender-ref ref="STDOUT"/>
+    </appender>
+
+    <root level="INFO">
+        <appender-ref ref="ASYNC_STDOUT"/>
+    </root>
+</configuration>
diff --git a/shenyu-dist/shenyu-bootstrap-dist/pom.xml 
b/shenyu-dist/shenyu-bootstrap-dist/pom.xml
index 848ddd239..41d24c752 100644
--- a/shenyu-dist/shenyu-bootstrap-dist/pom.xml
+++ b/shenyu-dist/shenyu-bootstrap-dist/pom.xml
@@ -98,12 +98,14 @@
                                     <name>apache/shenyu-bootstrap:latest</name>
                                     <build>
                                         
<contextDir>${project.basedir}</contextDir>
+                                        
<dockerFile>${project.basedir}/docker/Dockerfile</dockerFile>
                                     </build>
                                 </image>
                                 <image>
                                     
<name>apache/shenyu-bootstrap:${project.version}</name>
                                     <build>
                                         
<contextDir>${project.basedir}</contextDir>
+                                        
<dockerFile>${project.basedir}/docker/Dockerfile</dockerFile>
                                     </build>
                                 </image>
                             </images>

Reply via email to