-
Notifications
You must be signed in to change notification settings - Fork 216
USHIFT-5375: Document embedding container images in bootc builds #4635
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
ARG USHIFT_BASE_IMAGE_NAME | ||
ARG USHIFT_BASE_IMAGE_TAG | ||
FROM $USHIFT_BASE_IMAGE_NAME:$USHIFT_BASE_IMAGE_TAG | ||
|
||
# Pull the container image dependencies into /var/lib/containers/storage-preloaded | ||
RUN --mount=type=secret,id=pullsecret,dst=/run/secrets/pull-secret.json \ | ||
images=$(jq -r '.images | .[]' "/usr/share/microshift/release/release-$(uname -m).json") ; \ | ||
for i in ${images} ; do \ | ||
podman pull \ | ||
--authfile /run/secrets/pull-secret.json \ | ||
--root /var/lib/containers/storage-preloaded \ | ||
"docker://${i}" ; \ | ||
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. Does this preserve cosign signatures? I did not verify with a corresponding config to ensure that those local images still can be verified with the Red Hat release signer key. Do you know or want me to verify? 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. 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 that are two different aspects:
Lets add both aspects at a later stage. For now, this is simple and works. |
||
done | ||
|
||
# Edit the container storage configuration file to include the new path | ||
RUN sed -i '/^additionalimagestores.*/a\ "/var/lib/containers/storage-preloaded",' /etc/containers/storage.conf | ||
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 means the images are part of /var, which is mutable. Meaning: when switching to a new version, the old images are still present. That has a couple of pros and cons:
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. Actually I tried this with an update from 4.17.1 to 4.17.12, both images with embedded offline containers. I was expecting the /var/... folder to be merged, meaning to see both sets of images to be in there. 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. We have an open issue for fixing this: https://issues.redhat.com/browse/OCPBUGS-52420 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. okay, fine for me! |
||
|
||
# Apply a workaround to set the SELinux context on the new storage directory and | ||
# also restore 'NET_BIND_SERVICE' capability that is currently lost when including | ||
# images in the container. | ||
# | ||
# Note: This requires setting the additional image stores path to a read-write | ||
# location on the file system. The images will still be treated as read-only by | ||
# the container subsystem. | ||
# See https://github.com/ostreedev/ostree-rs-ext/issues/654 | ||
# | ||
# hadolint ignore=DL3059 | ||
RUN cat > /usr/bin/microshift-imagestore-config <<'EOF' | ||
ggiguash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#!/bin/bash | ||
set -euxo pipefail | ||
DEF_IMGPATH="$1" | ||
NEW_IMGPATH="$2" | ||
semanage fcontext -a -e "${DEF_IMGPATH}" "${NEW_IMGPATH}" | ||
restorecon -R "${NEW_IMGPATH}" | ||
find "${NEW_IMGPATH}" -type f -path "*/usr/sbin/haproxy" -exec setcap "cap_net_bind_service=+ep" {} \; | ||
EOF | ||
|
||
# hadolint ignore=DL3059 | ||
RUN cat > /etc/systemd/system/microshift-imagestore-config.service <<'EOF' | ||
[Unit] | ||
Description=Configure the image store directory for MicroShift | ||
Before=microshift.service | ||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/microshift-imagestore-config /var/lib/containers/storage /var/lib/containers/storage-preloaded | ||
[Install] | ||
WantedBy=multi-user.target | ||
EOF | ||
|
||
RUN chmod 755 /usr/bin/microshift-imagestore-config && \ | ||
systemctl enable microshift-imagestore-config.service |
Uh oh!
There was an error while loading. Please reload this page.