builders:
- inject:
properties-content: |
- DOCKER_NAME={docker-name}
DOCKER_ROOT={docker-root}
- conditional-step:
condition-kind: regex-match
- inject:
properties-content: |
DOCKER_ARGS={docker-build-args}
+ DOCKER_NAME={docker-name}
DOCKER_ROOT={docker-root}
CONTAINER_PULL_REGISTRY={container-public-registry}
+ CONTAINER_PUSH_REGISTRY={container-push-registry}
- shell: !include-raw-escape:
- ../shell/docker-build.sh
- shell: '{pre_docker_build_script}'
- lf-docker-get-container-tag:
docker-use-params-from: '{docker-use-params-from}'
- docker-name: '{docker-name}'
docker-root: '{docker-root}'
- lf-docker-build:
docker-build-args: '{docker-build-args}'
+ docker-name: '{docker-name}'
docker-root: '{docker-root}'
container-public-registry: '{container-public-registry}'
+ container-push-registry: '{container-push-registry}'
- shell: '{post_docker_build_script}'
- lf-provide-maven-settings-cleanup
- shell: '{pre_docker_build_script}'
- lf-docker-get-container-tag:
docker-use-params-from: '{docker-use-params-from}'
- docker-name: '{docker-name}'
docker-root: '{docker-root}'
- lf-docker-build:
docker-build-args: '{docker-build-args}'
+ docker-name: '{docker-name}'
docker-root: '{docker-root}'
container-public-registry: '{container-public-registry}'
+ container-push-registry: '{container-push-registry}'
- shell: '{post_docker_build_script}'
# Provided all steps have already passed, push the docker image
- lf-docker-push:
--- /dev/null
+---
+fixes:
+ - |
+ Allow DOCKER_ARGS to be empty in docker-build.sh. This is not a
+ required parameter, it can be empty.
+
+ Remove container reference in docker-get-git-describe.sh. The
+ CONTAINER_PUSH_REGISTRY already gets added in the docker-push script.
+ No need to add it again.
+
+ Rename image_name to image_build_tag in docker-get-yaml-tag to match
+ docker-get-git-describe. Add missing "DOCKER_NAME" in the DOCKER_IMAGE.
+
+ docker-get-git-describe.sh and docker-get-yaml-tag.sh should only export
+ the tag variable. Let docker-build.sh process DOCKER_NAME
# Docker image build script
set -eu -o pipefail
-
+echo "---> Building image: $CONTAINER_PUSH_REGISTRY/$DOCKER_NAME:$DOCKER_IMAGE_TAG"
cd "$DOCKER_ROOT"
-# DOCKER_IMAGE variable gets constructed after lf-docker-get-container-tag builder step
+# DOCKER_IMAGE_TAG variable gets constructed after lf-docker-get-container-tag builder step
# is executed. It constructs the image name and the appropriate tag in the same varaiable.
-docker build "$DOCKER_ARGS" . -t "$DOCKER_IMAGE" | tee "$WORKSPACE/docker_build_log.txt"
+docker_build_command="docker build ${DOCKER_ARGS:-} -t "$CONTAINER_PUSH_REGISTRY/$DOCKER_NAME:$DOCKER_IMAGE_TAG" ."
+echo $docker_build_command
+eval $docker_build_command | tee "$WORKSPACE/docker_build_log.txt"
then
echo "git describe returned an empty value, make sure a version tag is applied"
exit 1
-else
- image_name="$CONTAINER_PUSH_REGISTRY/$DOCKER_NAME:$image_build_tag"
fi
-
-# Write DOCKER_IMAGE information to a file so it can be injected into the
+echo "---> Tag found: $image_build_tag"
+# Write DOCKER_IMAGE_TAG information to a file so it can be injected into the
# environment for following steps
-echo "DOCKER_IMAGE=$image_name" >> "$WORKSPACE/env_docker_inject.txt"
+echo "DOCKER_IMAGE_TAG=$image_build_tag" >> "$WORKSPACE/env_docker_inject.txt"
if [ -f "$container_tag_file" ]
then
- image_name=$(yq -r .tag "$container_tag_file")
+ image_build_tag=$(yq -r .tag "$container_tag_file")
else
echo "$container_tag_file file not found. Make sure this file exists."
exit 1
fi
-
-# Write DOCKER_IMAGE information to a file so it can be injected into the
+echo "---> Tag found: $image_build_tag"
+# Write DOCKER_IMAGE_TAG information to a file so it can be injected into the
# environment for following steps
-echo "DOCKER_IMAGE=$image_name" >> "$WORKSPACE/env_docker_inject.txt"
+echo "DOCKER_IMAGE_TAG=$image_build_tag" >> "$WORKSPACE/env_docker_inject.txt"
# Ensure we fail the job if any steps fail
set -ue -o pipefail
-
-docker push "$CONTAINER_PUSH_REGISTRY/$DOCKER_IMAGE"
+echo "---> Pushing image: $CONTAINER_PUSH_REGISTRY/$DOCKER_NAME:$DOCKER_IMAGE_TAG"
+docker_push_command="docker push "$CONTAINER_PUSH_REGISTRY/$DOCKER_NAME:$DOCKER_IMAGE_TAG""
+echo $docker_push_command
+eval $docker_push_command