You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by go...@apache.org on 2021/07/22 06:09:25 UTC

[incubator-inlong] branch master updated: [INLONG-779] update tubemq manager docker image (#574)

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

gosonzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 9074866  [INLONG-779] update tubemq manager docker image (#574)
9074866 is described below

commit 907486668b089edb389f81143d0f4dc143afcb29
Author: dockerzhang <do...@apache.org>
AuthorDate: Thu Jul 22 14:09:15 2021 +0800

    [INLONG-779] update tubemq manager docker image (#574)
    
    Co-authored-by: dockerzhang <do...@tencent.com>
---
 inlong-tubemq/tubemq-docker/pom.xml                |   1 +
 .../{ => tubemq-docker}/tubemq-manager/Dockerfile  |  17 ++--
 .../tubemq-docker/tubemq-manager/README.md         |  22 +++++
 .../tubemq-manager/manager-docker.sh}              |  27 +++++-
 inlong-tubemq/tubemq-docker/tubemq-manager/pom.xml | 103 +++++++++++++++++++++
 .../tubemq-manager/bin/start-admin-docker.sh       |  21 -----
 .../bin/{start-admin.sh => start-manager.sh}       |   0
 .../bin/{stop-admin.sh => stop-manager.sh}         |   0
 inlong-tubemq/tubemq-manager/conf/logback.xml      |   4 +-
 .../tubemq-manager/src/main/assembly/assembly.xml  |   1 +
 .../src/main/resources/application.properties      |   6 ++
 11 files changed, 168 insertions(+), 34 deletions(-)

diff --git a/inlong-tubemq/tubemq-docker/pom.xml b/inlong-tubemq/tubemq-docker/pom.xml
index 8e32c4a..dc215a4 100644
--- a/inlong-tubemq/tubemq-docker/pom.xml
+++ b/inlong-tubemq/tubemq-docker/pom.xml
@@ -33,6 +33,7 @@
         <module>tubemq-all</module>
         <module>tubemq-build</module>
         <module>tubemq-cpp</module>
+        <module>tubemq-manager</module>
     </modules>
 
     <dependencies>
diff --git a/inlong-tubemq/tubemq-manager/Dockerfile b/inlong-tubemq/tubemq-docker/tubemq-manager/Dockerfile
similarity index 72%
rename from inlong-tubemq/tubemq-manager/Dockerfile
rename to inlong-tubemq/tubemq-docker/tubemq-manager/Dockerfile
index b266ee4..6ff2f14 100644
--- a/inlong-tubemq/tubemq-manager/Dockerfile
+++ b/inlong-tubemq/tubemq-docker/tubemq-manager/Dockerfile
@@ -17,10 +17,15 @@
 # under the License.
 #
 FROM openjdk:8-jdk-alpine
-VOLUME /tmp
-COPY dist/tubemq-manager-bin.zip /
-RUN unzip /tubemq-manager-bin.zip
-RUN ["chmod", "+x", "/tubemq-manager/bin/start-manager.sh"]
-RUN ["chmod", "+x", "/tubemq-manager/bin/start-manager-docker.sh"]
-ENTRYPOINT ["/tubemq-manager/bin/start-manager-docker.sh"]
+# add tarball from target output
+ARG TUBEMQ_MANAGER_TARBALL
+ADD ${TUBEMQ_MANAGER_TARBALL} /opt/tubemq-manager
 EXPOSE 8089
+ENV MYSQL_HOST=127.0.0.1
+ENV MYSQL_PORT=3306
+ENV MYSQL_USER=root
+ENV MYSQL_PASSWD=inlong
+WORKDIR /opt/tubemq-manager
+ADD manager-docker.sh bin/
+RUN chmod +x bin/manager-docker.sh
+CMD ["bin/manager-docker.sh"]
diff --git a/inlong-tubemq/tubemq-docker/tubemq-manager/README.md b/inlong-tubemq/tubemq-docker/tubemq-manager/README.md
new file mode 100644
index 0000000..77e24ee
--- /dev/null
+++ b/inlong-tubemq/tubemq-docker/tubemq-manager/README.md
@@ -0,0 +1,22 @@
+#### tubemq-manager docker image
+TubeMQ manager is available for development and experience.
+
+##### Pull Image
+```
+docker pull inlong/tubemq-manager:latest
+```
+
+##### Start Container
+- start MySQL 5.7+
+- run Container
+
+```
+docker run -d --name manager -p 8089:8089 -e MYSQL_HOST=127.0.0.1 \
+-e MYSQL_USER=root -e MYSQL_PASSWD=inlong inlong/tubemq-manager
+```
+#### Add TubeMQ Cluster to Manager
+```
+curl --header "Content-Type: application/json" --request POST --data \
+'{"masterIp":"master_ip","clusterName":"inlong","masterPort":"8715","masterWebPort":"8080","createUser":"manager","token":"abc"}' \
+http://127.0.0.1:8089/v1/cluster?method=add
+```
\ No newline at end of file
diff --git a/inlong-tubemq/tubemq-manager/src/main/resources/application.properties b/inlong-tubemq/tubemq-docker/tubemq-manager/manager-docker.sh
similarity index 54%
copy from inlong-tubemq/tubemq-manager/src/main/resources/application.properties
copy to inlong-tubemq/tubemq-docker/tubemq-manager/manager-docker.sh
index f1f53a4..203e2b7 100644
--- a/inlong-tubemq/tubemq-manager/src/main/resources/application.properties
+++ b/inlong-tubemq/tubemq-docker/tubemq-manager/manager-docker.sh
@@ -1,20 +1,37 @@
+#!/bin/sh
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
+# 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
-# <p>
-# http://www.apache.org/licenses/LICENSE-2.0
-# <p>
+# 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.
 #
+
+file_path=$(cd "$(dirname "$0")";pwd)
+# config
+cat <<EOF > ${file_path}/../conf/application.properties
 spring.jpa.hibernate.ddl-auto=update
 # configuration for admin
 topic.config.schedule=0/5 * * * * ?
 broker.reload.schedule=0/5 * * * * ?
+# mysql configuration for manager
+spring.datasource.url=jdbc:mysql://$MYSQL_HOST:$MYSQL_PORT/tubemanager
+spring.datasource.username=$MYSQL_USER
+spring.datasource.password=$MYSQL_PASSWD
+# server port
+server.port=8089
+EOF
+# start
+sh ${file_path}/start-manager.sh
+sleep 3
+# keep alive
+tail -F ${file_path}/../logs/tubemq-manager.out
\ No newline at end of file
diff --git a/inlong-tubemq/tubemq-docker/tubemq-manager/pom.xml b/inlong-tubemq/tubemq-docker/tubemq-manager/pom.xml
new file mode 100644
index 0000000..5317266
--- /dev/null
+++ b/inlong-tubemq/tubemq-docker/tubemq-manager/pom.xml
@@ -0,0 +1,103 @@
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>tubemq-docker</artifactId>
+    <groupId>org.apache.inlong</groupId>
+    <version>0.9.0-incubating</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <name>Apache InLong - TubeMQ Docker Manager</name>
+  <groupId>org.apache.inlong</groupId>
+  <artifactId>tubemq-manager-docker</artifactId>
+  <packaging>pom</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.inlong</groupId>
+      <artifactId>tubemq-manager</artifactId>
+      <version>${project.parent.version}</version>
+      <classifier>bin</classifier>
+      <type>tar.gz</type>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+  <profiles>
+    <profile>
+      <id>docker</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>com.spotify</groupId>
+            <artifactId>dockerfile-maven-plugin</artifactId>
+            <version>${dockerfile-maven.version}</version>
+            <executions>
+              <execution>
+                <id>default</id>
+                <goals>
+                  <goal>build</goal>
+                </goals>
+              </execution>
+              <execution>
+                <id>tag-and-push-latest</id>
+                <goals>
+                  <goal>tag</goal>
+                  <goal>push</goal>
+                </goals>
+                <configuration>
+                  <repository>${docker.organization}/tubemq-manager</repository>
+                  <tag>latest</tag>
+                </configuration>
+              </execution>
+            </executions>
+            <configuration>
+              <repository>${docker.organization}/tubemq-manager</repository>
+              <pullNewerImage>false</pullNewerImage>
+              <tag>${project.version}</tag>
+              <buildArgs>
+                <TUBEMQ_MANAGER_TARBALL>target/tubemq-manager-${project.version}-bin.tar.gz</TUBEMQ_MANAGER_TARBALL>
+              </buildArgs>
+            </configuration>
+          </plugin>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-dependency-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>copy-tarball</id>
+                <goals>
+                  <goal>copy-dependencies</goal>
+                </goals>
+                <phase>generate-resources</phase>
+                <configuration>
+                  <outputDirectory>${project.build.directory}/</outputDirectory>
+                  <includeArtifactIds>tubemq-manager</includeArtifactIds>
+                  <excludeTransitive>true</excludeTransitive>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
diff --git a/inlong-tubemq/tubemq-manager/bin/start-admin-docker.sh b/inlong-tubemq/tubemq-manager/bin/start-admin-docker.sh
deleted file mode 100644
index ce7cbf7..0000000
--- a/inlong-tubemq/tubemq-manager/bin/start-admin-docker.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env sh
-#
-# 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
-# <p>
-# http://www.apache.org/licenses/LICENSE-2.0
-# <p>
-# 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.
-#
-
-START_CMD="/tubemq-admin/bin/start-admin.sh"
-exec $START_CMD &
-tail -f /dev/null
\ No newline at end of file
diff --git a/inlong-tubemq/tubemq-manager/bin/start-admin.sh b/inlong-tubemq/tubemq-manager/bin/start-manager.sh
similarity index 100%
rename from inlong-tubemq/tubemq-manager/bin/start-admin.sh
rename to inlong-tubemq/tubemq-manager/bin/start-manager.sh
diff --git a/inlong-tubemq/tubemq-manager/bin/stop-admin.sh b/inlong-tubemq/tubemq-manager/bin/stop-manager.sh
similarity index 100%
rename from inlong-tubemq/tubemq-manager/bin/stop-admin.sh
rename to inlong-tubemq/tubemq-manager/bin/stop-manager.sh
diff --git a/inlong-tubemq/tubemq-manager/conf/logback.xml b/inlong-tubemq/tubemq-manager/conf/logback.xml
index 4b46451..40a677c 100644
--- a/inlong-tubemq/tubemq-manager/conf/logback.xml
+++ b/inlong-tubemq/tubemq-manager/conf/logback.xml
@@ -32,7 +32,7 @@
 
     <appender name="FILE_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <FileNamePattern>../logs/tubemq-admin.info.%d{yyyy-MM-dd}.part_%i.log</FileNamePattern>
+            <FileNamePattern>../logs/tubemq-manager.info.%d{yyyy-MM-dd}.part_%i.log</FileNamePattern>
             <maxHistory>10</maxHistory>
             <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                 <maxFileSize>100MB</maxFileSize>
@@ -46,7 +46,7 @@
 
     <appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <FileNamePattern>../logs/tubemq-admin.error.%d{yyyy-MM-dd}.part_%i.log</FileNamePattern>
+            <FileNamePattern>../logs/tubemq-manager.error.%d{yyyy-MM-dd}.part_%i.log</FileNamePattern>
             <maxHistory>10</maxHistory>
             <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                 <maxFileSize>100MB</maxFileSize>
diff --git a/inlong-tubemq/tubemq-manager/src/main/assembly/assembly.xml b/inlong-tubemq/tubemq-manager/src/main/assembly/assembly.xml
index 48537cf..aeb32dd 100644
--- a/inlong-tubemq/tubemq-manager/src/main/assembly/assembly.xml
+++ b/inlong-tubemq/tubemq-manager/src/main/assembly/assembly.xml
@@ -21,6 +21,7 @@
     <id>bin</id>
     <formats>
         <format>dir</format>
+        <format>tar.gz</format>
     </formats>
     <includeBaseDirectory>false</includeBaseDirectory>
     <dependencySets>
diff --git a/inlong-tubemq/tubemq-manager/src/main/resources/application.properties b/inlong-tubemq/tubemq-manager/src/main/resources/application.properties
index f1f53a4..5c023ce 100644
--- a/inlong-tubemq/tubemq-manager/src/main/resources/application.properties
+++ b/inlong-tubemq/tubemq-manager/src/main/resources/application.properties
@@ -18,3 +18,9 @@ spring.jpa.hibernate.ddl-auto=update
 # configuration for admin
 topic.config.schedule=0/5 * * * * ?
 broker.reload.schedule=0/5 * * * * ?
+# mysql configuration for manager
+# spring.datasource.url=jdbc:mysql://mysql_ip:mysql_port/tubemanager
+# spring.datasource.username=mysql_username
+# spring.datasource.password=mysql_password
+# server port
+server.port=8089