@@ -3,7 +3,7 @@ ARG BASE_IMAGE
33
44FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE} AS SRC
55
6- FROM ${BASE_IMAGE:-registry.access.redhat.com/ubi9/ubi:latest } AS ubi
6+ FROM ${BASE_IMAGE:-registry.access.redhat.com/ubi9/ubi:9.7 } AS ubi
77ARG TARGETARCH
88
99
@@ -20,7 +20,21 @@ RUN mkdir /image && \
2020COPY ubi-build-files-${TARGETARCH}.txt /tmp
2121# Copy all the required files from the base UBI image into the image directory
2222# As the go binary is not statically compiled this includes everything needed for CGO to work, cacerts, tzdata and RH release files
23- RUN tar cf /tmp/files.tar -T /tmp/ubi-build-files-${TARGETARCH}.txt && tar xf /tmp/files.tar -C /image/
23+ # Filter existing files and exclude temporary entitlement files that may be removed during build
24+ RUN while IFS= read -r file; do \
25+ [ -z "$file" ] && continue; \
26+ if [ -e "$file" ] || [ -L "$file" ]; then \
27+ echo "$file"; \
28+ fi; \
29+ done < /tmp/ubi-build-files-${TARGETARCH}.txt > /tmp/existing-files.txt && \
30+ if [ -s /tmp/existing-files.txt ]; then \
31+ tar -chf /tmp/files.tar --exclude='etc/pki/entitlement-host*' -T /tmp/existing-files.txt 2>&1 | grep -vE "(File removed before we read it|Cannot stat)" || true; \
32+ if [ -f /tmp/files.tar ]; then \
33+ tar xf /tmp/files.tar -C /image/ 2>/dev/null || true; \
34+ rm -f /tmp/files.tar; \
35+ fi; \
36+ fi && \
37+ rm -f /tmp/existing-files.txt
2438
2539# Generate a rpm database which contains all the packages that you said were needed in ubi-build-files-*.txt
2640RUN rpm --root /image --initdb \
0 commit comments