Skip to content

Commit

Permalink
RHINENG-9414 use tmp dir for docker config (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
r14chandra authored Apr 11, 2024
1 parent 33bfc4d commit 1d55e41
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,24 @@ if [[ -z "$QUAY_USER" || -z "$QUAY_TOKEN" ]]; then
exit 1
fi

DOCKER_CONF="$PWD/.docker"
# Create tmp dir to store data in during job run (do NOT store in $WORKSPACE)
export TMP_JOB_DIR=$(mktemp -d -p "$HOME" -t "jenkins-${JOB_NAME}-${BUILD_NUMBER}-XXXXXX")
echo "job tmp dir location: $TMP_JOB_DIR"

function job_cleanup() {
echo "cleaning up job tmp dir: $TMP_JOB_DIR"
rm -fr $TMP_JOB_DIR
}

trap job_cleanup EXIT ERR SIGINT SIGTERM

DOCKER_CONF="$TMP_JOB_DIR/.docker"

mkdir -p "$DOCKER_CONF"

docker login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
docker build -t "${IMAGE}:${IMAGE_TAG}" .
docker tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:latest"
docker --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
docker --config="$DOCKER_CONF" build -t "${IMAGE}:${IMAGE_TAG}" .
docker --config="$DOCKER_CONF" tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:latest"

docker push "${IMAGE}:${IMAGE_TAG}"
docker push "${IMAGE}:latest"
docker --config="$DOCKER_CONF" push "${IMAGE}:${IMAGE_TAG}"
docker --config="$DOCKER_CONF" push "${IMAGE}:latest"

0 comments on commit 1d55e41

Please sign in to comment.