Skip to content

Commit

Permalink
build_docker_remote: add ability to specify the RELEASE arg to the cl…
Browse files Browse the repository at this point in the history
…oud-based docker build
  • Loading branch information
droazen committed Mar 17, 2023
1 parent 2dbc025 commit 040a147
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions build_docker_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ STAGING_CLONE_DIR=${PROJECT}_staging_temp
#################################################
# Parsing arguments
#################################################
while getopts "e:sd:t:" option; do
while getopts "e:sd:t:r" option; do
case "$option" in
e) GITHUB_TAG="$OPTARG" ;;
s) IS_HASH=true ;;
d) STAGING_DIR="$OPTARG" ;;
t) DOCKER_IMAGE_TAG="$OPTARG" ;;
r) RELEASE=true ;;
esac
done

Expand Down Expand Up @@ -81,9 +82,22 @@ if [ -z "$DOCKER_IMAGE_TAG" ]; then
DOCKER_IMAGE_TAG=${GCR_REPO}:$(whoami)-${GITHUB_TAG}-${GIT_HASH_FOR_TAG}
fi

if [ -n "$RELEASE" ]; then
echo "steps:" >> cloudbuild.yaml
echo "- name: 'gcr.io/cloud-builders/docker'" >> cloudbuild.yaml
echo " args: [ 'build', '-t', '${DOCKER_IMAGE_TAG}', '--build-arg', 'RELEASE=true', '.' ]" >> cloudbuild.yaml
echo "- name: 'gcr.io/cloud-builders/docker'" >> cloudbuild.yaml
echo " args: [ 'push', '${DOCKER_IMAGE_TAG}' ]" >> cloudbuild.yaml
fi

echo "Building image with the tag ${DOCKER_IMAGE_TAG}..."

SUBMIT_COMMAND="gcloud builds submit --tag ${DOCKER_IMAGE_TAG} --timeout=24h --machine-type n1_highcpu_8"
if [ -n "$RELEASE" ]; then
SUBMIT_COMMAND="gcloud builds submit --config cloudbuild.yaml --timeout=24h --machine-type n1_highcpu_8"
else
SUBMIT_COMMAND="gcloud builds submit --tag ${DOCKER_IMAGE_TAG} --timeout=24h --machine-type n1_highcpu_8"
fi

echo "running the following gcloud command: ${SUBMIT_COMMAND}"
## We need to override the default .gcloudignore to preserve the .git directory which we need in order to download LFS files in the remote build.
echo -n "" >> .gcloudignore
Expand Down

0 comments on commit 040a147

Please sign in to comment.