-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We have support to build the image for branches and tags
- Loading branch information
Showing
3 changed files
with
34 additions
and
1 deletion.
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
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,25 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
|
||
echo "Build hook is running. IMAGE_NAME=${IMAGE_NAME}, DOCKER_REPO=${DOCKER_REPO}, CACHE_TAG=${CACHE_TAG}, DOCKERFILE_PATH=${DOCKERFILE_PATH}" | ||
|
||
# Pull the image for image currently built if it exists | ||
docker pull ${IMAGE_NAME} || true | ||
|
||
# Pull the image for latest build if it exists | ||
docker pull ${DOCKER_REPO}:latest || true | ||
|
||
if [[ ${CACHE_TAG} == "latest-clean" || ${CACHE_TAG} =~ "release.*" ]]; then | ||
echo "Disabling cache" | ||
CACHE_SPEC="--no-cache" | ||
else | ||
echo "Enabling cache" | ||
CACHE_SPEC="--cache-from ${IMAGE_NAME} --cache-from ${DOCKER_REPO}:latest" | ||
fi | ||
|
||
# Build the image using cached versions if present - both the branch/tag version and latest build can be used | ||
# as cache source - docker will choose appropriate cache based on hashes of the files changed | ||
docker build --pull --build-arg AIRFLOW_TAG=${CACHE_TAG} -f ${DOCKERFILE_PATH} -t ${IMAGE_NAME} \ | ||
${CACHE_SPEC} . | ||
|
||
echo "Build finished" |
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