Skip to content

Commit bf73580

Browse files
committed
Document embedding container images in bootc builds
1 parent ea99c2d commit bf73580

File tree

3 files changed

+253
-39
lines changed

3 files changed

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