Skip to content

Commit

Permalink
Build and push to spotify trino gcr (trinodb#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
narape authored and GitHub Enterprise committed Jul 10, 2023
1 parent 8274f26 commit eee7463
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ ij_java_doc_align_param_comments = false

[*.yml]
indent_size = 2

[*.yaml]
indent_size = 2
80 changes: 80 additions & 0 deletions build-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
version: "2"
timeout: 30
useBuildIndentity: true

definitions:
- &mvn "gcr.io/action-containers/mvn-java17:3.9.1-19@sha256:79893d426f1852abab335a53fa039223f053a3735a312de67bca2adf662a9e30"

pipelines:
- pipeline: "Review build"
ref: 'pr/.*/merge'
stages:
- stage: "Build trino jars"
tasks:
- task: Build trino jars
steps:
- action: *mvn
args:
- 'clean'
- 'install'
- '-B'
- '--strict-checksums'
- '-V'
- '-T'
- '1C'
- '-DskipTests'
- '-pl'
- '!:trino-docs'
- stage: "Build docker image"
tasks:
- task: Docker-build
steps:
- action: *mvn
entrypoint: '/bin/bash'
workdir: 'core/docker'
args:
- '-c'
- './build.sh'
- '-a'
- 'amd64'
- pipeline: "Master build"
ref: "refs/heads/(main|master)"
stages:
- stage: "Build trino jars"
tasks:
- task: Build trino jars
steps:
- action: *mvn
args:
- 'clean'
- 'install'
- '-B'
- '--strict-checksums'
- '-V'
- '-T'
- '1C'
- '-DskipTests'
- '-pl'
- '!:trino-docs'
- stage: "Build docker image"
tasks:
- task: Docker-build
steps:
- action: *mvn
entrypoint: '/bin/bash'
workdir: 'core/docker'
args:
- '-c'
- './build.sh'
- '-a'
- 'amd64'
- stage: "Push docker image"
tasks:
- task: Docker-build
steps:
- action: *mvn
workdir: 'core/docker'
entrypoint: '/bin/bash'
args:
- '-c'
- './push.sh'
3 changes: 2 additions & 1 deletion core/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ source container-test.sh
for arch in "${ARCHITECTURES[@]}"; do
# TODO: remove when https://github.com/multiarch/qemu-user-static/issues/128 is fixed
if [[ "$arch" != "ppc64le" ]]; then
test_container "${TAG_PREFIX}-$arch" "linux/$arch"
echo "⏭️ Skipping verification ${TAG_PREFIX}-$arch linux/$arch"
# test_container "${TAG_PREFIX}-$arch" "linux/$arch"
fi
docker image inspect -f '🚀 Built {{.RepoTags}} {{.Id}}' "${TAG_PREFIX}-$arch"
done
56 changes: 56 additions & 0 deletions core/docker/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
set -eox pipefail

get_commit_sha() {
if [[ -n "${COMMIT_SHA}" ]] ; then
echo >&2 using COMMIT_SHA variable
echo "${COMMIT_SHA}"
return 0
fi
if [[ -f .git/refs/heads/master ]]; then
echo >&2 using .git/refs/heads/master
head -n1 .git/refs/heads/master
return 0
elif [[ -f .git/HEAD ]]; then
echo >&2 using .git/HEAD
cat .git/HEAD
return 0
else
echo >&2 "Error: Expected a git repo but couldn't find .git/refs/heads/master"
exit 2
fi
}

## Based on https://ghe.spotify.net/action-containers/docker-builder/blob/2c374304be91e1cebcd1778bd0452cf3d2a28f0a/containerfs/usr/bin/entrypoint.sh
## but skipping the build part as that it is done on
SOURCE_DIR="../.."
GCP_PROJECT_ID="spotify-trino"
ORIGINAL_IMAGE_NAME="trino"
NEW_IMAGE_NAME="custom-trino"

## Optional vars
if [ -z "$TRINO_VERSION" ]; then
TRINO_VERSION=$("${SOURCE_DIR}/mvnw" -f "${SOURCE_DIR}/pom.xml" --quiet help:evaluate -Dexpression=project.version -DforceStdout)
fi

arch=${ARCH:-amd64}
TAG_PREFIX="${TRINO_VERSION}"
BUILT_IMAGE_TAG="${TAG_PREFIX}-$arch"

if [[ -z "${EXPANDED_IMAGE_TAG}" ]]; then
sha=$(get_commit_sha | cut -c 1-8)
timestamp=$(date +%Y%m%d%H%M%S)
EXPANDED_IMAGE_TAG="${BUILT_IMAGE_TAG}-${timestamp}-${sha}"
fi

full_image_name="${IMAGE_REGISTRY:-"eu.gcr.io"}/${GCP_PROJECT_ID}/${NEW_IMAGE_NAME}"
full_image_name_with_tag="${full_image_name}:${EXPANDED_IMAGE_TAG}"

echo "🏷️ Retagging: ${ORIGINAL_IMAGE_NAME}:${BUILT_IMAGE_TAG} as ${full_image_name_with_tag}"
docker tag ${ORIGINAL_IMAGE_NAME}:${BUILT_IMAGE_TAG} ${full_image_name_with_tag}

echo "🚀 Pusing: ${full_image_name_with_tag}"
docker push "${full_image_name_with_tag}"

docker rmi "${full_image_name_with_tag}"

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<air.check.skip-jacoco>true</air.check.skip-jacoco>

<project.build.targetJdk>17</project.build.targetJdk>
<air.java.version>17.0.4</air.java.version>
<air.java.version>17.0.6</air.java.version>
<air.modernizer.java-version>8</air.modernizer.java-version>

<air.release.preparation-goals>clean verify -DskipTests</air.release.preparation-goals>
Expand Down

0 comments on commit eee7463

Please sign in to comment.