-
Notifications
You must be signed in to change notification settings - Fork 13
CLOUDP-333181: Combined dockerfiles #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4b71c0e
Combined Dockerfiles
MaciejKaras c15bd7c
Remove local documentation
Julien-Ben 3a707e6
Preserve old Dockerfiles
Julien-Ben ede6447
Remove code used to generate the dockerfiles
Julien-Ben b6a36ca
Revert permissions change
Julien-Ben 5ccc233
Remove .plain files
Julien-Ben d027dfc
Add tag back
Julien-Ben f8c4e4f
Merge branch 'master' into combined-dockerfiles
Julien-Ben b11c684
Revert to initial file
Julien-Ben File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
ARG imagebase | ||
FROM ${imagebase} as base | ||
|
||
FROM registry.access.redhat.com/ubi9/ubi-minimal | ||
|
||
ARG version | ||
|
||
LABEL name="MongoDB Agent" \ | ||
version="${version}" \ | ||
summary="MongoDB Agent" \ | ||
description="MongoDB Agent" \ | ||
vendor="MongoDB" \ | ||
release="1" \ | ||
maintainer="support@mongodb.com" | ||
|
||
# Replace libcurl-minimal and curl-minimal with the full versions | ||
# https://bugzilla.redhat.com/show_bug.cgi?id=1994521 | ||
RUN microdnf install -y libssh libpsl libbrotli \ | ||
&& microdnf download curl libcurl \ | ||
&& rpm -Uvh --nodeps --replacefiles "*curl*$( uname -i ).rpm" \ | ||
&& microdnf remove -y libcurl-minimal curl-minimal | ||
|
||
RUN microdnf install -y --disableplugin=subscription-manager --setopt=install_weak_deps=0 nss_wrapper | ||
# Copy-pasted from https://www.mongodb.com/docs/manual/tutorial/install-mongodb-enterprise-on-red-hat-tarball/ | ||
RUN microdnf install -y --disableplugin=subscription-manager \ | ||
cyrus-sasl cyrus-sasl-gssapi cyrus-sasl-plain krb5-libs openldap openssl xz-libs | ||
# Dependencies for the Agent | ||
RUN microdnf install -y --disableplugin=subscription-manager --setopt=install_weak_deps=0 \ | ||
net-snmp \ | ||
net-snmp-agent-libs | ||
RUN microdnf install -y --disableplugin=subscription-manager \ | ||
hostname tar gzip procps jq \ | ||
&& microdnf upgrade -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir -p /agent \ | ||
&& mkdir -p /var/lib/mongodb-mms-automation \ | ||
&& mkdir -p /var/log/mongodb-mms-automation/ \ | ||
&& chmod -R +wr /var/log/mongodb-mms-automation/ \ | ||
# ensure that the agent user can write the logs in OpenShift | ||
&& touch /var/log/mongodb-mms-automation/readiness.log \ | ||
&& chmod ugo+rw /var/log/mongodb-mms-automation/readiness.log | ||
|
||
|
||
COPY --from=base /data/mongodb-agent.tar.gz /agent | ||
COPY --from=base /data/mongodb-tools.tgz /agent | ||
COPY --from=base /data/LICENSE /licenses/LICENSE | ||
|
||
RUN tar xfz /agent/mongodb-agent.tar.gz \ | ||
&& mv mongodb-mms-automation-agent-*/mongodb-mms-automation-agent /agent/mongodb-agent \ | ||
&& chmod +x /agent/mongodb-agent \ | ||
&& mkdir -p /var/lib/automation/config \ | ||
&& chmod -R +r /var/lib/automation/config \ | ||
&& rm /agent/mongodb-agent.tar.gz \ | ||
&& rm -r mongodb-mms-automation-agent-* | ||
|
||
RUN tar xfz /agent/mongodb-tools.tgz --directory /var/lib/mongodb-mms-automation/ && rm /agent/mongodb-tools.tgz | ||
|
||
USER 2000 | ||
CMD ["/agent/mongodb-agent", "-cluster=/var/lib/automation/config/automation-config.json"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### Building locally | ||
|
||
For building the MongoDB Agent (non-static) image locally use the example command: | ||
|
||
TODO: What to do with label quay.expires-after=48h? | ||
```bash | ||
AGENT_VERSION="108.0.7.8810-1" | ||
TOOLS_VERSION="100.12.0" | ||
AGENT_DISTRO="rhel9_x86_64" | ||
TOOLS_DISTRO="rhel93-x86_64" | ||
docker buildx build --load --progress plain . -f docker/mongodb-agent/Dockerfile -t "mongodb-agent:${AGENT_VERSION}" \ | ||
--build-arg version="${VERSION}" \ | ||
--build-arg agent_version="${AGENT_VERSION}" \ | ||
--build-arg tools_version="${TOOLS_VERSION}" \ | ||
--build-arg agent_distro="${AGENT_DISTRO}" \ | ||
--build-arg tools_distro="${TOOLS_DISTRO}" | ||
``` |
MaciejKaras marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
ARG imagebase | ||
FROM ${imagebase} as base | ||
|
||
FROM registry.access.redhat.com/ubi9/ubi-minimal | ||
|
||
ARG version | ||
|
||
LABEL name="MongoDB Agent" \ | ||
version="${version}" \ | ||
summary="MongoDB Agent" \ | ||
description="MongoDB Agent" \ | ||
vendor="MongoDB" \ | ||
release="1" \ | ||
maintainer="support@mongodb.com" | ||
|
||
COPY --from=base /data/probe.sh /opt/scripts/probe.sh | ||
COPY --from=base /data/readinessprobe /opt/scripts/readinessprobe | ||
COPY --from=base /data/version-upgrade-hook /opt/scripts/version-upgrade-hook | ||
COPY --from=base /data/agent-launcher-lib.sh /opt/scripts/agent-launcher-lib.sh | ||
COPY --from=base /data/agent-launcher.sh /opt/scripts/agent-launcher.sh | ||
COPY --from=base /data/LICENSE /licenses/LICENSE | ||
|
||
# Replace libcurl-minimal and curl-minimal with the full versions | ||
# https://bugzilla.redhat.com/show_bug.cgi?id=1994521 | ||
RUN microdnf install -y libssh libpsl libbrotli \ | ||
&& microdnf download curl libcurl \ | ||
&& rpm -Uvh --nodeps --replacefiles "*curl*$( uname -i ).rpm" \ | ||
&& microdnf remove -y libcurl-minimal curl-minimal | ||
|
||
RUN microdnf install -y --disableplugin=subscription-manager --setopt=install_weak_deps=0 nss_wrapper | ||
# Copy-pasted from https://www.mongodb.com/docs/manual/tutorial/install-mongodb-enterprise-on-red-hat-tarball/ | ||
RUN microdnf install -y --disableplugin=subscription-manager \ | ||
cyrus-sasl cyrus-sasl-gssapi cyrus-sasl-plain krb5-libs openldap openssl xz-libs | ||
# Dependencies for the Agent | ||
RUN microdnf install -y --disableplugin=subscription-manager --setopt=install_weak_deps=0 \ | ||
net-snmp \ | ||
net-snmp-agent-libs | ||
RUN microdnf install -y --disableplugin=subscription-manager \ | ||
hostname tar gzip procps jq \ | ||
&& microdnf upgrade -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
COPY --from=base /data/mongodb_tools_ubi.tgz /tools/mongodb_tools.tgz | ||
COPY --from=base /data/mongodb_agent_ubi.tgz /agent/mongodb_agent.tgz | ||
|
||
RUN tar xfz /tools/mongodb_tools.tgz | ||
RUN mv mongodb-database-tools-*/bin/* /tools | ||
RUN chmod +x /tools/* | ||
RUN rm /tools/mongodb_tools.tgz | ||
RUN rm -rf /mongodb-database-tools-* | ||
|
||
RUN tar xfz /agent/mongodb_agent.tgz | ||
RUN mv mongodb-mms-automation-agent-*/mongodb-mms-automation-agent /agent/mongodb-agent | ||
RUN chmod +x /agent/mongodb-agent | ||
RUN rm /agent/mongodb_agent.tgz | ||
RUN rm -rf mongodb-mms-automation-agent-* | ||
|
||
RUN mkdir -p /var/lib/automation/config | ||
RUN chmod -R +r /var/lib/automation/config | ||
|
||
USER 2000 | ||
|
||
HEALTHCHECK --timeout=30s CMD ls /opt/scripts/readinessprobe || exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,20 @@ | ||
# Mongodb-Agent | ||
The agent gets released in a matrix style with the init-database image, which gets tagged with the operator version. | ||
This works by using the multi-stage pattern and build-args. First - retrieve the `init-database:<version>` and retrieve the | ||
binaries from there. Then we continue with the other steps to fully build the image. | ||
This works by using the multi-stage pattern and build-args. First - retrieve the `init-database:<version>` and retrieve the | ||
binaries from there. Then we continue with the other steps to fully build the image. | ||
|
||
### Building locally | ||
|
||
For building the MongoDB Agent image locally use the example command: | ||
|
||
```bash | ||
VERSION="108.0.7.8810-1" | ||
INIT_DATABASE_IMAGE="268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-init-database:1.1.0" | ||
MONGODB_TOOLS_URL_UBI="https://downloads.mongodb.org/tools/db/mongodb-database-tools-rhel93-x86_64-100.12.0.tgz" | ||
MONGODB_AGENT_URL_UBI="https://mciuploads.s3.amazonaws.com/mms-automation/mongodb-mms-build-agent/builds/automation-agent/prod/mongodb-mms-automation-agent-108.0.7.8810-1.rhel9_x86_64.tar.gz" | ||
docker buildx build --load --progress plain . -f docker/mongodb-agent/Dockerfile -t "mongodb-agent:${VERSION}_1.1.0" \ | ||
--build-arg version="${VERSION}" \ | ||
--build-arg init_database_image="${INIT_DATABASE_IMAGE}" \ | ||
--build-arg mongodb_tools_url_ubi="${MONGODB_TOOLS_URL_UBI}" \ | ||
--build-arg mongodb_agent_url_ubi="${MONGODB_AGENT_URL_UBI}" | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Build compilable stuff | ||
|
||
FROM public.ecr.aws/docker/library/golang:1.24 AS readiness_builder | ||
COPY . /go/src/github.com/mongodb/mongodb-kubernetes | ||
WORKDIR /go/src/github.com/mongodb/mongodb-kubernetes | ||
|
||
RUN CGO_ENABLED=0 go build -a -buildvcs=false -o /data/scripts/mmsconfiguration ./docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/edit_mms_configuration.go | ||
RUN CGO_ENABLED=0 go build -a -buildvcs=false -o /data/scripts/backup-daemon-readiness-probe ./docker/mongodb-kubernetes-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness.go | ||
|
||
# Move binaries and scripts | ||
FROM scratch AS base | ||
|
||
COPY --from=readiness_builder /data/scripts/mmsconfiguration /data/scripts/mmsconfiguration | ||
COPY --from=readiness_builder /data/scripts/backup-daemon-readiness-probe /data/scripts/backup-daemon-readiness-probe | ||
|
||
# After v2.0, when non-Static Agent images will be removed, please ensure to copy those files | ||
# into ./docker/mongodb-enterprise-ops-manager directory. Leaving it this way will make the maintenance easier. | ||
COPY ./docker/mongodb-kubernetes-init-ops-manager/scripts/docker-entry-point.sh /data/scripts | ||
COPY ./docker/mongodb-kubernetes-init-ops-manager/scripts/backup-daemon-liveness-probe.sh /data/scripts | ||
COPY ./docker/mongodb-kubernetes-init-ops-manager/LICENSE /data/licenses/mongodb-enterprise-ops-manager | ||
|
||
FROM registry.access.redhat.com/ubi9/ubi-minimal | ||
|
||
ARG version | ||
ARG om_download_url | ||
|
||
LABEL name="MongoDB Enterprise Ops Manager" \ | ||
maintainer="support@mongodb.com" \ | ||
vendor="MongoDB" \ | ||
version=${version} \ | ||
release="1" \ | ||
summary="MongoDB Enterprise Ops Manager Image" \ | ||
description="MongoDB Enterprise Ops Manager" | ||
|
||
ENV MMS_HOME=/mongodb-ops-manager | ||
ENV MMS_PROP_FILE=${MMS_HOME}/conf/conf-mms.properties | ||
ENV MMS_CONF_FILE=${MMS_HOME}/conf/mms.conf | ||
ENV MMS_LOG_DIR=${MMS_HOME}/logs | ||
ENV MMS_TMP_DIR=${MMS_HOME}/tmp | ||
|
||
EXPOSE 8080 | ||
|
||
# OpsManager docker image needs to have the MongoDB dependencies because the | ||
# backup daemon is running its database locally | ||
|
||
# Replace libcurl-minimal and curl-minimal with the full versions | ||
# https://bugzilla.redhat.com/show_bug.cgi?id=1994521 | ||
RUN microdnf install -y libssh libpsl libbrotli \ | ||
&& microdnf download curl libcurl \ | ||
&& rpm -Uvh --nodeps --replacefiles "*curl*$( uname -i ).rpm" \ | ||
&& microdnf remove -y libcurl-minimal curl-minimal | ||
|
||
RUN microdnf install --disableplugin=subscription-manager -y \ | ||
cyrus-sasl \ | ||
cyrus-sasl-gssapi \ | ||
cyrus-sasl-plain \ | ||
krb5-libs \ | ||
libpcap \ | ||
lm_sensors-libs \ | ||
net-snmp \ | ||
net-snmp-agent-libs \ | ||
openldap \ | ||
openssl \ | ||
tar \ | ||
rpm-libs \ | ||
net-tools \ | ||
procps-ng \ | ||
ncurses | ||
|
||
COPY --from=base /data/licenses /licenses/ | ||
COPY --from=base /data/scripts /opt/scripts | ||
|
||
RUN curl --fail -L -o ops_manager.tar.gz ${om_download_url} \ | ||
&& tar -xzf ops_manager.tar.gz \ | ||
&& rm ops_manager.tar.gz \ | ||
&& mv mongodb-mms* "${MMS_HOME}" | ||
|
||
# permissions | ||
RUN chmod -R 0777 "${MMS_LOG_DIR}" \ | ||
&& chmod -R 0777 "${MMS_TMP_DIR}" \ | ||
&& chmod -R 0775 "${MMS_HOME}/conf" \ | ||
&& chmod -R 0775 "${MMS_HOME}/jdk" \ | ||
&& mkdir "${MMS_HOME}/mongodb-releases/" \ | ||
&& chmod -R 0775 "${MMS_HOME}/mongodb-releases" \ | ||
&& chmod -R 0777 "${MMS_CONF_FILE}" \ | ||
&& chmod -R 0777 "${MMS_PROP_FILE}" | ||
|
||
# The "${MMS_HOME}/conf" will be populated by the docker-entry-point.sh. | ||
# For now we need to move into the templates directory. | ||
RUN cp -r "${MMS_HOME}/conf" "${MMS_HOME}/conf-template" | ||
|
||
USER 2000 | ||
|
||
# operator to change the entrypoint to: /mongodb-ops-manager/bin/mongodb-mms start_mms (or a wrapper around this) | ||
ENTRYPOINT [ "sleep infinity" ] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
### Building locally | ||
|
||
For building the MongoDB Enterprise Ops Manager Docker image locally use the example command: | ||
|
||
```bash | ||
VERSION="8.0.7" | ||
OM_DOWNLOAD_URL="https://downloads.mongodb.com/on-prem-mms/tar/mongodb-mms-8.0.7.500.20250505T1426Z.tar.gz" | ||
docker buildx build --load --progress plain . -f docker/mongodb-enterprise-ops-manager/Dockerfile -t "mongodb-enterprise-ops-manager:${VERSION}" \ | ||
--build-arg version="${VERSION}" \ | ||
--build-arg om_download_url="${OM_DOWNLOAD_URL}" | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For review: Dockerfile.old files are the copy of the initial Dockerfile