You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/07/04 11:40:19 UTC

[GitHub] [inlong] lucaspeng12138 opened a new pull request, #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

lucaspeng12138 opened a new pull request, #4863:
URL: https://github.com/apache/inlong/pull/4863

   ### Prepare a Pull Request
   [INLONG-4862][Docker] Add publish images by arch and push manifest script
   
   - Fixes #4862 
   
   ### Motivation
   
   Add publish images by arch and push manifest script
   
   ### Modifications
   
   Use script to do following works:
   1、Add build operation before publish. Build docker images by arch.
   2、Add tag operation before publish. Add arch after version.
   3、Publish images according to docker registry information.
   4、Push manifest. This option doesn't need arch.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] dockerzhang commented on pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
dockerzhang commented on PR #4863:
URL: https://github.com/apache/inlong/pull/4863#issuecomment-1174568767

   `publish.sh` used in `.github/workflows/ci_docker.yml`, it is better to change it at the same time.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] shink commented on a diff in pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
shink commented on code in PR #4863:
URL: https://github.com/apache/inlong/pull/4863#discussion_r912959921


##########
docker/publish-by-arch.sh:
##########
@@ -0,0 +1,248 @@
+#!/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.
+#
+
+ARCH="x86"
+NEED_BUILD=false
+NEED_TAG=false
+NEED_PUBLISH=false
+NEED_MANIFEST=false
+
+SRC_POSTFIX=""
+DES_POSTFIX="x86"
+
+SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
+
+MVN_VERSION=`python ./get-project-version.py`
+
+buildImage() {
+  echo "Start building images"
+  if [ $ARCH = "aarch64" ]; then
+    sh build-arm-docker-images.sh

Review Comment:
   ```shell
   mvn clean package -DskipTests -Pdocker
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] shink commented on a diff in pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
shink commented on code in PR #4863:
URL: https://github.com/apache/inlong/pull/4863#discussion_r912965193


##########
docker/publish-by-arch.sh:
##########
@@ -0,0 +1,248 @@
+#!/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.
+#
+
+ARCH="x86"

Review Comment:
   How about `$(uname -m)` ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] shink commented on a diff in pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
shink commented on code in PR #4863:
URL: https://github.com/apache/inlong/pull/4863#discussion_r912969211


##########
docker/publish-by-arch.sh:
##########
@@ -0,0 +1,248 @@
+#!/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.
+#
+
+ARCH="x86"
+NEED_BUILD=false
+NEED_TAG=false
+NEED_PUBLISH=false
+NEED_MANIFEST=false
+
+SRC_POSTFIX=""
+DES_POSTFIX="x86"
+
+SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
+
+MVN_VERSION=`python ./get-project-version.py`
+
+buildImage() {
+  echo "Start building images"
+  if [ $ARCH = "aarch64" ]; then
+    sh build-arm-docker-images.sh
+  else
+    cd ${SHELL_FOLDER}
+    cd ..
+    mvn clean install -DskipTests -Pdocker
+  fi
+  echo "End building images"
+}
+
+tagImage() {
+  echo "Start tagging images"
+  if [ $ARCH = "aarch64" ]; then
+    SRC_POSTFIX="aarch64"
+    DES_POSTFIX="aarch64"
+  fi
+
+  docker tag inlong/manager:latest-${SRC_POSTFIX}      ${docker_registry_org}/manager:latest-${DES_POSTFIX}
+  docker tag inlong/agent:latest-${SRC_POSTFIX}           ${docker_registry_org}/agent:latest-${DES_POSTFIX}
+  docker tag inlong/dataproxy:latest-${SRC_POSTFIX}       ${docker_registry_org}/dataproxy:latest-${DES_POSTFIX}
+  docker tag inlong/tubemq-manager:latest-${SRC_POSTFIX}  ${docker_registry_org}/tubemq-manager:latest-${DES_POSTFIX}
+  docker tag inlong/tubemq-all:latest-${SRC_POSTFIX}      ${docker_registry_org}/tubemq-all:latest-${DES_POSTFIX}
+  docker tag inlong/tubemq-build:latest-${SRC_POSTFIX}    ${docker_registry_org}/tubemq-build:latest-${DES_POSTFIX}
+  docker tag inlong/dashboard:latest-${SRC_POSTFIX}         ${docker_registry_org}/dashboard:latest-${DES_POSTFIX}
+  docker tag inlong/tubemq-cpp:latest-${SRC_POSTFIX}      ${docker_registry_org}/tubemq-cpp:latest-${DES_POSTFIX}
+  docker tag inlong/audit:latest-${SRC_POSTFIX}      ${docker_registry_org}/audit:latest-${DES_POSTFIX}
+
+  docker tag inlong/manager:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/manager:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/agent:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/agent:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/dataproxy:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/dataproxy:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/tubemq-manager:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/tubemq-manager:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/tubemq-all:${MVN_VERSION}-${SRC_POSTFIX}  \
+  ${docker_registry_org}/tubemq-all:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/tubemq-build:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/tubemq-build:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/dashboard:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/dashboard:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/tubemq-cpp:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/tubemq-cpp:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/audit:${MVN_VERSION}-${SRC_POSTFIX}  \
+    ${docker_registry_org}/audit:${MVN_VERSION}-${DES_POSTFIX}
+  echo "End tagging images"
+}
+
+publishImages() {
+  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}"
+
+  echo $DOCKER_PASSWORD | docker login ${DOCKER_REGISTRY} -u="$DOCKER_USER" --password-stdin
+  if [ $? -ne 0 ]; then
+      echo "Failed to login to ${DOCKER_REGISTRY}"
+      exit 1
+  fi
+
+  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
+
+  set -e
+
+  pushImage ${docker_registry_org}
+}
+
+pushImage() {
+  echo "Start pushing images"
+  docker_registry_org=$1
+
+  if [ $ARCH = "aarch64" ]; then
+    SRC_POSTFIX="aarch64"
+    DES_POSTFIX="arm64"
+  elif [ $NEED_TAG = true ]; then
+    SRC_POSTFIX="x86"
+  fi
+
+  docker push inlong/manager:latest-${SRC_POSTFIX}
+  docker push inlong/agent:latest-${SRC_POSTFIX}
+  docker push inlong/dataproxy:latest-${SRC_POSTFIX}
+  docker push inlong/tubemq-manager:latest-${SRC_POSTFIX}
+  docker push inlong/tubemq-all:latest-${SRC_POSTFIX}
+  docker push inlong/tubemq-build:latest-${SRC_POSTFIX}
+  docker push inlong/dashboard:latest-${SRC_POSTFIX}
+  docker push inlong/tubemq-cpp:latest-${SRC_POSTFIX}
+  docker push inlong/audit:latest-${SRC_POSTFIX}
+
+  docker push inlong/manager:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/agent:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/dataproxy:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/tubemq-manager:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/tubemq-all:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/tubemq-build:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/dashboard:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/tubemq-cpp:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/audit:${MVN_VERSION}-${SRC_POSTFIX}
+
+  echo "Finished pushing images to ${docker_registry_org}"
+}
+
+pushManifest() {
+  echo "Start pushing manifest ..."
+  docker manifest create --insecure --amend inlong/manager:latest \
+    inlong/manager:latest-arm64 inlong/manager:latest-x86
+  docker manifest create --insecure --amend inlong/agent:latest \
+    inlong/agent:latest-arm64 inlong/agent:latest-x86
+  docker manifest create --insecure --amend inlong/dataproxy:latest \
+    inlong/dataproxy:latest-arm64 inlong/dataproxy:latest-x86
+  docker manifest create --insecure --amend inlong/tubemq-manager:latest \
+    inlong/tubemq-manager:latest-arm64 inlong/tubemq-manager:latest-x86
+  docker manifest create --insecure --amend inlong/tubemq-all:latest \
+    inlong/tubemq-all:latest-arm64 inlong/tubemq-all:latest-x86
+  docker manifest create --insecure --amend inlong/tubemq-build:latest \
+    inlong/tubemq-build:latest-arm64 inlong/tubemq-build:latest-x86
+  docker manifest create --insecure --amend inlong/dashboard:latest \
+    inlong/dashboard:latest-arm64 inlong/dashboard:latest-x86
+  docker manifest create --insecure --amend inlong/tubemq-cpp:latest \
+    inlong/tubemq-cpp:latest-arm64 inlong/tubemq-cpp:latest-x86
+  docker manifest create --insecure --amend inlong/audit:latest \
+    inlong/audit:latest-arm64 inlong/audit:latest-x86
+
+  docker manifest create --insecure --amend inlong/manager:${MVN_VERSION} \
+    inlong/manager:${MVN_VERSION}-arm64 inlong/manager:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/agent:${MVN_VERSION} \
+    inlong/agent:${MVN_VERSION}-arm64 inlong/agent:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/dataproxy:${MVN_VERSION} \
+    inlong/dataproxy:${MVN_VERSION}-arm64 inlong/dataproxy:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/tubemq-manager:${MVN_VERSION} \
+    inlong/tubemq-manager:${MVN_VERSION}-arm64 inlong/tubemq-manager:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/tubemq-all:${MVN_VERSION} \
+    inlong/tubemq-all:${MVN_VERSION}-arm64 inlong/tubemq-all:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/tubemq-build:${MVN_VERSION} \
+    inlong/tubemq-build:${MVN_VERSION}-arm64 inlong/tubemq-build:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/dashboard:${MVN_VERSION} \
+    inlong/dashboard:${MVN_VERSION}-arm64 inlong/dashboard:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/tubemq-cpp:${MVN_VERSION} \
+    inlong/tubemq-cpp:${MVN_VERSION}-arm64 inlong/tubemq-cpp:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/audit:${MVN_VERSION} \
+    inlong/audit:${MVN_VERSION}-arm64 inlong/audit:${MVN_VERSION}-x86
+  echo "End pushing manifest"
+}
+
+help() {
+  cat <<EOF
+Usage: ./publish-by-arch.sh [option] <arch>
+where arch is one of:
+  x86
+  aarch64
+Options:
+  -b        Add build operation before publish. Build docker images by arch.
+  -t        Add tag operation before publish. Add arch after version.
+  -p        Publish images according to docker registry information.
+  -m        Push manifest. This option doesn't need arch.
+  -h        Show help information.
+Example:
+  Use "./publish-by-arch.sh -b aarch64" to publish arm images after build operation.
+  Use "./publish-by-arch.sh -t x86" to publish amd images after tag already x86 images as x86.
+EOF
+}
+
+for arg in $@

Review Comment:
   Double quote array expansions to avoid re-splitting elements.
   ```suggestion
   for arg in "$@"
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] shink commented on a diff in pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
shink commented on code in PR #4863:
URL: https://github.com/apache/inlong/pull/4863#discussion_r914601884


##########
.github/workflows/ci_docker.yml:
##########
@@ -99,13 +99,37 @@ jobs:
           fi
 
       # If only this workflow file is changed, there is no need to publish Docker images.
-      - name: Push Docker images to Docker Hub
+      - name: Push x86 Docker images to Docker Hub
         if: |
           success()
           && steps.check-workflow-diff.outputs.changed_only == 'no'
           && steps.match-branch.outputs.match == 'true'
         working-directory: docker
-        run: bash +x publish.sh
+        run: bash +x publish-by-arch.sh --tag --publish
+        env:
+          DOCKER_USER: ${{ secrets.DOCKER_USER }}
+          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
+
+      # If only this workflow file is changed, there is no need to publish Docker images.
+      - name: Push aarch64 Docker images to Docker Hub
+        if: |
+          success()
+          && steps.check-workflow-diff.outputs.changed_only == 'no'
+          && steps.match-branch.outputs.match == 'true'
+        working-directory: docker
+        run: bash +x publish-by-arch.sh --tag --buildx --publish
+        env:
+          DOCKER_USER: ${{ secrets.DOCKER_USER }}
+          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

Review Comment:
   It is recommended to use a matrix for this job [^1].
   [^1]: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] lucaspeng12138 commented on pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
lucaspeng12138 commented on PR #4863:
URL: https://github.com/apache/inlong/pull/4863#issuecomment-1173726202

   > @lucaspeng12138 do we need to remove the `publish.sh` and replace the script in CI workflows?
   
   @dockerzhang  I think this can replace `publish.sh`, I will remove the old one.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] shink commented on pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
shink commented on PR #4863:
URL: https://github.com/apache/inlong/pull/4863#issuecomment-1175036381

   @lucaspeng12138 It is recommended to update the configuration in [.github/labeler.yml](https://github.com/apache/inlong/blob/master/.github/labeler.yml#L49-L57) at same time.
   ```yaml
   docker:
     - '**/Dockerfile'
     - '**/*-docker.sh'
     - 'inlong-agent/agent-docker/**/*'
     - 'inlong-audit/audit-docker/**/*'
     - 'inlong-dataproxy/dataproxy-docker/**/*'
     - 'inlong-manager/manager-docker/**/*'
     - 'inlong-tubemq/tubemq-docker/**/*'
     - 'docker/**/*'
     - '!docker/kubernetes/**/*'
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] dockerzhang commented on a diff in pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
dockerzhang commented on code in PR #4863:
URL: https://github.com/apache/inlong/pull/4863#discussion_r913312499


##########
docker/publish-by-arch.sh:
##########
@@ -0,0 +1,248 @@
+#!/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.
+#
+
+ARCH="x86"
+NEED_BUILD=false
+NEED_TAG=false
+NEED_PUBLISH=false
+NEED_MANIFEST=false
+
+SRC_POSTFIX=""
+DES_POSTFIX="x86"
+
+SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
+
+MVN_VERSION=`python ./get-project-version.py`
+
+buildImage() {
+  echo "Start building images"
+  if [ $ARCH = "aarch64" ]; then
+    sh build-arm-docker-images.sh

Review Comment:
   `build-arm-docker-images.sh` only need the package files, and build the docker image manually, so `mvn clean install -DskipTests` is enough to use.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] shink commented on pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
shink commented on PR #4863:
URL: https://github.com/apache/inlong/pull/4863#issuecomment-1173788198

   @lucaspeng12138 It is recommended to double quote on variables. It can prevent globbing and word splitting.
   For example:
   ```shell
   # instead of `cd ${SHELL_FOLDER}`
   cd "${SHELL_FOLDER}"
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] shink commented on a diff in pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
shink commented on code in PR #4863:
URL: https://github.com/apache/inlong/pull/4863#discussion_r912982150


##########
docker/publish-by-arch.sh:
##########
@@ -0,0 +1,248 @@
+#!/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.
+#
+
+ARCH="x86"
+NEED_BUILD=false
+NEED_TAG=false
+NEED_PUBLISH=false
+NEED_MANIFEST=false
+
+SRC_POSTFIX=""
+DES_POSTFIX="x86"
+
+SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
+
+MVN_VERSION=`python ./get-project-version.py`
+
+buildImage() {
+  echo "Start building images"
+  if [ $ARCH = "aarch64" ]; then
+    sh build-arm-docker-images.sh
+  else
+    cd ${SHELL_FOLDER}
+    cd ..
+    mvn clean install -DskipTests -Pdocker
+  fi
+  echo "End building images"
+}
+
+tagImage() {
+  echo "Start tagging images"
+  if [ $ARCH = "aarch64" ]; then
+    SRC_POSTFIX="aarch64"
+    DES_POSTFIX="aarch64"
+  fi
+
+  docker tag inlong/manager:latest-${SRC_POSTFIX}      ${docker_registry_org}/manager:latest-${DES_POSTFIX}
+  docker tag inlong/agent:latest-${SRC_POSTFIX}           ${docker_registry_org}/agent:latest-${DES_POSTFIX}
+  docker tag inlong/dataproxy:latest-${SRC_POSTFIX}       ${docker_registry_org}/dataproxy:latest-${DES_POSTFIX}
+  docker tag inlong/tubemq-manager:latest-${SRC_POSTFIX}  ${docker_registry_org}/tubemq-manager:latest-${DES_POSTFIX}
+  docker tag inlong/tubemq-all:latest-${SRC_POSTFIX}      ${docker_registry_org}/tubemq-all:latest-${DES_POSTFIX}
+  docker tag inlong/tubemq-build:latest-${SRC_POSTFIX}    ${docker_registry_org}/tubemq-build:latest-${DES_POSTFIX}
+  docker tag inlong/dashboard:latest-${SRC_POSTFIX}         ${docker_registry_org}/dashboard:latest-${DES_POSTFIX}
+  docker tag inlong/tubemq-cpp:latest-${SRC_POSTFIX}      ${docker_registry_org}/tubemq-cpp:latest-${DES_POSTFIX}
+  docker tag inlong/audit:latest-${SRC_POSTFIX}      ${docker_registry_org}/audit:latest-${DES_POSTFIX}
+
+  docker tag inlong/manager:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/manager:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/agent:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/agent:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/dataproxy:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/dataproxy:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/tubemq-manager:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/tubemq-manager:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/tubemq-all:${MVN_VERSION}-${SRC_POSTFIX}  \
+  ${docker_registry_org}/tubemq-all:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/tubemq-build:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/tubemq-build:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/dashboard:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/dashboard:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/tubemq-cpp:${MVN_VERSION}-${SRC_POSTFIX} \
+    ${docker_registry_org}/tubemq-cpp:${MVN_VERSION}-${DES_POSTFIX}
+  docker tag inlong/audit:${MVN_VERSION}-${SRC_POSTFIX}  \
+    ${docker_registry_org}/audit:${MVN_VERSION}-${DES_POSTFIX}
+  echo "End tagging images"
+}
+
+publishImages() {
+  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}"
+
+  echo $DOCKER_PASSWORD | docker login ${DOCKER_REGISTRY} -u="$DOCKER_USER" --password-stdin
+  if [ $? -ne 0 ]; then
+      echo "Failed to login to ${DOCKER_REGISTRY}"
+      exit 1
+  fi
+
+  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
+
+  set -e
+
+  pushImage ${docker_registry_org}
+}
+
+pushImage() {
+  echo "Start pushing images"
+  docker_registry_org=$1
+
+  if [ $ARCH = "aarch64" ]; then
+    SRC_POSTFIX="aarch64"
+    DES_POSTFIX="arm64"
+  elif [ $NEED_TAG = true ]; then
+    SRC_POSTFIX="x86"
+  fi
+
+  docker push inlong/manager:latest-${SRC_POSTFIX}
+  docker push inlong/agent:latest-${SRC_POSTFIX}
+  docker push inlong/dataproxy:latest-${SRC_POSTFIX}
+  docker push inlong/tubemq-manager:latest-${SRC_POSTFIX}
+  docker push inlong/tubemq-all:latest-${SRC_POSTFIX}
+  docker push inlong/tubemq-build:latest-${SRC_POSTFIX}
+  docker push inlong/dashboard:latest-${SRC_POSTFIX}
+  docker push inlong/tubemq-cpp:latest-${SRC_POSTFIX}
+  docker push inlong/audit:latest-${SRC_POSTFIX}
+
+  docker push inlong/manager:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/agent:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/dataproxy:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/tubemq-manager:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/tubemq-all:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/tubemq-build:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/dashboard:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/tubemq-cpp:${MVN_VERSION}-${SRC_POSTFIX}
+  docker push inlong/audit:${MVN_VERSION}-${SRC_POSTFIX}
+
+  echo "Finished pushing images to ${docker_registry_org}"
+}
+
+pushManifest() {
+  echo "Start pushing manifest ..."
+  docker manifest create --insecure --amend inlong/manager:latest \
+    inlong/manager:latest-arm64 inlong/manager:latest-x86
+  docker manifest create --insecure --amend inlong/agent:latest \
+    inlong/agent:latest-arm64 inlong/agent:latest-x86
+  docker manifest create --insecure --amend inlong/dataproxy:latest \
+    inlong/dataproxy:latest-arm64 inlong/dataproxy:latest-x86
+  docker manifest create --insecure --amend inlong/tubemq-manager:latest \
+    inlong/tubemq-manager:latest-arm64 inlong/tubemq-manager:latest-x86
+  docker manifest create --insecure --amend inlong/tubemq-all:latest \
+    inlong/tubemq-all:latest-arm64 inlong/tubemq-all:latest-x86
+  docker manifest create --insecure --amend inlong/tubemq-build:latest \
+    inlong/tubemq-build:latest-arm64 inlong/tubemq-build:latest-x86
+  docker manifest create --insecure --amend inlong/dashboard:latest \
+    inlong/dashboard:latest-arm64 inlong/dashboard:latest-x86
+  docker manifest create --insecure --amend inlong/tubemq-cpp:latest \
+    inlong/tubemq-cpp:latest-arm64 inlong/tubemq-cpp:latest-x86
+  docker manifest create --insecure --amend inlong/audit:latest \
+    inlong/audit:latest-arm64 inlong/audit:latest-x86
+
+  docker manifest create --insecure --amend inlong/manager:${MVN_VERSION} \
+    inlong/manager:${MVN_VERSION}-arm64 inlong/manager:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/agent:${MVN_VERSION} \
+    inlong/agent:${MVN_VERSION}-arm64 inlong/agent:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/dataproxy:${MVN_VERSION} \
+    inlong/dataproxy:${MVN_VERSION}-arm64 inlong/dataproxy:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/tubemq-manager:${MVN_VERSION} \
+    inlong/tubemq-manager:${MVN_VERSION}-arm64 inlong/tubemq-manager:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/tubemq-all:${MVN_VERSION} \
+    inlong/tubemq-all:${MVN_VERSION}-arm64 inlong/tubemq-all:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/tubemq-build:${MVN_VERSION} \
+    inlong/tubemq-build:${MVN_VERSION}-arm64 inlong/tubemq-build:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/dashboard:${MVN_VERSION} \
+    inlong/dashboard:${MVN_VERSION}-arm64 inlong/dashboard:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/tubemq-cpp:${MVN_VERSION} \
+    inlong/tubemq-cpp:${MVN_VERSION}-arm64 inlong/tubemq-cpp:${MVN_VERSION}-x86
+  docker manifest create --insecure --amend inlong/audit:${MVN_VERSION} \
+    inlong/audit:${MVN_VERSION}-arm64 inlong/audit:${MVN_VERSION}-x86
+  echo "End pushing manifest"
+}
+
+help() {
+  cat <<EOF
+Usage: ./publish-by-arch.sh [option] <arch>
+where arch is one of:
+  x86
+  aarch64
+Options:
+  -b        Add build operation before publish. Build docker images by arch.
+  -t        Add tag operation before publish. Add arch after version.
+  -p        Publish images according to docker registry information.
+  -m        Push manifest. This option doesn't need arch.
+  -h        Show help information.

Review Comment:
   Would it be clearer?
   ```suggestion
     -b, --build           Add build operation before publish. Build docker images by arch.
     -t, --tag             Add tag operation before publish. Add arch after version.
     -p, --publish         Publish images according to docker registry information.
     -m, --manifest        Push manifest. This option doesn't need arch.
     -h, --help            Show help information.
   ```
   
   ```shell
     if [ "$arg" = "-b" ] || [ "$arg" = "--build" ]; then
       NEED_BUILD=true
     elif [ "$arg" = "-t" ] || [ "$arg" = "--tag" ]; then
       NEED_TAG=true
     elif [ "$arg" = "-m" ] || [ "$arg" = "--manifest" ]; then
       NEED_MANIFEST=true
     elif [ "$arg" = "-p" ] || [ "$arg" = "--publish" ]; then
       NEED_PUBLISH=true
     elif [ "$arg" = "-h" ] || [ "$arg" = "--help" ]; then
       help
       exit 0
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] shink commented on a diff in pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
shink commented on code in PR #4863:
URL: https://github.com/apache/inlong/pull/4863#discussion_r912971829


##########
docker/publish-by-arch.sh:
##########
@@ -0,0 +1,248 @@
+#!/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.
+#
+
+ARCH="x86"
+NEED_BUILD=false
+NEED_TAG=false
+NEED_PUBLISH=false
+NEED_MANIFEST=false
+
+SRC_POSTFIX=""
+DES_POSTFIX="x86"
+
+SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
+
+MVN_VERSION=`python ./get-project-version.py`

Review Comment:
   It is recommended to use `$(...)` notation instead of legacy backticked \`...\`
   ```suggestion
   MVN_VERSION=$(python ./get-project-version.py)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] dockerzhang merged pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
dockerzhang merged PR #4863:
URL: https://github.com/apache/inlong/pull/4863


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] dockerzhang commented on a diff in pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
dockerzhang commented on code in PR #4863:
URL: https://github.com/apache/inlong/pull/4863#discussion_r912926084


##########
docker/publish-by-arch.sh:
##########
@@ -0,0 +1,248 @@
+#!/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.
+#
+
+ARCH="x86"
+NEED_BUILD=false
+NEED_TAG=false
+NEED_PUBLISH=false
+NEED_MANIFEST=false
+
+SRC_POSTFIX=""
+DES_POSTFIX="x86"
+
+SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
+
+MVN_VERSION=`python ./get-project-version.py`
+
+buildImage() {
+  echo "Start building images"
+  if [ $ARCH = "aarch64" ]; then
+    sh build-arm-docker-images.sh

Review Comment:
    I think we should prepare all package files first, like using `mvn clean install -DskipTests`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] dockerzhang commented on pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
dockerzhang commented on PR #4863:
URL: https://github.com/apache/inlong/pull/4863#issuecomment-1173723960

   @lucaspeng12138 do we need to remove the `publish.sh` and replace the script in CI workflows?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] shink commented on a diff in pull request #4863: [INLONG-4862][Docker] Add publish images by arch and push manifest script

Posted by GitBox <gi...@apache.org>.
shink commented on code in PR #4863:
URL: https://github.com/apache/inlong/pull/4863#discussion_r913340040


##########
docker/publish-by-arch.sh:
##########
@@ -0,0 +1,248 @@
+#!/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.
+#
+
+ARCH="x86"
+NEED_BUILD=false
+NEED_TAG=false
+NEED_PUBLISH=false
+NEED_MANIFEST=false
+
+SRC_POSTFIX=""
+DES_POSTFIX="x86"
+
+SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
+
+MVN_VERSION=`python ./get-project-version.py`
+
+buildImage() {
+  echo "Start building images"
+  if [ $ARCH = "aarch64" ]; then
+    sh build-arm-docker-images.sh

Review Comment:
   OK. Got it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org