-
Notifications
You must be signed in to change notification settings - Fork 77
Improve linux Dockerfile caching #1038
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
Conversation
7a811b4 to
b13ef60
Compare
b13ef60 to
541d3c4
Compare
3392b77 to
11219f1
Compare
Co-authored-by: Jeff Erbrecht <89024676+jefferbrecht@users.noreply.github.com>
11219f1 to
53cdf8c
Compare
| if [[ ! -f /work/google_cloud_ops_agent_engine ]]; then | ||
| go build -buildvcs=false -o "/work/google_cloud_ops_agent_engine" \ |
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.
@hsmatulisgoogle This changes break the build.sh if its run directly. For example,
$ BUILD_DISTRO=arch CODE_VERSION="${pkgver}" DESTDIR="$_destdir" ./build.sh
See build output here: https://build.kilabit.info/karajo/job/log?id=aur_google-cloud-ops-agent-git&counter=51
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.
build.sh is an implementation detail of Dockerfile and is not intended to be run standalone. Would you mind sharing the reason why you're building it that way instead of using Dockerfile -- is there something about Dockerfile that doesn't work for you?
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.
build.sh is an implementation detail of Dockerfile and is not intended to be run standalone.
I see. I thought it was for building the binaries (the usual make flow installed on $DESTDIR). I remember reading the rpm spec script and it execute the build.sh directly.
Would you mind sharing the reason why you're building it that way instead of using Dockerfile -- is there something about Dockerfile that doesn't work for you?
I use it to build the ops-agent package for Arch Linux [1] which is not available in Dockerfile.
In that case I will patch the build script manually, and run each .sh script manually.
@@ -72,6 +74,13 @@ build() {
echo "destdir: $_destdir"
cd "${pkgname}"
+
+ CGO_ENABLED=1 ./builds/otel.sh "$_destdir"
+ ./builds/fluent_bit.sh "$_destdir"
+ ./builds/systemd.sh "$_destdir"
+ ./builds/ops_agent_diagnostics.sh "$_destdir"
+
+ git apply "${srcdir}/0001-build-sh.patch"
BUILD_DISTRO=arch CODE_VERSION="${pkgver}" DESTDIR="$_destdir" \
./build.sh
}
It succesfully build last time I run, but need to test it on live image.
Sorry for the noise.
[1] https://aur.archlinux.org/packages/google-cloud-ops-agent-git
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.
FYI build.sh was intended to function independently from Docker. I agree that this change now makes it impossible to do non-Docker builds.
Since PR #1038 merged to master, the build failed due to the $DESTDIR now replaced with "/work" for building with docker. [1] [1] GoogleCloudPlatform/ops-agent#1038 (comment)
Description
Improve Dockerfile caching to speed up subsequent builds on the same machine. It now takes ~8 minutes on my machine to recompile the agent after changing the source code
Checklist: