-
Notifications
You must be signed in to change notification settings - Fork 83
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 1 commit
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 |
|---|---|---|
|
|
@@ -12,3 +12,4 @@ tasks: | |
| - ":package" | ||
| cmds: | ||
| - "./build.sh" | ||
| - "rsync -a 'image.id' '{{.G_PACKAGE_BUILD_DIR}}'" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,11 +4,26 @@ set -eu | |
| set -o pipefail | ||
|
|
||
| script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
| iid_file="${script_dir}/image.id" | ||
|
||
| repo_root=${script_dir}/../../../ | ||
|
|
||
| # Remove the previous image after the build to allow layer reuse. | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| prev_image_id="" | ||
| if [[ -f "$iid_file" ]]; then | ||
| prev_image_id=$(cat "$iid_file") | ||
junhaoliao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi | ||
| cleanup() { | ||
|
||
| if [[ -n "$prev_image_id" ]] && docker image inspect "$prev_image_id" >/dev/null 2>&1; then | ||
| echo "Removing previous image $prev_image_id" | ||
junhaoliao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| docker image remove "$prev_image_id" | ||
| fi | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
|
||
| build_cmd=( | ||
| docker build | ||
| --tag "clp-package:dev" | ||
| --iidfile "$iid_file" | ||
| --tag "clp-package:dev-${USER}-$(date +%s)" | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "$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 |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
🛠️ Refactor suggestion | 🟠 Major
Ensure destination directory exists before rsync.
If
{{.G_PACKAGE_BUILD_DIR}}doesn’t exist yet, rsync will fail. Create it first.🤖 Prompt for AI Agents
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.
The
docker-images:packagetask depends on the:packagetask, which already creates the G_PACKAGE_BUILD_DIRThere 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.
🧩 Analysis chain
🏁 Script executed:
Length of output: 1186
🏁 Script executed:
Length of output: 7777
🏁 Script executed:
Length of output: 2141
@junhaoliao You're absolutely correct! I can see that the
:packagetask does indeed create theG_PACKAGE_BUILD_DIRdirectory with the commandmkdir -p '{{.OUTPUT_DIR}}/lib/python3/site-packages'whereOUTPUT_DIRis set to{{.G_PACKAGE_BUILD_DIR}}. Since thedocker-images:packagetask depends on:package, the directory is guaranteed to exist before the rsync command runs.Thank you for the clarification - my suggestion to add the redundant
mkdir -pwas unnecessary.✏️ Learnings added