-
Notifications
You must be signed in to change notification settings - Fork 87
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
Optimize Docker image #271
base: master
Are you sure you want to change the base?
Optimize Docker image #271
Conversation
RUN make install | ||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
xx-go --wrap && \ |
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.
takes care of the plumbing like on line https://github.com/viaduct-ai/kustomize-sops/pull/271/files#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557L21-L23
also has a verify command to virify the outcome of the binary.
Hey @marcofranssen awesome work. Are you able to show a before/after for image size? |
This change optimizes the layers, build speed, and foremost reduces vulnerabilities by switching to distroless/base image
53717ac
to
087356f
Compare
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ksops latest 83865ac306be About a minute ago 165MB
viaductoss/ksops latest fa92f7c8ba3f 4 hours ago 288MB Furthermore CVE in current image: $ trivy image viaductoss/ksops
………
viaductoss/ksops (debian 11.11)
Total: 156 (UNKNOWN: 0, LOW: 119, MEDIUM: 27, HIGH: 7, CRITICAL: 3)
………………
usr/local/bin/kustomize (gobinary)
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)
vs new image: $ trivy image ttl.sh/ksops-1234567890:1h
…………
ttl.sh/ksops-1234567890:1h (debian 12.9)
Total: 9 (UNKNOWN: 0, LOW: 7, MEDIUM: 2, HIGH: 0, CRITICAL: 0)
……………
…………
usr/local/bin/kustomize (gobinary)
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0) So you can see it has massive lower dependencies and therefore also less vulnerabilities. |
This PR optimizes the Docker image in following ways:
If necessary I can break up the PR in smaller chunks, but wanted to start with the full picture to show where I'm heading at.
Also seems like the Makefile and compiling can also be improved and much more efficient, would love to contribute that part as well in a follow-up PR.