Dockerfile.ubi 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. FROM registry.access.redhat.com/ubi8/ubi as minimal-ubi
  2. ARG TARGETOS
  3. ARG TARGETARCH
  4. RUN dnf update -y && dnf install -y binutils
  5. # prep target rootfs for scratch container
  6. WORKDIR /
  7. RUN mkdir /image && \
  8. ln -s usr/bin /image/bin && \
  9. ln -s usr/sbin /image/sbin && \
  10. ln -s usr/lib64 /image/lib64 && \
  11. ln -s usr/lib /image/lib && \
  12. mkdir -p /image/{usr/bin,usr/lib64,usr/lib,root,home,proc,etc,sys,var,dev}
  13. COPY ubi-build-files-${TARGETARCH}.txt /tmp
  14. # Copy all the required files from the base UBI image into the image directory
  15. # As the go binary is not statically compiled this includes everything needed for CGO to work, cacerts, tzdata and RH release files
  16. RUN tar cf /tmp/files.tar -T /tmp/ubi-build-files-${TARGETARCH}.txt && tar xf /tmp/files.tar -C /image/ \
  17. && strip --strip-unneeded /image/usr/lib64/*[0-9].so
  18. # Generate a rpm database which contains all the packages that you said were needed in ubi-build-files-*.txt
  19. RUN rpm --root /image --initdb \
  20. && PACKAGES=$(rpm -qf $(cat /tmp/ubi-build-files-${TARGETARCH}.txt) | grep -v "is not owned by any package" | sort -u) \
  21. && echo dnf install -y 'dnf-command(download)' \
  22. && dnf download --destdir / ${PACKAGES} \
  23. && rpm --root /image -ivh --justdb --nodeps `for i in ${PACKAGES}; do echo $i.rpm; done`
  24. FROM scratch
  25. # Copy all required files + rpm database so the image is scannable
  26. COPY --from=minimal-ubi /image/ /
  27. USER 65534
  28. ARG TARGETOS
  29. ARG TARGETARCH
  30. COPY bin/external-secrets-${TARGETOS}-${TARGETARCH} /bin/external-secrets
  31. ENTRYPOINT ["/bin/external-secrets"]