Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#312] docker: Publish Docker image operation Action (#313)

Xun Liu89d3878665d1
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
new file mode 100644
index 0000000000..b8949c4cb9
--- /dev/null
+++ b/.github/workflows/docker-image.yml
@@ -0,0 +1,52 @@
+name: Docker Image
+
+on:
+ workflow_dispatch:
+ inputs:
+ tag:
+ description: 'Docker tag to apply to this image'
+ required: true
+ type: string
+ token:
+ description: 'Publish Docker token'
+ required: true
+ type: string
+env:
+ HIVE_IMAGE_NAME: datastrato/graviton-ci-hive
+
+jobs:
+ publish-docker-image:
+ runs-on: ubuntu-latest
+ timeout-minutes: 60
+ env:
+ input_token: ${{ github.event.inputs.token }}
+ secrets_token: ${{ secrets.PUBLISH_DOCKER_TOKEN }}
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Check release token
+ run: |
+ if [[ "${secrets_token}" != "${input_token}" ]]; then
+ echo "The token you entered is incorrect. Please try again."
+ exit 1
+ fi
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v2
+ with:
+ username: datastrato
+ password: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }}
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+
+ - name: Build and Push the main branch Docker image
+ if: ${{ github.ref_name == 'main' }}
+ run: ./dev/docker/hive/build-docker.sh --platform all --image ${HIVE_IMAGE_NAME}:${{ github.event.inputs.tag }} --tag ${HIVE_IMAGE_NAME}:latest
+
+ - name: Build and Push the other branch Docker image
+ if: ${{ github.ref_name != 'main' }}
+ run: ./dev/docker/hive/build-docker.sh --platform all --image ${HIVE_IMAGE_NAME}:${{ github.event.inputs.tag }}
diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml
index 0fc23e5345..26ea0d7e54 100644
--- a/.github/workflows/integration-test.yml
+++ b/.github/workflows/integration-test.yml
@@ -9,8 +9,8 @@ on:
branches: [ "main", "branch-*" ]
env:
- HIVE2_IMAGE_NAME: datastrato/hive2
- HIVE2_IMAGE_TAG_NAME: 0.1.0
+ HIVE_IMAGE_NAME: datastrato/graviton-ci-hive
+ HIVE_IMAGE_TAG_NAME: 0.1.0
concurrency:
group: ${{ github.worklfow }}-${{ github.event.pull_request.number || github.ref }}
@@ -25,7 +25,7 @@ jobs:
matrix:
architecture: [linux/amd64]
env:
- DOCKER_RUN_NAME: hive2-amd64
+ DOCKER_RUN_NAME: hive-amd64
PLATFORM: ${{ matrix.architecture }}
steps:
- uses: actions/checkout@v3
@@ -41,13 +41,13 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- - name: Build the hive2 Docker image for AMD64
+ - name: Build the hive Docker image for AMD64
if: ${{ contains(github.event.pull_request.labels.*.name, 'build docker image') }}
- run: ./dev/docker/hive2/build-docker.sh --platform ${PLATFORM} --image ${HIVE2_IMAGE_NAME}:${HIVE2_IMAGE_TAG_NAME}
+ run: ./dev/docker/hive/build-docker.sh --platform ${PLATFORM} --image ${HIVE_IMAGE_NAME}:${HIVE_IMAGE_TAG_NAME}
- name: Run AMD64 container
run: |
- docker run --rm --name ${DOCKER_RUN_NAME} --platform ${PLATFORM} -d -p 8088:8088 -p 50070:50070 -p 50075:50075 -p 10000:10000 -p 10002:10002 -p 8888:8888 -p 9083:9083 -p 8022:22 ${HIVE2_IMAGE_NAME}:${HIVE2_IMAGE_TAG_NAME}
+ docker run --rm --name ${DOCKER_RUN_NAME} --platform ${PLATFORM} -d -p 8088:8088 -p 50070:50070 -p 50075:50075 -p 10000:10000 -p 10002:10002 -p 8888:8888 -p 9083:9083 -p 8022:22 ${HIVE_IMAGE_NAME}:${HIVE_IMAGE_TAG_NAME}
docker ps -a
- name: Setup Gradle
@@ -86,4 +86,4 @@ jobs:
docker stop ${DOCKER_RUN_NAME}
sleep 3
docker ps -a
- docker rmi ${HIVE2_IMAGE_NAME}:${HIVE2_IMAGE_TAG_NAME}
\ No newline at end of file
+ docker rmi ${HIVE_IMAGE_NAME}:${HIVE_IMAGE_TAG_NAME}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index d4f0649c5a..9eb2d6567a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,4 +36,4 @@ out/**
distribution
server/src/main/resources/project.properties
-dev/docker/hive2/packages
\ No newline at end of file
+dev/docker/hive/packages
\ No newline at end of file
diff --git a/dev/docker/hive2/Dockerfile b/dev/docker/hive/Dockerfile
similarity index 100%
rename from dev/docker/hive2/Dockerfile
rename to dev/docker/hive/Dockerfile
diff --git a/dev/docker/hive2/README.md b/dev/docker/hive/README.md
similarity index 92%
rename from dev/docker/hive2/README.md
rename to dev/docker/hive/README.md
index 61a5193622..e449564c9e 100644
--- a/dev/docker/hive2/README.md
+++ b/dev/docker/hive/README.md
@@ -11,7 +11,7 @@ Build Image
Run container
=============
-docker run --rm -d -p 8088:8088 -p 50070:50070 -p 50075:50075 -p 10000:10000 -p 10002:10002 -p 8888:8888 -p 9083:9083 -p 8022:22 datastrato/hive2:0.1.0
+docker run --rm -d -p 8088:8088 -p 50070:50070 -p 50075:50075 -p 10000:10000 -p 10002:10002 -p 8888:8888 -p 9083:9083 -p 8022:22 datastrato/graviton-ci-hivehive:0.1.0
Login to the server
=============
diff --git a/dev/docker/hive2/build-docker.sh b/dev/docker/hive/build-docker.sh
similarity index 97%
rename from dev/docker/hive2/build-docker.sh
rename to dev/docker/hive/build-docker.sh
index 3b3d959e77..8c9d536cd1 100755
--- a/dev/docker/hive2/build-docker.sh
+++ b/dev/docker/hive/build-docker.sh
@@ -8,9 +8,9 @@ bin="$(dirname "${BASH_SOURCE-$0}")"
bin="$(cd "${bin}">/dev/null; pwd)"
# Environment variables definition
-IMAGE_NAME="datastrato/hive2:0.1.0"
HADOOP_VERSION="2.7.3"
HIVE_VERSION="2.3.9"
+IMAGE_NAME="datastrato/hive:0.1.0"
HADOOP_PACKAGE_NAME="hadoop-${HADOOP_VERSION}.tar.gz"
HADOOP_DOWNLOAD_URL="http://archive.apache.org/dist/hadoop/core/hadoop-${HADOOP_VERSION}/${HADOOP_PACKAGE_NAME}"
@@ -69,13 +69,13 @@ if [ ! -f "${bin}/packages/${HIVE_PACKAGE_NAME}" ]; then
fi
# Create multi-arch builder
-BUILDER_NAME="hive2"
+BUILDER_NAME="hive-builder"
builders=$(docker buildx ls)
if echo "${builders}" | grep -q "${BUILDER_NAME}"; then
echo "BuildKit builder '${BUILDER_NAME}' already exists."
else
echo "BuildKit builder '${BUILDER_NAME}' does not exist."
- docker buildx create --platform linux/amd64,linux/arm64 --use --name hive2
+ docker buildx create --platform linux/amd64,linux/arm64 --use --name ${BUILDER_NAME}
fi
cd ${bin}
diff --git a/dev/docker/hive2/core-site.xml b/dev/docker/hive/core-site.xml
similarity index 100%
rename from dev/docker/hive2/core-site.xml
rename to dev/docker/hive/core-site.xml
diff --git a/dev/docker/hive2/hadoop-env.sh b/dev/docker/hive/hadoop-env.sh
similarity index 100%
rename from dev/docker/hive2/hadoop-env.sh
rename to dev/docker/hive/hadoop-env.sh
diff --git a/dev/docker/hive2/hdfs-site.xml b/dev/docker/hive/hdfs-site.xml
similarity index 100%
rename from dev/docker/hive2/hdfs-site.xml
rename to dev/docker/hive/hdfs-site.xml
diff --git a/dev/docker/hive2/hive-site.xml b/dev/docker/hive/hive-site.xml
similarity index 100%
rename from dev/docker/hive2/hive-site.xml
rename to dev/docker/hive/hive-site.xml
diff --git a/dev/docker/hive2/mapred-site.xml b/dev/docker/hive/mapred-site.xml
similarity index 100%
rename from dev/docker/hive2/mapred-site.xml
rename to dev/docker/hive/mapred-site.xml
diff --git a/dev/docker/hive2/start.sh b/dev/docker/hive/start.sh
similarity index 100%
rename from dev/docker/hive2/start.sh
rename to dev/docker/hive/start.sh
diff --git a/dev/docker/hive2/yarn-site.xml b/dev/docker/hive/yarn-site.xml
similarity index 100%
rename from dev/docker/hive2/yarn-site.xml
rename to dev/docker/hive/yarn-site.xml
diff --git a/docs/assets/publish-docker-image.png b/docs/assets/publish-docker-image.png
new file mode 100644
index 0000000000..563773109f
Binary files /dev/null and b/docs/assets/publish-docker-image.png differ
diff --git a/docs/integration-test.md b/docs/integration-test.md
index 0a5b43df77..35d1eb420c 100644
--- a/docs/integration-test.md
+++ b/docs/integration-test.md
@@ -14,7 +14,7 @@ You can view the test results in the `Actions` tab of the pull request page.
The integration tests are executed in the following steps:
1. If you set the `build docker image` label in the pull request, GitHub Actions will trigger the build of all Docker images under the `./dev/docker/` directory. This step usually takes around 10 minutes. If you have made changes to the Dockerfile, you need to set the `build docker image` label in the pull request.
-2. If you do not set the `build docker image` label in the pull request, GitHub Actions will pull the Docker image `datastrato/hive2:latest` from the Docker Hub repository. This step usually takes around 15 seconds.
+2. If you do not set the `build docker image` label in the pull request, GitHub Actions will pull the Docker image `datastrato/graviton-ci-hive:latest` from the Docker Hub repository. This step usually takes around 15 seconds.
3. The Docker image is then run in the GitHub Actions environment.
4. If you set the `debug action` label in the pull request, GitHub Actions will run an SSH server with `csexton/debugger-action@master`, allowing you to remotely log in to the Actions environment for debugging purposes.
5. The Graviton project is compiled and packaged in the `distribution` directory using the `./gradlew compileDistribution` command.
@@ -27,7 +27,7 @@ Before running the tests, make sure Docker is installed.
Then, execute blow steps:
1. Execute the `./gradlew clean build` command to build Graviton project.
2. The Graviton project is compiled and packaged in the `distribution` directory using the `./gradlew compileDistribution` command.
-3. Run a hive2 docker container in the local using the `docker run --rm -d -p 8088:8088 -p 50070:50070 -p 50075:50075 -p 10000:10000 -p 10002:10002 -p 8888:8888 -p 9083:9083 -p 8022:22 datastrato/hive2:0.1.0` command.
+3. Run a hive docker test environment container in the local using the `docker run --rm -d -p 8088:8088 -p 50070:50070 -p 50075:50075 -p 10000:10000 -p 10002:10002 -p 8888:8888 -p 9083:9083 -p 8022:22 datastrato/graviton-ci-hive:0.1.0` command.
4. The integration test cases in the `integration-test` module are executed using the `./gradlew integrationTest` command.
Additionally, the Graviton Server and third-party data source Docker runtime environments will use certain ports. Ensure that these ports are not already in use:
diff --git a/docs/publish-docker-image.md b/docs/publish-docker-image.md
new file mode 100644
index 0000000000..fd1dd31d43
--- /dev/null
+++ b/docs/publish-docker-image.md
@@ -0,0 +1,35 @@
+<!--
+ Copyright 2023 Datastrato.
+ This software is licensed under the Apache License version 2.
+-->
+# How to Publish Docker images
+
+## Introduction
+The Graviton project provides a set of docker images to facilitate the publish, development and testing of the Graviton project.
+The Graviton official docker images are published to the [datastrato](https://hub.docker.com/u/datastrato) DockerHub repository.
+
+## Publish Docker Images to Docker Hub Flow
+
+We use Github Actions to publish the docker images to the DockerHub repository.
+1. Open the https://github.com/datastrato/graviton/actions/workflows/docker-image.yml
+2. Click the `Run workflow` button.
+3. Select the branch you want to publish.
+
+ + If you select `main` branch, the docker image will be published same to specified tag and the `latest` tag.
+
+ + If you select another branch, the docker image will only publish the specified tag.
+
+4. Input the `tag name`, for example: `0.1.0`, Then build and push the docker image name is `datastrato/{image-name}:0.1.0`.
+
+ + Currently, we only support publishing the `hive` docker image, for example: `datastrato/graviton-ci-hive:0.1.0`.
+ + We will support publishing other data sources, for example, `Iecberg` docker image in the future.
+
+5. You must enter the correct `publish docker token` before you can execute run `Publish Docker Image` workflow.
+6. Wait for the workflow to complete. You can see a new docker image shown in the [datastrato](https://hub.docker.com/u/datastrato) DockerHub repository.
+
+[<img src="assets/publish-docker-image.png" width="400"/>](assets/publish-docker-image.png)
+
+## The version of the Data source in the Docker image
+| Docker image name | Docker image tag | Data source version |
+|-------------------|------------------|--------------------------|
+| graviton-ci-hive | 0.1.0 | hadoop-2.7.3, hive-2.3.9 |