Dockerfile.ubi 1.7 KB

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