|
| 1 | +FROM --platform=${BUILDPLATFORM} registry.access.redhat.com/ubi9/ubi-minimal AS tools_downloader |
| 2 | + |
| 3 | +ARG TARGETPLATFORM |
| 4 | +ARG mongodb_tools_url |
| 5 | +ARG mongodb_tools_version_s390x |
| 6 | +ARG mongodb_tools_version_ppc64le |
| 7 | +ARG mongodb_tools_version_amd64 |
| 8 | +ARG mongodb_tools_version_arm64 |
| 9 | + |
| 10 | +RUN microdnf -y update --nodocs \ |
| 11 | + && microdnf -y install --nodocs tar gzip \ |
| 12 | + && microdnf clean all |
| 13 | + |
| 14 | +RUN case ${TARGETPLATFORM} in \ |
| 15 | + "linux/amd64") export MONGODB_TOOLS_VERSION=${mongodb_tools_version_amd64} ;; \ |
| 16 | + "linux/arm64") export MONGODB_TOOLS_VERSION=${mongodb_tools_version_arm64} ;; \ |
| 17 | + "linux/s390x") export MONGODB_TOOLS_VERSION=${mongodb_tools_version_s390x} ;; \ |
| 18 | + "linux/ppc64le") export MONGODB_TOOLS_VERSION=${mongodb_tools_version_ppc64le} ;; \ |
| 19 | + esac \ |
| 20 | + && mkdir -p /tools \ |
| 21 | + && curl -o /tools/mongodb_tools.tgz "${mongodb_tools_url}/${MONGODB_TOOLS_VERSION}" |
| 22 | + |
| 23 | +RUN tar xfz /tools/mongodb_tools.tgz \ |
| 24 | + && mv mongodb-database-tools-*/bin/* /tools \ |
| 25 | + && chmod +x /tools/* \ |
| 26 | + && rm /tools/mongodb_tools.tgz \ |
| 27 | + && rm -r mongodb-database-tools-* |
| 28 | + |
| 29 | +FROM --platform=${BUILDPLATFORM} registry.access.redhat.com/ubi9/ubi-minimal AS agent_downloader |
| 30 | + |
| 31 | +ARG TARGETPLATFORM |
| 32 | +ARG mongodb_agent_url |
| 33 | +ARG mongodb_agent_version_s390x |
| 34 | +ARG mongodb_agent_version_ppc64le |
| 35 | +ARG mongodb_agent_version_amd64 |
| 36 | +ARG mongodb_agent_version_arm64 |
| 37 | + |
| 38 | +RUN microdnf -y update --nodocs \ |
| 39 | + && microdnf -y install --nodocs tar gzip \ |
| 40 | + && microdnf clean all |
| 41 | + |
| 42 | +RUN case ${TARGETPLATFORM} in \ |
| 43 | + "linux/amd64") export MONGODB_AGENT_VERSION=${mongodb_agent_version_amd64} ;; \ |
| 44 | + "linux/arm64") export MONGODB_AGENT_VERSION=${mongodb_agent_version_arm64} ;; \ |
| 45 | + "linux/s390x") export MONGODB_AGENT_VERSION=${mongodb_agent_version_s390x} ;; \ |
| 46 | + "linux/ppc64le") export MONGODB_AGENT_VERSION=${mongodb_agent_version_ppc64le} ;; \ |
| 47 | + esac \ |
| 48 | + && mkdir -p /agent \ |
| 49 | + && curl -o /agent/mongodb_agent.tgz "${mongodb_agent_url}/${MONGODB_AGENT_VERSION}" |
| 50 | + |
| 51 | +RUN tar xfz /agent/mongodb_agent.tgz \ |
| 52 | + && mv mongodb-mms-automation-agent-*/mongodb-mms-automation-agent /agent/mongodb-agent \ |
| 53 | + && chmod +x /agent/mongodb-agent \ |
| 54 | + && rm /agent/mongodb_agent.tgz \ |
| 55 | + && rm -r mongodb-mms-automation-agent-* |
| 56 | + |
| 57 | +FROM registry.access.redhat.com/ubi9/ubi-minimal |
| 58 | + |
| 59 | +# Replace libcurl-minimal and curl-minimal with the full versions |
| 60 | +# https://bugzilla.redhat.com/show_bug.cgi?id=1994521 |
| 61 | +RUN microdnf install -y libssh libpsl libbrotli \ |
| 62 | + && microdnf download curl libcurl \ |
| 63 | + && rpm -Uvh --nodeps --replacefiles "*curl*$( uname -i ).rpm" \ |
| 64 | + && microdnf remove -y libcurl-minimal curl-minimal |
| 65 | + |
| 66 | +RUN microdnf install -y --disableplugin=subscription-manager --setopt=install_weak_deps=0 nss_wrapper |
| 67 | +# Copy-pasted from https://www.mongodb.com/docs/manual/tutorial/install-mongodb-enterprise-on-red-hat-tarball/ |
| 68 | +RUN microdnf install -y --disableplugin=subscription-manager \ |
| 69 | + cyrus-sasl cyrus-sasl-gssapi cyrus-sasl-plain krb5-libs openldap openssl xz-libs |
| 70 | +# Dependencies for the Agent |
| 71 | +RUN microdnf install -y --disableplugin=subscription-manager --setopt=install_weak_deps=0 \ |
| 72 | + net-snmp \ |
| 73 | + net-snmp-agent-libs |
| 74 | +RUN microdnf install -y --disableplugin=subscription-manager \ |
| 75 | + hostname tar gzip procps jq \ |
| 76 | + && microdnf upgrade -y \ |
| 77 | + && rm -rf /var/lib/apt/lists/* |
| 78 | + |
| 79 | +RUN mkdir -p /agent \ |
| 80 | + && mkdir -p /var/lib/mongodb-mms-automation \ |
| 81 | + && mkdir -p /var/log/mongodb-mms-automation/ \ |
| 82 | + && chmod -R +wr /var/log/mongodb-mms-automation/ \ |
| 83 | + # ensure that the agent user can write the logs in OpenShift |
| 84 | + && touch /var/log/mongodb-mms-automation/readiness.log \ |
| 85 | + && chmod ugo+rw /var/log/mongodb-mms-automation/readiness.log |
| 86 | + |
| 87 | +# Copy scripts to a safe location that won't be overwritten by volume mount |
| 88 | +COPY ./docker/mongodb-kubernetes-init-database/content/LICENSE /licenses/LICENSE |
| 89 | +COPY ./docker/mongodb-agent/agent-launcher-shim.sh /usr/local/bin/agent-launcher-shim.sh |
| 90 | +COPY ./docker/mongodb-agent/setup-agent-files.sh /usr/local/bin/setup-agent-files.sh |
| 91 | +COPY ./docker/mongodb-agent/dummy-probe.sh /usr/local/bin/dummy-probe.sh |
| 92 | +COPY ./docker/mongodb-agent/dummy-readinessprobe /usr/local/bin/dummy-readinessprobe |
| 93 | + |
| 94 | +RUN mkdir -p /var/lib/automation/config \ |
| 95 | + && chmod -R +r /var/lib/automation/config |
| 96 | + |
| 97 | +RUN mkdir -p /tools /agent |
| 98 | + |
| 99 | +COPY --from=tools_downloader "/tools/" /tools/ |
| 100 | +COPY --from=agent_downloader "/agent/" /agent/ |
| 101 | + |
| 102 | +ARG version |
| 103 | + |
| 104 | +LABEL name="MongoDB Agent" \ |
| 105 | + version="${version}" \ |
| 106 | + summary="MongoDB Agent" \ |
| 107 | + description="MongoDB Agent" \ |
| 108 | + vendor="MongoDB" \ |
| 109 | + release="1" \ |
| 110 | + maintainer="support@mongodb.com" |
| 111 | + |
| 112 | +USER 2000 |
| 113 | +CMD ["/agent/mongodb-agent", "-cluster=/var/lib/automation/config/automation-config.json"] |
0 commit comments