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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 9d2e5f1c00bd04277b492df979b367e1184c09de
Author: yujun <yu.jun.re...@gmail.com>
AuthorDate: Tue Mar 5 16:04:24 2024 +0800

    [feature](doris compose) doris compose use jdk 17 image (#31775)
---
 docker/runtime/doris-compose/Dockerfile | 32 ++++++++++++++++++++++++--------
 docker/runtime/doris-compose/command.py | 28 ++++++++++++++++++++++++----
 docker/runtime/doris-compose/utils.py   | 28 ++++++++++++++++++++--------
 3 files changed, 68 insertions(+), 20 deletions(-)

diff --git a/docker/runtime/doris-compose/Dockerfile 
b/docker/runtime/doris-compose/Dockerfile
index 2306bf67cd2..fb1b0331928 100644
--- a/docker/runtime/doris-compose/Dockerfile
+++ b/docker/runtime/doris-compose/Dockerfile
@@ -16,14 +16,30 @@
 # specific language governing permissions and limitations
 # under the License.
 
+#### START ARG ####
+
+# docker build cmd example:
+# docker build -f docker/runtime/doris-compose/Dockerfile -t 
<your-image-name>:<version> .
+
 # choose a base image
-FROM openjdk:8u342-jdk
+ARG JDK_IMAGE=openjdk:17-jdk-slim
+#ARG JDK_IMAGE=openjdk:8u342-jdk
+
+#### END ARG ####
+
+FROM ${JDK_IMAGE}
 
-ARG OUT_DIRECTORY=output
+RUN <<EOF
+    if [ -d "/usr/local/openjdk-17" ]; then
+        ln -s /usr/local/openjdk-17  /usr/local/openjdk
+    else \
+        ln -s /usr/local/openjdk-8  /usr/local/openjdk
+    fi
+EOF
 
 # set environment variables
-ENV JAVA_HOME="/usr/local/openjdk-8/"
-ENV jacoco_version 0.8.8
+ENV JAVA_HOME="/usr/local/openjdk"
+ENV JACOCO_VERSION 0.8.8
 
 RUN mkdir -p /opt/apache-doris/coverage
 
@@ -31,17 +47,17 @@ RUN  sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g 
/etc/apt/sources.list
 RUN  apt-get clean
 
 RUN apt-get update && \
-    apt-get install -y default-mysql-client python lsof tzdata curl unzip 
patchelf jq && \
+    apt-get install -y default-mysql-client python lsof tzdata curl unzip 
patchelf jq procps && \
     ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
     dpkg-reconfigure -f noninteractive tzdata && \
     apt-get clean
 
-RUN curl -f 
https://repo1.maven.org/maven2/org/jacoco/jacoco/$jacoco_version/jacoco-$jacoco_version.zip
 -o jacoco.zip && \
+RUN curl -f 
https://repo1.maven.org/maven2/org/jacoco/jacoco/${JACOCO_VERSION}/jacoco-${JACOCO_VERSION}.zip
 -o jacoco.zip && \
     mkdir /jacoco && \
     unzip jacoco.zip -d /jacoco
 
 # cloud
-COPY ${OUT_DIRECTORY}/../cloud/CMakeLists.txt 
${OUT_DIRECTORY}/../cloud/output* /opt/apache-doris/cloud/
+COPY cloud/CMakeLists.txt cloud/output* /opt/apache-doris/cloud/
 RUN <<EOF
     mkdir /opt/apache-doris/fdb
     if [ -d /opt/apache-doris/cloud/bin ]; then
@@ -50,7 +66,7 @@ RUN <<EOF
 EOF
 
 # fe and be
-COPY $OUT_DIRECTORY /opt/apache-doris/
+COPY output /opt/apache-doris/
 # in docker, run 'chmod 755 doris_be' first time cost 1min, remove it.
 RUN sed -i 's/\<chmod\>/echo/g' /opt/apache-doris/be/bin/start_be.sh
 
diff --git a/docker/runtime/doris-compose/command.py 
b/docker/runtime/doris-compose/command.py
index 7e1a4ef695a..31c212eec8a 100644
--- a/docker/runtime/doris-compose/command.py
+++ b/docker/runtime/doris-compose/command.py
@@ -278,7 +278,7 @@ class UpCommand(Command):
 
         parser.add_argument("--coverage-dir",
                             default="",
-                            help="code coverage output directory")
+                            help="Set code coverage output directory")
 
         parser.add_argument(
             "--fdb-version",
@@ -286,6 +286,20 @@ class UpCommand(Command):
             default="7.1.26",
             help="fdb image version. Only use in cloud cluster.")
 
+        if self._support_boolean_action():
+            parser.add_argument(
+                "--detach",
+                default=True,
+                action=self._get_parser_bool_action(False),
+                help="Detached mode: Run containers in the background. If 
specific --no-detach, "\
+                "will run containers in frontend. ")
+        else:
+            parser.add_argument("--no-detach",
+                                dest='detach',
+                                default=True,
+                                action=self._get_parser_bool_action(False),
+                                help="Run containers in frontend. ")
+
     def run(self, args):
         if not args.NAME:
             raise Exception("Need specific not empty cluster name")
@@ -401,7 +415,9 @@ class UpCommand(Command):
         if not args.start:
             options.append("--no-start")
         else:
-            options = ["-d", "--remove-orphans"]
+            options += ["--remove-orphans"]
+            if args.detach:
+                options.append("-d")
             if args.force_recreate:
                 options.append("--force-recreate")
 
@@ -410,8 +426,12 @@ class UpCommand(Command):
             related_node_num = cluster.get_all_nodes_num()
             related_nodes = None
 
-        utils.exec_docker_compose_command(cluster.get_compose_file(), "up",
-                                          options, related_nodes)
+        output_real_time = args.start and not args.detach
+        utils.exec_docker_compose_command(cluster.get_compose_file(),
+                                          "up",
+                                          options,
+                                          related_nodes,
+                                          output_real_time=output_real_time)
 
         ls_cmd = "python docker/runtime/doris-compose/doris-compose.py ls " + 
cluster.name
         LOG.info("Inspect command: " + utils.render_green(ls_cmd) + "\n")
diff --git a/docker/runtime/doris-compose/utils.py 
b/docker/runtime/doris-compose/utils.py
index 8b4b39619bc..54255b597bc 100644
--- a/docker/runtime/doris-compose/utils.py
+++ b/docker/runtime/doris-compose/utils.py
@@ -179,25 +179,37 @@ def is_dir_empty(dir):
     return False if os.listdir(dir) else True
 
 
-def exec_shell_command(command, ignore_errors=False):
+def exec_shell_command(command, ignore_errors=False, output_real_time=False):
     LOG.info("Exec command: {}".format(command))
     p = subprocess.Popen(command,
                          shell=True,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.STDOUT)
-    out = p.communicate()[0].decode('utf-8')
+    out = ''
+    exitcode = None
+    if output_real_time:
+        while p.poll() is None:
+            s = p.stdout.readline().decode('utf-8')
+            if ENABLE_LOG and s.rstrip():
+                print(s.rstrip())
+            out += s
+        exitcode = p.wait()
+    else:
+        out = p.communicate()[0].decode('utf-8')
+        exitcode = p.returncode
+        if ENABLE_LOG and out:
+            print(out)
     if not ignore_errors:
-        assert p.returncode == 0, out
-    if ENABLE_LOG and out:
-        print(out)
-    return p.returncode, out
+        assert exitcode == 0, out
+    return exitcode, out
 
 
 def exec_docker_compose_command(compose_file,
                                 command,
                                 options=None,
                                 nodes=None,
-                                user_command=None):
+                                user_command=None,
+                                output_real_time=False):
     if nodes != None and not nodes:
         return 0, "Skip"
 
@@ -206,7 +218,7 @@ def exec_docker_compose_command(compose_file,
         " ".join([node.service_name() for node in nodes]) if nodes else "",
         user_command if user_command else "")
 
-    return exec_shell_command(compose_cmd)
+    return exec_shell_command(compose_cmd, output_real_time=output_real_time)
 
 
 def get_docker_subnets_prefix16():


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to