-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathContainerfile.bootc-embedded-rhel9
46 lines (41 loc) · 1.88 KB
/
Containerfile.bootc-embedded-rhel9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
ARG USHIFT_BASE_IMAGE_NAME
ARG USHIFT_BASE_IMAGE_TAG
FROM $USHIFT_BASE_IMAGE_NAME:$USHIFT_BASE_IMAGE_TAG
ENV IMAGE_STORAGE_DIR=/usr/lib/containers/storage
ENV IMAGE_LIST_FILE=${IMAGE_STORAGE_DIR}/image-list.txt
# Pull the container images into /usr/lib/containers/storage:
# - Each image goes into a separate sub-directory
# - Sub-directories are named after the image reference string SHA
# - An image list file maps image references to their name SHA
# hadolint ignore=DL4006
RUN --mount=type=secret,id=pullsecret,dst=/run/secrets/pull-secret.json \
images="$(jq -r ".images[]" /usr/share/microshift/release/release-"$(uname -m)".json)" ; \
mkdir -p "${IMAGE_STORAGE_DIR}" ; \
for img in ${images} ; do \
sha="$(echo "${img}" | sha256sum | awk '{print $1}')" ; \
skopeo copy --all --preserve-digests \
--authfile /run/secrets/pull-secret.json \
"docker://${img}" "dir:$IMAGE_STORAGE_DIR/${sha}" ; \
echo "${img},${sha}" >> "${IMAGE_LIST_FILE}" ; \
done
# Install a systemd drop-in unit to address the problem with image upgrades
# overwriting the container images in additional store. The workaround is to
# copy the images from the pre-loaded to the main container storage.
# In this case, it is not necessary to update /etc/containers/storage.conf with
# the additional store path.
# See https://issues.redhat.com/browse/RHEL-75827
RUN cat > /usr/bin/microshift-copy-images <<EOF
#!/bin/bash
set -eux -o pipefail
while IFS="," read -r img sha ; do
skopeo copy --preserve-digests \
"dir:${IMAGE_STORAGE_DIR}/\${sha}" \
"containers-storage:\${img}"
done < "${IMAGE_LIST_FILE}"
EOF
RUN chmod 755 /usr/bin/microshift-copy-images && \
mkdir -p /usr/lib/systemd/system/microshift.service.d
RUN cat > /usr/lib/systemd/system/microshift.service.d/microshift-copy-images.conf <<EOF
[Service]
ExecStartPre=/usr/bin/microshift-copy-images
EOF