|
| 1 | +FROM --platform=${BUILDPLATFORM} registry.access.redhat.com/ubi8/ubi-minimal AS tools_downloader |
| 2 | + |
| 3 | +ARG mongodb_tools_url |
| 4 | +ARG mongodb_tools_version_s390x |
| 5 | +ARG mongodb_tools_version_ppc64le |
| 6 | +ARG mongodb_tools_version_amd64 |
| 7 | +ARG mongodb_tools_version_arm64 |
| 8 | + |
| 9 | +RUN microdnf -y update --nodocs \ |
| 10 | + && microdnf -y install --nodocs tar gzip curl \ |
| 11 | + && microdnf clean all |
| 12 | + |
| 13 | +RUN case ${TARGETPLATFORM} in \ |
| 14 | + "linux/amd64") export MONGODB_TOOLS_VERSION=${mongodb_tools_version_amd64} ;; \ |
| 15 | + "linux/arm64") export MONGODB_TOOLS_VERSION=${mongodb_tools_version_arm64} ;; \ |
| 16 | + "linux/s390x") export MONGODB_TOOLS_VERSION=${mongodb_tools_version_s390x} ;; \ |
| 17 | + "linux/ppc64le") export MONGODB_TOOLS_VERSION=${mongodb_tools_version_ppc64le} ;; \ |
| 18 | + esac \ |
| 19 | + && mkdir -p /tools \ |
| 20 | + && if [ -n "$MONGODB_TOOLS_VERSION" ]; then \ |
| 21 | + curl -o /tools/mongodb_tools.tgz "${mongodb_tools_url}/${MONGODB_TOOLS_VERSION}"; \ |
| 22 | + fi |
| 23 | + |
| 24 | +RUN if [ -f "/tools/mongodb_tools.tgz" ]; then \ |
| 25 | + tar xfz /tools/mongodb_tools.tgz --directory /tools \ |
| 26 | + && rm /tools/mongodb_tools.tgz; \ |
| 27 | + fi |
| 28 | + |
| 29 | +FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/golang:1.24 AS readiness_builder |
| 30 | + |
| 31 | +WORKDIR /go/src/github.com/mongodb/mongodb-kubernetes/ |
| 32 | + |
| 33 | +COPY go.mod go.sum ./ |
| 34 | + |
| 35 | +RUN go mod download |
| 36 | + |
| 37 | +COPY mongodb-community-operator ./mongodb-community-operator |
| 38 | + |
| 39 | +ARG TARGETOS |
| 40 | +ARG TARGETARCH |
| 41 | +RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /readinessprobe ./mongodb-community-operator/cmd/readiness/main.go |
| 42 | +RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /version-upgrade-hook ./mongodb-community-operator/cmd/versionhook/main.go |
| 43 | + |
| 44 | +FROM scratch AS base |
| 45 | + |
| 46 | +COPY --from=readiness_builder /readinessprobe /data/readinessprobe |
| 47 | +COPY --from=readiness_builder /version-upgrade-hook /data/version-upgrade-hook |
| 48 | + |
| 49 | +COPY ./docker/mongodb-kubernetes-init-database/content/probe.sh /data/probe.sh |
| 50 | + |
| 51 | +COPY ./docker/mongodb-kubernetes-init-database/content/agent-launcher-lib.sh /data/scripts/ |
| 52 | +COPY ./docker/mongodb-kubernetes-init-database/content/agent-launcher.sh /data/scripts/ |
| 53 | + |
| 54 | +COPY ./docker/mongodb-kubernetes-init-database/content/LICENSE /data/licenses/ |
| 55 | + |
| 56 | +FROM registry.access.redhat.com/ubi8/ubi-minimal |
| 57 | + |
| 58 | +# Copy the extracted tools from the downloader stage (tools are already extracted there) |
| 59 | +COPY --from=tools_downloader /tools/ /tools/ |
| 60 | + |
| 61 | +COPY --from=base /data/readinessprobe /probes/readinessprobe |
| 62 | +COPY --from=base /data/probe.sh /probes/probe.sh |
| 63 | +COPY --from=base /data/scripts/ /scripts/ |
| 64 | +COPY --from=base /data/licenses /licenses/ |
| 65 | +COPY --from=base /data/version-upgrade-hook /probes/version-upgrade-hook |
| 66 | + |
| 67 | +RUN microdnf -y update --nodocs \ |
| 68 | + && microdnf -y install --nodocs tar gzip \ |
| 69 | + && microdnf clean all |
| 70 | + |
| 71 | +ARG version |
| 72 | +LABEL name="MongoDB Kubernetes Init AppDB" \ |
| 73 | + version="mongodb-kubernetes-init-appdb-${version}" \ |
| 74 | + summary="MongoDB Kubernetes AppDB Init Image" \ |
| 75 | + description="Startup Scripts for MongoDB Enterprise Application Database for Ops Manager" \ |
| 76 | + release="1" \ |
| 77 | + vendor="MongoDB" \ |
| 78 | + |
| 79 | + |
| 80 | +USER 2000 |
| 81 | + |
| 82 | +ENTRYPOINT [ "/bin/cp", "-f", "-r", "/scripts/agent-launcher.sh", "/scripts/agent-launcher-lib.sh", "/probes/readinessprobe", "/probes/probe.sh", "/tools", "/opt/scripts/" ] |
0 commit comments