Dockerfile.ubi 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. FROM registry.access.redhat.com/ubi8/ubi@sha256:8bd1b6306f8164de7fb0974031a0f903bd3ab3e6bcab835854d3d9a1a74ea5db 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 && rpm --root /image --initdb \
  18. && PACKAGES=$(rpm -qf $(cat /tmp/ubi-build-files-${TARGETARCH}.txt) | grep -v "is not owned by any package" | sort -u) \
  19. && echo dnf install -y 'dnf-command(download)' \
  20. && dnf download --destdir / ${PACKAGES} \
  21. && rpm --root /image -ivh --justdb --nodeps `for i in ${PACKAGES}; do echo $i.rpm; done`
  22. FROM scratch
  23. # Copy all required files + rpm database so the image is scannable
  24. COPY --from=minimal-ubi /image/ /
  25. USER 65534
  26. ARG TARGETOS
  27. ARG TARGETARCH
  28. COPY bin/external-secrets-${TARGETOS}-${TARGETARCH} /bin/external-secrets
  29. ENTRYPOINT ["/bin/external-secrets"]