forked from trinodb/trino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build and push to spotify trino gcr (trinodb#3)
- Loading branch information
Showing
5 changed files
with
142 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ ij_java_doc_align_param_comments = false | |
|
||
[*.yml] | ||
indent_size = 2 | ||
|
||
[*.yaml] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters