Skip to content

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

[#614] feat(docker): Gravitino Trino Docker image (#702)

Xun Liu2cc554510fd2
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 6d6fcb6bf8..2d461508dd 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -3,6 +3,14 @@ name: Publish Docker Image
on:
workflow_dispatch:
inputs:
+ image:
+ type: choice
+ description: 'Choose the image to build'
+ required: true
+ default: 'gravitino-ci-hive'
+ options:
+ - 'gravitino-ci-hive'
+ - 'gravitino-ci-trino'
tag:
description: 'Docker tag to apply to this image'
required: true
@@ -11,8 +19,6 @@ on:
description: 'Publish Docker token'
required: true
type: string
-env:
- HIVE_IMAGE_NAME: datastrato/gravitino-ci-hive
jobs:
publish-docker-image:
@@ -22,6 +28,16 @@ jobs:
input_token: ${{ github.event.inputs.token }}
secrets_token: ${{ secrets.PUBLISH_DOCKER_TOKEN }}
steps:
+ - name: Set environment variables
+ run: |
+ if [ "${{ github.event.inputs.image }}" == "gravitino-ci-hive" ]; then
+ echo "image_type=hive" >> $GITHUB_ENV
+ echo "image_name=datastrato/gravitino-ci-hive" >> $GITHUB_ENV
+ elif [ "${{ github.event.inputs.image }}" == "gravitino-ci-trino" ]; then
+ echo "image_type=trino" >> $GITHUB_ENV
+ echo "image_name=datastrato/gravitino-ci-trino" >> $GITHUB_ENV
+ fi
+
- uses: actions/checkout@v3
- name: Check publish Docker token
@@ -45,8 +61,7 @@ jobs:
- 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} --tag ${{ github.event.inputs.tag }} --latest
-
+ run: ./dev/docker/build-docker.sh --platform all --type ${image_type} --image ${image_name} --tag ${{ github.event.inputs.tag }} --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} --tag ${{ github.event.inputs.tag }}
+ run: ./dev/docker/build-docker.sh --platform all --type ${image_type} --image ${image_name} --tag ${{ github.event.inputs.tag }}
diff --git a/dev/docker/hive/README.md b/dev/docker/README.md
similarity index 64%
rename from dev/docker/hive/README.md
rename to dev/docker/README.md
index ce918c202a..ca06daa096 100644
--- a/dev/docker/hive/README.md
+++ b/dev/docker/README.md
@@ -2,29 +2,26 @@
Copyright 2023 Datastrato.
This software is licensed under the Apache License version 2.
-->
-# Hadoop and Hive Docker image
-This Docker image is used to support Gravitino integration testing.
-It includes Hadoop-2.x and Hive-2.x, you can use this Docker image to test the Gravitino catalog-hive module.
+# Gravitino Docker images
+This Docker image is designed to facilitate Gravitino integration testing.
+It can be utilized to test all catalog and connector modules within Gravitino.
-## Build Docker image
-```
-./build-docker.sh --platform [all|linux/amd64|linux/arm64] --image {image_name} --tag {tag_name} --latest
-```
+# Datastrato Docker hub repository
+- [Datastrato Docker hub repository address](https://hub.docker.com/r/datastrato)
-## Run container
+## How to build Docker image
```
-docker run --rm -d -p 8022:22 -p 8088:8088 -p 9000:9000 -p 9083:9083 -p 10000:10000 -p 10002:10002 -p 50070:50070 -p 50075:50075 -p 50010:50010 datastrato/gravitino-ci-hive
+./build-docker.sh --platform [all|linux/amd64|linux/arm64] --type [hive|trino] --image {image_name} --tag {tag_name} --latest
```
-## Login Docker container
+# Version change history
+## Gravitino CI Hive
+
+### Container startup commands
```
-ssh -p 8022 datastrato@localhost (password: ds123, this is a sudo user)
+docker run --rm -d -p 8022:22 -p 8088:8088 -p 9000:9000 -p 9083:9083 -p 10000:10000 -p 10002:10002 -p 50070:50070 -p 50075:50075 -p 50010:50010 datastrato/gravitino-ci-hive
```
-# Docker hub repository
-- [datastrato/gravitino-ci-hive](https://hub.docker.com/r/datastrato/gravitino-ci-hive)
-
-## Version change history
### 0.1.0
- Docker image `datastrato/gravitino-ci-hive:0.1.0`
- `hadoop-2.7.3`
@@ -62,3 +59,16 @@ ssh -p 8022 datastrato@localhost (password: ds123, this is a sudo user)
### 0.1.5
- Rollback `Map container hostname to 127.0.0.1 before starting Hadoop` of `datastrato/gravitino-ci-hive:0.1.4`
+
+## Gravitino CI Trino
+
+### Container startup commands
+```
+docker run --rm -it -p 8080:8080 datastrato/gravitino-ci-trino
+```
+
+### 0.1.0
+- Docker image `datastrato/gravitino-ci-trino:0.1.0`
+- Base on `trinodb/trino:426` and removed some unused plugins from it.
+- Expose ports:
+ - `8080` Trino JDBC port
\ No newline at end of file
diff --git a/dev/docker/build-docker.sh b/dev/docker/build-docker.sh
new file mode 100755
index 0000000000..543f53d241
--- /dev/null
+++ b/dev/docker/build-docker.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+#
+# Copyright 2023 Datastrato.
+# This software is licensed under the Apache License version 2.
+#
+set -ex
+script_dir="$(dirname "${BASH_SOURCE-$0}")"
+script_dir="$(cd "${script_dir}">/dev/null; pwd)"
+
+# Build docker image for multi-arch
+USAGE="-e Usage: ./build-docker.sh --platform [all|linux/amd64|linux/arm64] --type [hive|trino] --image {image_name} --tag {tag_name} --latest"
+
+# Get platform type
+if [[ "$1" == "--platform" ]]; then
+ shift
+ platform_type="$1"
+ if [[ "${platform_type}" == "linux/amd64" || "${platform_type}" == "linux/arm64" || "${platform_type}" == "all" ]]; then
+ echo "INFO : platform type is ${platform_type}"
+ else
+ echo "ERROR : ${platform_type} is not a valid platform type"
+ echo ${USAGE}
+ exit 1
+ fi
+ shift
+else
+ platform_type="all"
+fi
+
+# Get component type
+if [[ "$1" == "--type" ]]; then
+ shift
+ component_type="$1"
+ shift
+else
+ echo "ERROR : must specify component type"
+ echo ${USAGE}
+ exit 1
+fi
+
+# Get docker image name
+if [[ "$1" == "--image" ]]; then
+ shift
+ image_name="$1"
+ shift
+else
+ echo "ERROR : must specify image name"
+ echo ${USAGE}
+ exit 1
+fi
+
+# Get docker image tag
+if [[ "$1" == "--tag" ]]; then
+ shift
+ tag_name="$1"
+ shift
+fi
+
+# Get latest flag
+build_latest=0
+if [[ "$1" == "--latest" ]]; then
+ shift
+ build_latest=1
+fi
+
+if [[ "${component_type}" == "hive" ]]; then
+ . ${script_dir}/hive/hive-dependency.sh
+ build_args="--build-arg HADOOP_PACKAGE_NAME=${HADOOP_PACKAGE_NAME} --build-arg HIVE_PACKAGE_NAME=${HIVE_PACKAGE_NAME}"
+elif [ "${component_type}" == "trino" ]; then
+ true # Placeholder, do nothing
+else
+ echo "ERROR : ${component_type} is not a valid component type"
+ echo ${USAGE}
+ exit 1
+fi
+
+# Create multi-arch builder
+BUILDER_NAME="gravitino-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 ${BUILDER_NAME}
+fi
+
+cd ${script_dir}/${component_type}
+if [[ "${platform_type}" == "all" ]]; then
+ if [ ${build_latest} -eq 1 ]; then
+ docker buildx build --platform=linux/amd64,linux/arm64 ${build_args} --push --progress plain -f Dockerfile -t ${image_name}:latest -t ${image_name}:${tag_name} .
+ else
+ docker buildx build --platform=linux/amd64,linux/arm64 ${build_args} --push --progress plain -f Dockerfile -t ${image_name}:${tag_name} .
+ fi
+else
+ if [ ${build_latest} -eq 1 ]; then
+ docker buildx build --platform=${platform_type} ${build_args} --output type=docker --progress plain -f Dockerfile -t ${image_name}:latest -t ${image_name}:${tag_name} .
+ else
+ docker buildx build --platform=${platform_type} ${build_args} --output type=docker --progress plain -f Dockerfile -t ${image_name}:${tag_name} .
+ fi
+fi
diff --git a/dev/docker/hive/build-docker.sh b/dev/docker/hive/build-docker.sh
deleted file mode 100755
index d41d18091a..0000000000
--- a/dev/docker/hive/build-docker.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2023 Datastrato.
-# This software is licensed under the Apache License version 2.
-#
-set -ex
-bin="$(dirname "${BASH_SOURCE-$0}")"
-bin="$(cd "${bin}">/dev/null; pwd)"
-
-# Environment variables definition
-HADOOP_VERSION="2.7.3"
-HIVE_VERSION="2.3.9"
-
-HADOOP_PACKAGE_NAME="hadoop-${HADOOP_VERSION}.tar.gz"
-HADOOP_DOWNLOAD_URL="http://archive.apache.org/dist/hadoop/core/hadoop-${HADOOP_VERSION}/${HADOOP_PACKAGE_NAME}"
-
-HIVE_PACKAGE_NAME="apache-hive-${HIVE_VERSION}-bin.tar.gz"
-HIVE_DOWNLOAD_URL="https://archive.apache.org/dist/hive/hive-${HIVE_VERSION}/${HIVE_PACKAGE_NAME}"
-
-# Build docker image for multi-arch
-USAGE="-e Usage: ./build-docker.sh --platform [all|linux/amd64|linux/arm64] --image {image_name} --tag {tag_name} --latest"
-
-# Get platform type
-if [[ "$1" == "--platform" ]]; then
- shift
- platform_type="$1"
- if [[ "${platform_type}" == "linux/amd64" || "${platform_type}" == "linux/arm64" || "${platform_type}" == "all" ]]; then
- echo "INFO : platform type is ${platform_type}"
- else
- echo "ERROR : ${platform_type} is not a valid platform type"
- echo ${USAGE}
- exit 1
- fi
- shift
-else
- platform_type="all"
-fi
-
-# Get docker image name
-if [[ "$1" == "--image" ]]; then
- shift
- image_name="$1"
- shift
-else
- echo "ERROR : must specify image name"
- echo ${USAGE}
- exit 1
-fi
-
-# Get docker image tag
-if [[ "$1" == "--tag" ]]; then
- shift
- tag_name="$1"
- shift
-fi
-
-# Get latest flag
-buildLatest=0
-if [[ "$1" == "--latest" ]]; then
- shift
- buildLatest=1
-fi
-
-# Prepare download packages
-if [[ ! -d "${bin}/packages" ]]; then
- mkdir -p "${bin}/packages"
-fi
-
-if [ ! -f "${bin}/packages/${HADOOP_PACKAGE_NAME}" ]; then
- curl -s -o "${bin}/packages/${HADOOP_PACKAGE_NAME}" ${HADOOP_DOWNLOAD_URL}
-fi
-
-if [ ! -f "${bin}/packages/${HIVE_PACKAGE_NAME}" ]; then
- curl -s -o "${bin}/packages/${HIVE_PACKAGE_NAME}" ${HIVE_DOWNLOAD_URL}
-fi
-
-# Create multi-arch builder
-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 ${BUILDER_NAME}
-fi
-
-cd ${bin}
-if [[ "${platform_type}" == "all" ]]; then
- if [ ${buildLatest} -eq 1 ]; then
- docker buildx build --platform=linux/amd64,linux/arm64 --build-arg HADOOP_PACKAGE_NAME=${HADOOP_PACKAGE_NAME} --build-arg HIVE_PACKAGE_NAME=${HIVE_PACKAGE_NAME} --push --progress plain -f Dockerfile -t ${image_name}:latest -t ${image_name}:${tag_name} .
- else
- docker buildx build --platform=linux/amd64,linux/arm64 --build-arg HADOOP_PACKAGE_NAME=${HADOOP_PACKAGE_NAME} --build-arg HIVE_PACKAGE_NAME=${HIVE_PACKAGE_NAME} --push --progress plain -f Dockerfile -t ${image_name}:${tag_name} .
- fi
-else
- if [ ${buildLatest} -eq 1 ]; then
- docker buildx build --platform=${platform_type} --build-arg HADOOP_PACKAGE_NAME=${HADOOP_PACKAGE_NAME} --build-arg HIVE_PACKAGE_NAME=${HIVE_PACKAGE_NAME} --output type=docker --progress plain -f Dockerfile -t ${image_name}:latest -t ${image_name}:${tag_name} .
- else
- docker buildx build --platform=${platform_type} --build-arg HADOOP_PACKAGE_NAME=${HADOOP_PACKAGE_NAME} --build-arg HIVE_PACKAGE_NAME=${HIVE_PACKAGE_NAME} --output type=docker --progress plain -f Dockerfile -t ${image_name}:${tag_name} .
- fi
-fi
\ No newline at end of file
diff --git a/dev/docker/hive/hive-dependency.sh b/dev/docker/hive/hive-dependency.sh
new file mode 100755
index 0000000000..2e0fe6fa1a
--- /dev/null
+++ b/dev/docker/hive/hive-dependency.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Copyright 2023 Datastrato.
+# This software is licensed under the Apache License version 2.
+#
+set -ex
+hive_dir="$(dirname "${BASH_SOURCE-$0}")"
+hive_dir="$(cd "${hive_dir}">/dev/null; pwd)"
+
+# Environment variables definition
+HADOOP_VERSION="2.7.3"
+HIVE_VERSION="2.3.9"
+
+HADOOP_PACKAGE_NAME="hadoop-${HADOOP_VERSION}.tar.gz" # Must export this variable for Dockerfile
+HADOOP_DOWNLOAD_URL="http://archive.apache.org/dist/hadoop/core/hadoop-${HADOOP_VERSION}/${HADOOP_PACKAGE_NAME}"
+
+HIVE_PACKAGE_NAME="apache-hive-${HIVE_VERSION}-bin.tar.gz" # Must export this variable for Dockerfile
+HIVE_DOWNLOAD_URL="https://archive.apache.org/dist/hive/hive-${HIVE_VERSION}/${HIVE_PACKAGE_NAME}"
+
+# Prepare download packages
+if [[ ! -d "${hive_dir}/packages" ]]; then
+ mkdir -p "${hive_dir}/packages"
+fi
+
+if [ ! -f "${hive_dir}/packages/${HADOOP_PACKAGE_NAME}" ]; then
+ curl -s -o "${hive_dir}/packages/${HADOOP_PACKAGE_NAME}" ${HADOOP_DOWNLOAD_URL}
+fi
+
+if [ ! -f "${hive_dir}/packages/${HIVE_PACKAGE_NAME}" ]; then
+ curl -s -o "${hive_dir}/packages/${HIVE_PACKAGE_NAME}" ${HIVE_DOWNLOAD_URL}
+fi
diff --git a/dev/docker/trino/Dockerfile b/dev/docker/trino/Dockerfile
new file mode 100644
index 0000000000..5f1d35d666
--- /dev/null
+++ b/dev/docker/trino/Dockerfile
@@ -0,0 +1,47 @@
+#
+# Copyright 2023 Datastrato.
+# This software is licensed under the Apache License version 2.
+#
+FROM trinodb/trino:426
+LABEL maintainer="[email protected]"
+
+# Only mysql, hudi, iceberg, mariadb, jmx, memory, tpch, tpcds, hive plugin are kept
+RUN rm -rf /usr/lib/trino/plugin/accumulo \
+ && rm -rf /usr/lib/trino/plugin/blackhole \
+ && rm -rf /usr/lib/trino/plugin/delta-lake \
+ && rm -rf /usr/lib/trino/plugin/example-http \
+ && rm -rf /usr/lib/trino/plugin/geospatial \
+ && rm -rf /usr/lib/trino/plugin/kafka \
+ && rm -rf /usr/lib/trino/plugin/local-file \
+ && rm -rf /usr/lib/trino/plugin/ml \
+ && rm -rf /usr/lib/trino/plugin/mysql-event-listener \
+ && rm -rf /usr/lib/trino/plugin/phoenix5 \
+ && rm -rf /usr/lib/trino/plugin/prometheus \
+ && rm -rf /usr/lib/trino/plugin/redshift \
+ && rm -rf /usr/lib/trino/plugin/singlestore \
+ && rm -rf /usr/lib/trino/plugin/thrift \
+ && rm -rf /usr/lib/trino/plugin/atop \
+ && rm -rf /usr/lib/trino/plugin/cassandra \
+ && rm -rf /usr/lib/trino/plugin/druid \
+ && rm -rf /usr/lib/trino/plugin/exchange-filesystem \
+ && rm -rf /usr/lib/trino/plugin/google-sheets \
+ && rm -rf /usr/lib/trino/plugin/http-event-listener \
+ && rm -rf /usr/lib/trino/plugin/ignite \
+ && rm -rf /usr/lib/trino/plugin/kinesis \
+ && rm -rf /usr/lib/trino/plugin/mongodb \
+ && rm -rf /usr/lib/trino/plugin/oracle \
+ && rm -rf /usr/lib/trino/plugin/pinot \
+ && rm -rf /usr/lib/trino/plugin/raptor-legacy \
+ && rm -rf /usr/lib/trino/plugin/resource-group-managers \
+ && rm -rf /usr/lib/trino/plugin/sqlserver \
+ && rm -rf /usr/lib/trino/plugin/bigquery \
+ && rm -rf /usr/lib/trino/plugin/clickhouse \
+ && rm -rf /usr/lib/trino/plugin/elasticsearch \
+ && rm -rf /usr/lib/trino/plugin/exchange-hdfs \
+ && rm -rf /usr/lib/trino/plugin/hudi \
+ && rm -rf /usr/lib/trino/plugin/kudu \
+ && rm -rf /usr/lib/trino/plugin/password-authenticators \
+ && rm -rf /usr/lib/trino/plugin/postgresql \
+ && rm -rf /usr/lib/trino/plugin/redis \
+ && rm -rf /usr/lib/trino/plugin/session-property-managers \
+ && rm -rf /usr/lib/trino/plugin/teradata-functions
diff --git a/docs/assets/publish-docker-image.png b/docs/assets/publish-docker-image.png
index 563773109f..4f4c63eed7 100644
Binary files a/docs/assets/publish-docker-image.png and b/docs/assets/publish-docker-image.png differ
diff --git a/docs/publish-docker-images.md b/docs/publish-docker-images.md
index 1b18cef86a..3ca07597b3 100644
--- a/docs/publish-docker-images.md
+++ b/docs/publish-docker-images.md
@@ -18,21 +18,19 @@ We use Github Actions to publish the docker images to the DockerHub repository.
1. Open the <https://github.com/datastrato/gravitino/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 the specified tag and the `latest` tag.
+3. Select the branch you want to build
+ + If you select `main` branch, the docker image will be published with the specified tag and the `latest` tag.
+ If you select another branch, the docker image will only publish the specified tag.
-
+4. Choose the image you want to build
+ + `datastrato/gravitino-ci-hive`.
+ + `datastrato/gravitino-ci-trino`.
+ + Other data sources will be supported in the future.
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, only the `hive` docker image is supported, for example: `datastrato/gravitino-ci-hive`.
- + Publishing other data sources, for example, `Iceberg` docker image will be supported 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.
![Publish Docker Image](assets/publish-docker-image.png)
-## The Version of the Data Source
+## The Version of Gravitino Docker images
-+ [gravitino-ci-hive](../dev/docker/hive/README.md)
++ [Gravitino Docker images](../dev/docker/README.md)