Skip to content

Commit

Permalink
use temp directory for docker config
Browse files Browse the repository at this point in the history
  • Loading branch information
petracihalova committed Dec 17, 2024
1 parent 66ac71d commit de3fcda
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ IMAGE_TAG=$(git rev-parse --short=7 HEAD)

docker build -t "${IMAGE}:${IMAGE_TAG}" .

# 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

if [[ -n "$QUAY_USER" && -n "$QUAY_TOKEN" ]]; then
DOCKER_CONF="$PWD/.docker"
DOCKER_CONF="$TMP_JOB_DIR/.docker"
mkdir -p "$DOCKER_CONF"
docker --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
docker --config="$DOCKER_CONF" push "${IMAGE}:${IMAGE_TAG}"
Expand Down

0 comments on commit de3fcda

Please sign in to comment.