-
Notifications
You must be signed in to change notification settings - Fork 39
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
Use busybox from alpine #51
Open
liam-verta
wants to merge
4
commits into
prometheus:master
Choose a base branch
from
liam-verta:ln/alpine-busybox
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
ARG ARCH="" | ||
FROM ${ARCH}debian:buster-slim | ||
|
||
RUN \ | ||
apt-get update && apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
gcc \ | ||
netbase \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN set -x \ | ||
&& mkdir -p rootfs/lib \ | ||
&& set -- \ | ||
/etc/nsswitch.conf \ | ||
/etc/ssl/certs/ca-certificates.crt \ | ||
/usr/share/zoneinfo \ | ||
/etc/services \ | ||
/lib/"$(gcc -print-multiarch)"/libpthread.so.* \ | ||
&& while [ "$#" -gt 0 ]; do \ | ||
f="$1"; shift; \ | ||
fn="$(basename "$f")"; \ | ||
if [ -e "rootfs/lib/$fn" ]; then continue; fi; \ | ||
if [ "${f#/lib/}" != "$f" ]; then \ | ||
ln -vL "$f" "rootfs/lib/$fn"; \ | ||
else \ | ||
d="$(dirname $f)" \ | ||
&& mkdir -p "rootfs/${d#/}" \ | ||
&& cp -av "$f" "rootfs/${f#/}"; \ | ||
fi; \ | ||
done | ||
|
||
FROM ${ARCH}alpine:latest as alpine | ||
RUN apk add busybox-static && \ | ||
rm /bin/* && \ | ||
/tmp/busybox --install /bin && \ | ||
mv /tmp/busybox /bin/ | ||
|
||
FROM ${ARCH}busybox:glibc | ||
MAINTAINER The Prometheus Authors <[email protected]> | ||
|
||
# Use the busybox executable from alpine which is generally patched more quickly for vulnerabilities | ||
# Use the busybox.static to avoid dynamic library dependencies. | ||
COPY --from=alpine /bin/busybox.static /tmp/busybox | ||
|
||
RUN rm /bin/* && \ | ||
/tmp/busybox --install /bin && \ | ||
mv /tmp/busybox /bin/ | ||
|
||
COPY --from=0 /rootfs / |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why not
FROM scratch
? If we're not going to use the busybox binary from this package, why use this as the image? All of the prometheus project binaries are static, we don't actually use glibc anymore.Also, maybe we can simplify this to just pull the misc etc files from alpine as well, skip the debian layer as well.
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.
I consume this image: https://hub.docker.com/r/prom/prometheus
I opened this PR to try to produce a more secure base image for that image to be based on so I (and every other consumer) don't have to repackage it for
busybox
security issues. I was trying to do this with the least set of changes in order to have the least risk of breakages and to respect the intent of the existing images.As I noted above, I believe:
This PR provides the above with the least changes from the existing behavior.
What you're suggesting is I skip this and go make the case for prometheus
scratch
images. Fair enough.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.
Yeah I don't get why this isn't
FROM scratch
either. I would also assume that the final image will contain both the original busybox (in a hidden layer) as well as the new one.