Skip to content

Commit

Permalink
Use docker --format to parse snapshot from "latest" tag (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
rockycodes authored Jun 23, 2023
1 parent c8e0983 commit 92bf60b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cloud/shared/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ while getopts s:c:t: flag; do
done

# if the tag is "latest", resolve it to the specific snapshot tag from Docker
# Go templating is used to parse the snapshot tag from the json returned by docker inspect
# https://docs.docker.com/engine/reference/commandline/inspect/#options
if [[ "${tag}" == "latest" ]]; then
docker pull --platform linux/x86_64 docker.io/civiform/civiform:latest
snapshot_tag="$(docker inspect docker.io/civiform/civiform:latest \
| grep 'CIVIFORM_IMAGE_TAG' \
| grep -oE 'SNAPSHOT-\w+-\d+')"
--format='{{range .Config.Env}}{{if eq (printf "%.19s" .) "CIVIFORM_IMAGE_TAG="}}{{slice . 19}}{{end}}{{end}}')"
if [[ -z "${snapshot_tag}" ]]; then
echo "Latest snapshot tag not found." 2>&1
exit 1
fi
echo "Resolved 'latest' to snapshot tag ${snapshot_tag}"
tag="${snapshot_tag}"
fi

Expand Down Expand Up @@ -71,6 +73,7 @@ else
"['object']['url']")
commit_sha=$(fetch_json_val ${tag_url} "['object']['sha']")
fi
echo "Fetched commit sha ${commit_sha}"

dependencies_file_path="cloud/shared/bin/env-var-docs-python-dependencies.txt"

Expand Down

0 comments on commit 92bf60b

Please sign in to comment.