Repository navigation
feat(docker): Generate unique tag for each clp-package dev image build to avoid conflicts on shared hosts. #1335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
653cdd7
0c8c699
d79cb5f
49f3822
e0dc40f
ec09d98
a2a8f08
7a05377
be5a517
0e2667c
aa4919f
94a8523
c9d9959
074650c
2b73559
fba7d3b
c778427
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,32 @@ | |
| set -eu | ||
| set -o pipefail | ||
|
|
||
| remove_prev_image_and_temp_file() { | ||
| if [[ -n "$prev_image_id" && "$prev_image_id" != "$new_image_id" ]]; then | ||
| if docker image inspect "$prev_image_id" >/dev/null 2>&1; then | ||
| echo "Removing previous image $prev_image_id." | ||
| docker image remove "$prev_image_id" | ||
| fi | ||
| fi | ||
| rm -f "$temp_iid_file" | ||
| } | ||
| trap remove_prev_image_and_temp_file EXIT | ||
|
|
||
| script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
| repo_root=${script_dir}/../../../ | ||
| iid_file="${repo_root}/build/clp-package-image.id" | ||
|
|
||
| prev_image_id="" | ||
| if [[ -f "$iid_file" ]]; then | ||
| prev_image_id=$(<"$iid_file") | ||
| fi | ||
|
|
||
| temp_iid_file="$(mktemp)" | ||
| new_image_id="" | ||
|
|
||
| build_cmd=( | ||
| docker build | ||
| --tag "clp-package:dev" | ||
| --iidfile "$temp_iid_file" | ||
| "$repo_root" | ||
| --file "${script_dir}/Dockerfile" | ||
| ) | ||
|
Comment on lines
30
to
35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Confirm intended builder: buildx vs classic build. PR text mentions buildx, but this uses 🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @junhaoliao Thank you for the clarification and the reference! You're absolutely right - since Docker Engine 23.0, I appreciate you providing the documentation link to confirm this behavior change. The script is appropriately using 🐰💡 ✏️ Learnings added
🧠 Learnings used
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kirkrodrigues i realise we don't really mention any docker version in our dev docs (we do mention docker in the userquick start guide, though we don't say the version still). if that's not intentionally left out, maybe we should specify the version in our dev docs as well?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we should specify the version we require. I just don't know what version that is right now.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it might be time consuming to figure out the exact version for the feature / syntax we use. maybe we can just take the latest version and put that into the docs? at least we can be sure that's a version we have validated
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally, we support up to 2 years of backwards compatibility with OSes. Perhaps we can do the same for Docker?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://containerd.io/releases/ 's LTS version is now i installed these versions on my machine and tested things fine: sudo apt-get install -y \
docker-ce=5:27.0.3-1~ubuntu.22.04~jammy \
docker-ce-cli=5:27.0.3-1~ubuntu.22.04~jammy \
containerd.io=1.7.18-1 \
docker-buildx-plugin=0.15.1-1~ubuntu.22.04~jammy \
docker-compose-plugin=2.28.1-1~ubuntu.22.04~jammy |
||
|
|
@@ -22,3 +42,12 @@ then | |
| fi | ||
|
|
||
| "${build_cmd[@]}" | ||
|
|
||
| if [[ -s "$temp_iid_file" ]]; then | ||
| new_image_id=$(<"$temp_iid_file") | ||
| echo "$new_image_id" > "$iid_file" | ||
|
|
||
| short_id=${new_image_id#sha256:} | ||
| short_id=${short_id:0:4} | ||
| docker tag "$new_image_id" "clp-package:dev-${USER}-${short_id}" | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update documentation to reflect the new image tagging scheme.
According to the PR summary, the build process now generates unique identifiers to avoid overwriting older builds on shared machines. The AI summary mentions tagging as
clp-package:dev-${USER}-${short_id}, but this line still states the image will be namedclp-package:dev.Please update this documentation to:
image.idfile mentioned in the PR summary)🤖 Prompt for AI Agents