Skip to content

Commit abe25a9

Browse files
Merge pull request #4635 from ggiguash/embedded_container_docs
USHIFT-5375: Document embedding container images in bootc builds
2 parents f7e8b94 + 5bacd91 commit abe25a9

File tree

6 files changed

+262
-45
lines changed

6 files changed

+262
-45
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
ARG USHIFT_BASE_IMAGE_NAME
2+
ARG USHIFT_BASE_IMAGE_TAG
3+
FROM $USHIFT_BASE_IMAGE_NAME:$USHIFT_BASE_IMAGE_TAG
4+
5+
# Pull the container image dependencies into /var/lib/containers/storage-preloaded
6+
RUN --mount=type=secret,id=pullsecret,dst=/run/secrets/pull-secret.json \
7+
images=$(jq -r '.images | .[]' "/usr/share/microshift/release/release-$(uname -m).json") ; \
8+
for i in ${images} ; do \
9+
podman pull \
10+
--authfile /run/secrets/pull-secret.json \
11+
--root /var/lib/containers/storage-preloaded \
12+
"docker://${i}" ; \
13+
done
14+
15+
# Edit the container storage configuration file to include the new path
16+
RUN sed -i '/^additionalimagestores.*/a\ "/var/lib/containers/storage-preloaded",' /etc/containers/storage.conf
17+
18+
# Apply a workaround to set the SELinux context on the new storage directory and
19+
# also restore 'NET_BIND_SERVICE' capability that is currently lost when including
20+
# images in the container.
21+
#
22+
# Note: This requires setting the additional image stores path to a read-write
23+
# location on the file system. The images will still be treated as read-only by
24+
# the container subsystem.
25+
# See https://github.com/ostreedev/ostree-rs-ext/issues/654
26+
#
27+
# hadolint ignore=DL3059
28+
RUN cat > /usr/bin/microshift-imagestore-config <<'EOF'
29+
#!/bin/bash
30+
set -euxo pipefail
31+
DEF_IMGPATH="$1"
32+
NEW_IMGPATH="$2"
33+
semanage fcontext -a -e "${DEF_IMGPATH}" "${NEW_IMGPATH}"
34+
restorecon -R "${NEW_IMGPATH}"
35+
find "${NEW_IMGPATH}" -type f -path "*/usr/sbin/haproxy" -exec setcap "cap_net_bind_service=+ep" {} \;
36+
EOF
37+
38+
# hadolint ignore=DL3059
39+
RUN cat > /etc/systemd/system/microshift-imagestore-config.service <<'EOF'
40+
[Unit]
41+
Description=Configure the image store directory for MicroShift
42+
Before=microshift.service
43+
[Service]
44+
Type=oneshot
45+
ExecStart=/usr/bin/microshift-imagestore-config /var/lib/containers/storage /var/lib/containers/storage-preloaded
46+
[Install]
47+
WantedBy=multi-user.target
48+
EOF
49+
50+
RUN chmod 755 /usr/bin/microshift-imagestore-config && \
51+
systemctl enable microshift-imagestore-config.service

docs/config/Containerfile.bootc-rhel9

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
FROM registry.redhat.io/rhel9-eus/rhel-9.4-bootc:9.4
22

3-
ARG USHIFT_VER=4.17
3+
ARG USHIFT_VER=4.18
44
# hadolint ignore=SC1091
55
RUN . /etc/os-release && dnf upgrade -y --releasever="${VERSION_ID}" && \
66
dnf config-manager \
77
--set-enabled "rhocp-${USHIFT_VER}-for-rhel-9-$(uname -m)-rpms" \
88
--set-enabled "fast-datapath-for-rhel-9-$(uname -m)-rpms" && \
9-
dnf install -y firewalld microshift && \
9+
dnf install -y firewalld jq microshift microshift-release-info && \
1010
systemctl enable microshift && \
1111
dnf clean all
1212

0 commit comments

Comments
 (0)