-
Notifications
You must be signed in to change notification settings - Fork 72
add CLEANUPLEVEL arg for image-base #618
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 all commits
0aa07c8
0a1c464
29dbdbf
dd33def
646b438
b51acc0
cb041bc
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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
# CLEANUPLEVEL defines the level of FS stripping we apply to the generated image. | ||
ARG CLEANUP_LEVEL | ||
ARG BASE | ||
|
||
FROM --platform=linux/amd64 calico/qemu-user-static:latest AS qemu | ||
|
||
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest AS ubi | ||
FROM ${BASE} AS source-unstripped | ||
|
||
ARG LDSONAME | ||
|
||
COPY --from=qemu /usr/bin/qemu-*-static /usr/bin/ | ||
|
||
RUN microdnf upgrade -y | ||
|
||
ARG PKGMAN | ||
RUN ${PKGMAN} upgrade -y | ||
# Prepare a rootfs for necessary files from UBI. | ||
# Symbolic links are preserved. | ||
RUN mkdir -p /rootfs/lib64 /rootfs/etc | ||
|
@@ -38,15 +42,17 @@ RUN cp /etc/nsswitch.conf /rootfs/etc/nsswitch.conf | |
# Copy base image release info. | ||
RUN cp /etc/os-release /rootfs/etc/os-release | ||
|
||
FROM scratch AS source | ||
|
||
COPY --from=ubi /rootfs / | ||
|
||
# Stripped image. | ||
FROM scratch AS source-stripped | ||
COPY --from=source-unstripped /rootfs / | ||
# tmp.tar has a /tmp with the correct permissions 01777. | ||
ADD tmp.tar / | ||
|
||
COPY licenses /licenses/ | ||
|
||
FROM scratch | ||
# Unstripped image. | ||
FROM source-unstripped | ||
# Remove the prepped rootfs for the unstripped img. | ||
RUN rm -rf /rootfs | ||
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. This step results an extra layer to the source-unstripped image and wasted space if not squashed. 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. IMO I think that's fine - we dont intend to ship unstripped images, and anyone who want's to build an unstripped image themselves can opt to squash. I have cleaned up these lines a bit anyway though, and removed what I believe are redundant layers. Does this help? 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. I think we've ended up with qemu in the image too, which we don't want and maybe we now have literally nothing of value in the unstripped image (I thought we needed to add /tmp and the licenses, but if not, perhaps we should derive it from the BASE with no changes? |
||
|
||
COPY --from=source / / | ||
# Choose which image is shipped. | ||
FROM source-${CLEANUP_LEVEL} |
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 think all this rootfs building (and the qemu bit) should happen in an intermediate image that's not a base for the unstripped one.