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/08/23 06:05:49 UTC

[incubator-inlong] branch master updated: [INLONG-1455][platform] add a script to publish docker images (#1456)

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 5688601  [INLONG-1455][platform] add a script to publish docker images (#1456)
5688601 is described below

commit 5688601ed182dfda892607d3b8e51d37b05fa054
Author: dockerzhang <do...@apache.org>
AuthorDate: Mon Aug 23 14:05:45 2021 +0800

    [INLONG-1455][platform] add a script to publish docker images (#1456)
    
    Co-authored-by: dockerzhang <do...@tencent.com>
---
 docker/README.md              | 12 ++++++
 docker/get-project-version.py | 29 ++++++++++++++
 docker/publish.sh             | 92 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 133 insertions(+)

diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..1ebbe40
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,12 @@
+## Docker For InLong
+
+Requirements:
+- [Docker](https://docs.docker.com/engine/install/) 19.03.1+
+
+### Build Images
+```
+mvn clean package -DskipTests -Pdocker
+```
+
+### Run All Modules
+- [docker-compose](docker-compose/README.md)
diff --git a/docker/get-project-version.py b/docker/get-project-version.py
new file mode 100644
index 0000000..631cd68
--- /dev/null
+++ b/docker/get-project-version.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+#
+# 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.
+#
+
+import xml.etree.ElementTree as ET
+from os.path import dirname, realpath, join
+
+# Derive the POM path from the current script location
+TOP_LEVEL_PATH = dirname(dirname(realpath(__file__)))
+POM_PATH = join(TOP_LEVEL_PATH, 'pom.xml')
+
+root = ET.XML(open(POM_PATH).read())
+print(root.find('{http://maven.apache.org/POM/4.0.0}version').text)
diff --git a/docker/publish.sh b/docker/publish.sh
new file mode 100644
index 0000000..46fdb57
--- /dev/null
+++ b/docker/publish.sh
@@ -0,0 +1,92 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+if [ -z "$DOCKER_USER" ]; then
+    echo "Docker user in variable \$DOCKER_USER was not set. Skipping image publishing"
+    exit 1
+fi
+
+if [ -z "$DOCKER_PASSWORD" ]; then
+    echo "Docker password in variable \$DOCKER_PASSWORD was not set. Skipping image publishing"
+    exit 1
+fi
+
+DOCKER_ORG="${DOCKER_ORG:-inlong}"
+
+docker login ${DOCKER_REGISTRY} -u="$DOCKER_USER" -p="$DOCKER_PASSWORD"
+if [ $? -ne 0 ]; then
+    echo "Failed to loging to Docker Hub"
+    exit 1
+fi
+
+MVN_VERSION=`python ./get-project-version.py`
+echo "InLong version: ${MVN_VERSION}"
+
+if [[ -z ${DOCKER_REGISTRY} ]]; then
+    docker_registry_org=${DOCKER_ORG}
+else
+    docker_registry_org=${DOCKER_REGISTRY}/${DOCKER_ORG}
+    echo "Starting to push images to ${docker_registry_org}..."
+fi
+
+set -x
+
+# Fail if any of the subsequent commands fail
+set -e
+
+# tag all images
+docker tag inlong/manager-web:latest     ${docker_registry_org}/manager-web:latest
+docker tag inlong/agent:latest           ${docker_registry_org}/agent:latest
+docker tag inlong/dataproxy:latest       ${docker_registry_org}/dataproxy:latest
+docker tag inlong/tubemq-manager:latest  ${docker_registry_org}/tubemq-manager:latest
+docker tag inlong/tubemq-all:latest      ${docker_registry_org}/tubemq-all:latest
+docker tag inlong/tubemq-build:latest    ${docker_registry_org}/tubemq-build:latest
+docker tag inlong/website:latest         ${docker_registry_org}/website:latest
+docker tag inlong/tubemq-cpp:latest      ${docker_registry_org}/tubemq-cpp:latest
+
+docker tag inlong/manager-web:$MVN_VERSION     ${docker_registry_org}/manager-web:$MVN_VERSION
+docker tag inlong/agent:$MVN_VERSION           ${docker_registry_org}/agent:$MVN_VERSION
+docker tag inlong/dataproxy:$MVN_VERSION       ${docker_registry_org}/dataproxy:$MVN_VERSION
+docker tag inlong/tubemq-manager:$MVN_VERSION  ${docker_registry_org}/tubemq-manager:$MVN_VERSION
+docker tag inlong/tubemq-all:$MVN_VERSION      ${docker_registry_org}/tubemq-all:$MVN_VERSION
+docker tag inlong/tubemq-build:$MVN_VERSION    ${docker_registry_org}/tubemq-build:$MVN_VERSION
+docker tag inlong/website:$MVN_VERSION         ${docker_registry_org}/website:$MVN_VERSION
+docker tag inlong/tubemq-cpp:$MVN_VERSION      ${docker_registry_org}/tubemq-cpp:$MVN_VERSION
+
+# Push all images and tags
+docker push inlong/manager-web:latest
+docker push inlong/agent:latest
+docker push inlong/dataproxy:latest
+docker push inlong/tubemq-manager:latest
+docker push inlong/tubemq-all:latest
+docker push inlong/tubemq-build:latest
+docker push inlong/website:latest
+docker push inlong/tubemq-cpp:latest
+
+docker push inlong/manager-web:$MVN_VERSION
+docker push inlong/agent:$MVN_VERSION
+docker push inlong/dataproxy:$MVN_VERSION
+docker push inlong/tubemq-manager:$MVN_VERSION
+docker push inlong/tubemq-all:$MVN_VERSION
+docker push inlong/tubemq-build:$MVN_VERSION
+docker push inlong/website:$MVN_VERSION
+docker push inlong/tubemq-cpp:$MVN_VERSION
+
+echo "Finished pushing images to ${docker_registry_org}"