-
Notifications
You must be signed in to change notification settings - Fork 413
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
Make the container image smaller #753
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: thockin The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
one nit :-)
stage_binaries.sh
Outdated
dpkg -s "${package}" > "${staging}/var/lib/dpkg/status.d/${package}" | ||
} | ||
|
||
# helper because bash sometimes barfs on embedded comments |
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.
nit: I can't really tell from this comment and the usage context why this is needed. At the call site it's also not obvious what's happening without going back and reading this.
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.
grep treats "no match" as an error, which trips up pipefail
and errexit
$ echo foo | grep bar; echo $?
1
So we want to do:
$ echo foo | { grep bar || true; }; echo $?
0
Adding back the comments in the style of binary_to_libraries()
:
$ echo foo \
`# comment1` \
| { grep "bar" || true; } \
`# comment2`; echo $?
bash: syntax error near unexpected token ``# comment2`'
Parens fails the same way.
It works without the braces and || true
, but returns error status
$ echo foo `# comment1` | grep "bar" `# comment2`; echo $?
1
Once bash parses {}
or ()
it can't handle subsequent #comment
blocks. happy()
hides that. I could rename it :)
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.
grep treats "no match" as an error, which trips up pipefail and errexit
instead of swallowing all errors, you can actually detect the no-match case and ignore that
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.
grep_allow_nomatch() {
# grep exits 0 on match, 1 on no match, 2 on error
grep "$@" || [ $? = 1 ]
}
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.
cute, I guess I should actually read the man 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.
PTAL. I want to run a scanner against it to be sure it works, when I get a moment
And hopefully less CVEs. |
1f52e3b
to
d360a68
Compare
For each package and binary we need, this pulls in all the files and deps (shared libs, mostly). The build is slower but the final image is 85 MB (versus 157 MB before). e2e passes. Hopefully less CVE surface. This is based on scripts used in kubernetes and KinD.
d360a68
to
f037087
Compare
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.
/lgtm
For each package and binary we need, this pulls in all the files and deps (shared libs, mostly). The build is slower but the final image is 85 MB (versus 157 MB before). e2e passes.
This is based on scripts used in kubernetes and KinD.