From 3adc221ab75af040526f25dd006548db3519d6cf Mon Sep 17 00:00:00 2001 From: Michael Skarbek Date: Wed, 10 Apr 2024 17:01:53 -0400 Subject: [PATCH] [COST-4899] add .dockerignore file (#74) * [COST-4899] add .dockerignore file * [COST-4899] create tmp dir for build-deploy --- .dockerignore | 5 +++++ build_deploy.sh | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..65d6b74 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +# Ignore everything +** + +# ... except for dependencies and source +!default/ diff --git a/build_deploy.sh b/build_deploy.sh index 4d6e718..7434eff 100755 --- a/build_deploy.sh +++ b/build_deploy.sh @@ -15,7 +15,18 @@ 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 --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io docker --config="$DOCKER_CONF" build -t "${IMAGE}:${IMAGE_TAG}" ${SCRIPT_DIR}