From 85fd92220ce141e49cf8a5ad904ca2e18dfcc088 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Khan-Sunde Date: Tue, 20 Oct 2026 00:53:38 +0200 Subject: [PATCH] Keep only the image: one main branch, the recipe in image/, and a publish that ends green when nothing is new The repository publishes one image, so it keeps only the files of that image. - The recipe moves from 8.0/ to image/ (Dockerfile and docker-entrypoint.sh). publish.ps1 builds ./image. The ARG defaults of the Dockerfile now match publish.ps1 (MONGO_MAJOR and MONGOSH_CHANNEL 9.0, not 8.3), and "Publish image" checks all three, not only MONGO_VERSION. - The upstream docker-library files are gone: 7.0/, the Windows folders, the templates, apply-templates.sh, update.sh, versions.json, versions.sh, generate-stackbrew-library.sh, pgp-keys.json, pgp-keys.sh (the Dockerfile downloads its keys itself), the root docker-entrypoint.sh, the "Verify Templating" workflow, .gitattributes and .gitignore. - "Publish image" publishes on a push to main that changes publish.ps1 or image/. When the tag is published and the push did not change the version in publish.ps1, it ends green with the notice "Nothing to publish". A push that changes the version to a published tag still fails. Pull requests still get a dry run. - AGENTS.md describes one main branch: a GA patch, minor or major is a change of publish.ps1 and image/Dockerfile (plus the signing key of a new major) in a pull request into main, and the merge publishes. There is no default-branch switch. README.md describes this repository. --- .gitattributes | 3 - .github/workflows/publish.yml | 92 +++- .github/workflows/verify-templating.yml | 19 - .gitignore | 1 - 7.0/Dockerfile | 121 ----- 7.0/windows/nanoserver-ltsc2022/Dockerfile | 34 -- .../windowsservercore-ltsc2022/Dockerfile | 67 --- .../windowsservercore-ltsc2025/Dockerfile | 67 --- 8.0/docker-entrypoint.sh | 420 ------------------ 8.0/windows/nanoserver-ltsc2022/Dockerfile | 34 -- .../windowsservercore-ltsc2022/Dockerfile | 67 --- .../windowsservercore-ltsc2025/Dockerfile | 67 --- AGENTS.md | 238 +++++----- Dockerfile-linux.template | 134 ------ Dockerfile-windows.template | 101 ----- README.md | 18 +- apply-templates.sh | 75 ---- docker-entrypoint.sh | 420 ------------------ generate-stackbrew-library.sh | 160 ------- {8.0 => image}/Dockerfile | 15 +- {7.0 => image}/docker-entrypoint.sh | 0 pgp-keys.json | 50 --- pgp-keys.sh | 37 -- publish.ps1 | 2 +- update.sh | 7 - versions.json | 139 ------ versions.sh | 244 ---------- 27 files changed, 191 insertions(+), 2441 deletions(-) delete mode 100644 .gitattributes delete mode 100644 .github/workflows/verify-templating.yml delete mode 100644 .gitignore delete mode 100644 7.0/Dockerfile delete mode 100644 7.0/windows/nanoserver-ltsc2022/Dockerfile delete mode 100644 7.0/windows/windowsservercore-ltsc2022/Dockerfile delete mode 100644 7.0/windows/windowsservercore-ltsc2025/Dockerfile delete mode 100755 8.0/docker-entrypoint.sh delete mode 100644 8.0/windows/nanoserver-ltsc2022/Dockerfile delete mode 100644 8.0/windows/windowsservercore-ltsc2022/Dockerfile delete mode 100644 8.0/windows/windowsservercore-ltsc2025/Dockerfile delete mode 100644 Dockerfile-linux.template delete mode 100644 Dockerfile-windows.template delete mode 100755 apply-templates.sh delete mode 100755 docker-entrypoint.sh delete mode 100755 generate-stackbrew-library.sh rename {8.0 => image}/Dockerfile (93%) rename {7.0 => image}/docker-entrypoint.sh (100%) delete mode 100644 pgp-keys.json delete mode 100755 pgp-keys.sh delete mode 100755 update.sh delete mode 100644 versions.json delete mode 100755 versions.sh diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 14a112269e..0000000000 --- a/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -/*/**/Dockerfile linguist-generated -/*/**/docker-entrypoint.sh linguist-generated -/Dockerfile*.template linguist-language=Dockerfile diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e38a3e4a23..7806123c1b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,11 +1,13 @@ name: Publish image -# Builds ./8.0 once with the build arguments of publish.ps1, checks the +# Builds ./image once with the build arguments of publish.ps1, checks the # Enterprise package inventory and `mongod --version` of that image, and gives # its digest the tag ghcr.io/fintermobilityas/mongo-enterprise: # with this job's token. # -# - A push to a finter-* branch that changes publish.ps1 or 8.0/Dockerfile publishes. +# - A push to main that changes publish.ps1 or image/ publishes. When the tag is +# published already and the push did not change the version in publish.ps1, +# there is nothing to publish and the run ends green. # - workflow_dispatch builds and checks only, unless the `push` input is true. # - A pull request builds and checks only. # @@ -15,14 +17,14 @@ name: Publish image on: push: branches: - - 'finter-*' + - main paths: - publish.ps1 - - 8.0/Dockerfile + - 'image/**' pull_request: paths: - publish.ps1 - - 8.0/Dockerfile + - 'image/**' - .github/workflows/publish.yml workflow_dispatch: inputs: @@ -61,17 +63,23 @@ jobs: - name: Read the build arguments from publish.ps1 shell: pwsh + env: + BEFORE: ${{ github.event.before }} run: | - $parseErrors = $null - $ast = [System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path publish.ps1).Path, [ref]$null, [ref]$parseErrors) - if ($parseErrors.Count -gt 0) { throw "publish.ps1 does not parse: $($parseErrors -join '; ')" } - - $defaults = @{} - foreach ($parameter in $ast.ParamBlock.Parameters) { - $value = if ($parameter.DefaultValue) { [string]$parameter.DefaultValue.SafeGetValue() } else { '' } - $defaults[$parameter.Name.VariablePath.UserPath] = $value + function Get-Defaults([string]$source) { + $parseErrors = $null + $ast = [System.Management.Automation.Language.Parser]::ParseInput($source, [ref]$null, [ref]$parseErrors) + if ($parseErrors.Count -gt 0) { throw "publish.ps1 does not parse: $($parseErrors -join '; ')" } + $values = @{} + foreach ($parameter in $ast.ParamBlock.Parameters) { + $value = if ($parameter.DefaultValue) { [string]$parameter.DefaultValue.SafeGetValue() } else { '' } + $values[$parameter.Name.VariablePath.UserPath] = $value + } + $values } + $defaults = Get-Defaults (Get-Content -Raw publish.ps1) + $names = [ordered]@{ MongoVersion = 'VERSION' MongoPackageVersion = 'PACKAGE_VERSION' @@ -86,13 +94,35 @@ jobs: } if (-not $defaults.MongoVersion) { throw 'publish.ps1 has an empty $MongoVersion' } - - name: Check that 8.0/Dockerfile matches publish.ps1 + # The version before this push. A push that does not change it has + # nothing to publish when its tag exists (the tag check below). + $previous = '' + if ($env:GITHUB_EVENT_NAME -eq 'push' -and $env:BEFORE -match '^[0-9a-f]{40}$' -and $env:BEFORE -notmatch '^0+$') { + git fetch --no-tags --depth=1 origin $env:BEFORE + if ($LASTEXITCODE -eq 0) { + $source = git show "$($env:BEFORE):publish.ps1" + if ($LASTEXITCODE -eq 0) { + try { $previous = [string](Get-Defaults ($source -join "`n")).MongoVersion } catch { $previous = '' } + } + } + $global:LASTEXITCODE = 0 + } + "PREVIOUS_VERSION=$previous" >> $env:GITHUB_ENV + "Version before this push: $(if ($previous) { $previous } else { 'unknown' })" + + - name: Check that image/Dockerfile matches publish.ps1 run: | - dockerfile_version=$(sed -n 's/^ARG MONGO_VERSION=//p' 8.0/Dockerfile) - if [ "$dockerfile_version" != "$PACKAGE_VERSION" ]; then - echo "::error::8.0/Dockerfile has ARG MONGO_VERSION=$dockerfile_version, publish.ps1 has \$MongoPackageVersion = $PACKAGE_VERSION" - exit 1 - fi + check() { + local value + value=$(sed -n "s/^ARG $1=//p" image/Dockerfile) + if [ "$value" != "$3" ]; then + echo "::error::image/Dockerfile has ARG $1=$value, publish.ps1 has \$$2 = $3" + exit 1 + fi + } + check MONGO_VERSION MongoPackageVersion "$PACKAGE_VERSION" + check MONGO_MAJOR MongoAptChannel "$APT_CHANNEL" + check MONGOSH_CHANNEL MongoMongoshChannel "$MONGOSH_CHANNEL" # The same arguments, in the same order, as publish.ps1 passes to docker build. : > "$RUNNER_TEMP/build-args" @@ -131,14 +161,21 @@ jobs: fi if jq -e --arg tag "$VERSION" 'any((.tags // [])[]; . == $tag)' "$RUNNER_TEMP/tags.json" > /dev/null; then - echo "::error::${IMAGE}:${VERSION} already exists. Published tags are never overwritten; bump the version in publish.ps1 and 8.0/Dockerfile." + if [ "$GITHUB_EVENT_NAME" = push ] && [ "$PREVIOUS_VERSION" = "$VERSION" ]; then + echo "::notice::Nothing to publish: ${IMAGE}:${VERSION} is published, and this push did not change the version in publish.ps1." + echo "SKIP=true" >> "$GITHUB_ENV" + exit 0 + fi + echo "::error::${IMAGE}:${VERSION} already exists. Published tags are never overwritten; bump the version in publish.ps1 and image/Dockerfile." exit 1 fi echo "${IMAGE}:${VERSION} is not published yet." - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + if: env.SKIP != 'true' - - name: Build ./8.0 + - name: Build ./image + if: env.SKIP != 'true' run: | mapfile -t build_args < "$RUNNER_TEMP/build-args" if [ "$PUSH" = true ]; then @@ -147,18 +184,19 @@ jobs: # A run that fails a check leaves an untagged version in the package. docker buildx build "${build_args[@]}" --platform linux/amd64 --provenance=mode=min \ --output "type=image,name=${IMAGE},push-by-digest=true,push=true" \ - --metadata-file "$RUNNER_TEMP/metadata.json" ./8.0 + --metadata-file "$RUNNER_TEMP/metadata.json" ./image digest=$(jq -er '."containerimage.digest"' "$RUNNER_TEMP/metadata.json") docker pull --platform linux/amd64 "${IMAGE}@${digest}" echo "DIGEST=${digest}" >> "$GITHUB_ENV" echo "CHECK_IMAGE=${IMAGE}@${digest}" >> "$GITHUB_ENV" else docker buildx build "${build_args[@]}" --platform linux/amd64 --load \ - -t "mongo-enterprise:${VERSION}" ./8.0 + -t "mongo-enterprise:${VERSION}" ./image echo "CHECK_IMAGE=mongo-enterprise:${VERSION}" >> "$GITHUB_ENV" fi - name: Check the package inventory + if: env.SKIP != 'true' run: | docker run --rm --entrypoint dpkg-query "$CHECK_IMAGE" \ -W '-f=${Package} ${db:Status-Status} ${Version}\n' \ @@ -187,6 +225,7 @@ jobs: done - name: Check mongod --version + if: env.SKIP != 'true' run: | output=$(docker run --rm -e GLIBC_TUNABLES=glibc.pthread.rseq=1 "$CHECK_IMAGE" mongod --version) echo "$output" @@ -205,7 +244,7 @@ jobs: echo "MONGOD_VERSION=${mongod_version}" >> "$GITHUB_ENV" - name: Check the provenance and tag the checked image - if: env.PUSH == 'true' + if: env.PUSH == 'true' && env.SKIP != 'true' run: | docker buildx imagetools inspect "${IMAGE}@${DIGEST}" provenance=$(docker buildx imagetools inspect "${IMAGE}@${DIGEST}" --format '{{json .Provenance}}') @@ -250,3 +289,8 @@ jobs: echo "- Packages:" sed 's/^/ - /' "$RUNNER_TEMP/packages.txt" } >> "$GITHUB_STEP_SUMMARY" + + - name: Summarize a push with nothing to publish + if: env.SKIP == 'true' + run: | + echo "### Nothing to publish: ${IMAGE}:${VERSION} is published, and this push did not change the version" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/verify-templating.yml b/.github/workflows/verify-templating.yml deleted file mode 100644 index e822ba6bb9..0000000000 --- a/.github/workflows/verify-templating.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Verify Templating - -on: - pull_request: - push: - workflow_dispatch: - -defaults: - run: - shell: 'bash -Eeuo pipefail -x {0}' - -jobs: - apply-templates: - name: Check For Uncomitted Changes - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: ./apply-templates.sh - - run: git diff --exit-code diff --git a/.gitignore b/.gitignore deleted file mode 100644 index d548f66de0..0000000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.jq-template.awk diff --git a/7.0/Dockerfile b/7.0/Dockerfile deleted file mode 100644 index 707b51711b..0000000000 --- a/7.0/Dockerfile +++ /dev/null @@ -1,121 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" -# -# PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM ubuntu:jammy - -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN set -eux; \ - groupadd --gid 999 --system mongodb; \ - useradd --uid 999 --system --gid mongodb --home-dir /data/db mongodb; \ - mkdir -p /data/db /data/configdb; \ - chown -R mongodb:mongodb /data/db /data/configdb - -RUN set -eux; \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - jq \ - numactl \ - procps \ - ; \ - rm -rf /var/lib/apt/lists/* - -# grab gosu for easy step-down from root (https://github.com/tianon/gosu/releases) -ENV GOSU_VERSION 1.19 -# grab "js-yaml" for parsing mongod's YAML config files (https://github.com/nodeca/js-yaml/releases) -ENV JSYAML_VERSION 3.13.1 -ENV JSYAML_CHECKSUM 662e32319bdd378e91f67578e56a34954b0a2e33aca11d70ab9f4826af24b941 - -RUN set -eux; \ - \ - savedAptMark="$(apt-mark showmanual)"; \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - gnupg \ - wget \ - ; \ - rm -rf /var/lib/apt/lists/*; \ - \ -# download/install gosu - dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \ - wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ - wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ - export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ - gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ - gpgconf --kill all; \ - rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \ - \ -# download/install js-yaml - mkdir -p /opt/js-yaml/; \ - wget -O /opt/js-yaml/js-yaml.tgz https://registry.npmjs.org/js-yaml/-/js-yaml-${JSYAML_VERSION}.tgz; \ - echo "$JSYAML_CHECKSUM */opt/js-yaml/js-yaml.tgz" | sha256sum -c -; \ - tar -xz --strip-components=1 -f /opt/js-yaml/js-yaml.tgz -C /opt/js-yaml package/dist/js-yaml.js package/package.json; \ - rm /opt/js-yaml/js-yaml.tgz; \ - ln -s /opt/js-yaml/dist/js-yaml.js /js-yaml.js; \ - \ -# download/install MongoDB PGP keys - export GNUPGHOME="$(mktemp -d)"; \ - wget -O KEYS 'https://pgp.mongodb.com/server-7.0.asc'; \ - gpg --batch --import KEYS; \ - mkdir -p /etc/apt/keyrings; \ - gpg --batch --export --armor 'E58830201F7DD82CD808AA84160D26BB1785BA38' > /etc/apt/keyrings/mongodb.asc; \ - gpgconf --kill all; \ - rm -rf "$GNUPGHOME" KEYS; \ - \ - apt-mark auto '.*' > /dev/null; \ - apt-mark manual $savedAptMark > /dev/null; \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ - \ -# smoke test - chmod +x /usr/local/bin/gosu; \ - gosu --version; \ - gosu nobody true - -RUN mkdir /docker-entrypoint-initdb.d - -# Allow build-time overrides (eg. to build image with MongoDB Enterprise version) -# Options for MONGO_PACKAGE: mongodb-org OR mongodb-enterprise -# Options for MONGO_REPO: repo.mongodb.org OR repo.mongodb.com -# Example: docker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com . -ARG MONGO_PACKAGE=mongodb-org -ARG MONGO_REPO=repo.mongodb.org -ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO} - -ENV MONGO_MAJOR 7.0 -RUN echo "deb [ signed-by=/etc/apt/keyrings/mongodb.asc ] http://$MONGO_REPO/apt/ubuntu jammy/${MONGO_PACKAGE%-unstable}/$MONGO_MAJOR multiverse" | tee "/etc/apt/sources.list.d/${MONGO_PACKAGE%-unstable}.list" - -# https://docs.mongodb.org/master/release-notes/7.0/ -ENV MONGO_VERSION 7.0.45 -# 09/24/2026, https://github.com/mongodb/mongo/tree/a52313e13ab55c9bddf7c3ff91dab286fa381796 - -RUN set -x \ -# installing "mongodb-enterprise" pulls in "tzdata" which prompts for input - && export DEBIAN_FRONTEND=noninteractive \ - && apt-get update \ - && apt-get install -y \ - ${MONGO_PACKAGE}=$MONGO_VERSION \ - ${MONGO_PACKAGE}-server=$MONGO_VERSION \ - ${MONGO_PACKAGE}-shell=$MONGO_VERSION \ - ${MONGO_PACKAGE}-mongos=$MONGO_VERSION \ - ${MONGO_PACKAGE}-tools=$MONGO_VERSION \ - ${MONGO_PACKAGE}-database=$MONGO_VERSION \ - ${MONGO_PACKAGE}-database-tools-extra=$MONGO_VERSION \ - && rm -rf /var/lib/apt/lists/* \ - && rm -rf /var/lib/mongodb \ - && mv /etc/mongod.conf /etc/mongod.conf.orig - -VOLUME /data/db /data/configdb - -# ensure that if running as custom user that "mongosh" has a valid "HOME" -# https://github.com/docker-library/mongo/issues/524 -ENV HOME /data/db - -COPY docker-entrypoint.sh /usr/local/bin/ -ENTRYPOINT ["docker-entrypoint.sh"] - -EXPOSE 27017 -CMD ["mongod"] diff --git a/7.0/windows/nanoserver-ltsc2022/Dockerfile b/7.0/windows/nanoserver-ltsc2022/Dockerfile deleted file mode 100644 index 4dcca5329f..0000000000 --- a/7.0/windows/nanoserver-ltsc2022/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" -# -# PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 - -SHELL ["cmd", "/S", "/C"] - -# PATH isn't actually set in the Docker image, so we have to set it from within the container -USER ContainerAdministrator -RUN setx /m PATH "C:\mongodb\bin;%PATH%" -USER ContainerUser -# doing this first to share cache across versions more aggressively - -COPY --from=mongo:7.0.45-windowsservercore-ltsc2022 \ - C:\\Windows\\System32\\msvcp140.dll \ - C:\\Windows\\System32\\msvcp140_1.dll \ - C:\\Windows\\System32\\vcruntime140.dll \ - C:\\Windows\\System32\\vcruntime140_1.dll \ - C:\\Windows\\System32\\ - -# https://docs.mongodb.org/master/release-notes/7.0/ -ENV MONGO_VERSION 7.0.45 -# 09/24/2026, https://github.com/mongodb/mongo/tree/a52313e13ab55c9bddf7c3ff91dab286fa381796 - -COPY --from=mongo:7.0.45-windowsservercore-ltsc2022 C:\\mongodb C:\\mongodb -RUN mongod --version - -VOLUME C:\\data\\db C:\\data\\configdb - -EXPOSE 27017 -CMD ["mongod", "--bind_ip_all"] diff --git a/7.0/windows/windowsservercore-ltsc2022/Dockerfile b/7.0/windows/windowsservercore-ltsc2022/Dockerfile deleted file mode 100644 index fc69b520ea..0000000000 --- a/7.0/windows/windowsservercore-ltsc2022/Dockerfile +++ /dev/null @@ -1,67 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" -# -# PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM mcr.microsoft.com/windows/servercore:ltsc2022 - -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] - -# https://docs.mongodb.org/master/release-notes/7.0/ -ENV MONGO_VERSION 7.0.45 -# 09/24/2026, https://github.com/mongodb/mongo/tree/a52313e13ab55c9bddf7c3ff91dab286fa381796 - -ENV MONGO_DOWNLOAD_URL https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-7.0.45-signed.msi -ENV MONGO_DOWNLOAD_SHA256=c523c13eec4bfe0900f6d0a4db9f7033276bafeda6786f388297c59f13eaee63 - -RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ - (New-Object System.Net.WebClient).DownloadFile($env:MONGO_DOWNLOAD_URL, 'mongo.msi'); \ - \ - if ($env:MONGO_DOWNLOAD_SHA256) { \ - Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256); \ - if ((Get-FileHash mongo.msi -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { \ - Write-Host 'FAILED!'; \ - exit 1; \ - }; \ - }; \ - \ - Write-Host 'Installing ...'; \ -# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#install-mongodb-community-edition - Start-Process msiexec -Wait \ - -ArgumentList @( \ - '/i', \ - 'mongo.msi', \ - '/quiet', \ - '/qn', \ - '/l*v', 'install.log', \ -# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter - 'INSTALLLOCATION=C:\mongodb', \ - 'ADDLOCAL=MiscellaneousTools,Router,ServerNoService' \ - ); \ - if (-Not (Test-Path C:\mongodb\bin\mongod.exe -PathType Leaf)) { \ - Write-Host 'Installer failed!'; \ - Get-Content install.log; \ - exit 1; \ - }; \ - Remove-Item install.log; \ - \ - $env:PATH = 'C:\mongodb\bin;' + $env:PATH; \ - [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \ - \ - Write-Host 'Verifying install ...'; \ - Write-Host ' mongod --version'; mongod --version; \ - \ - Write-Host 'Removing ...'; \ - Remove-Item C:\windows\installer\*.msi -Force; \ - Remove-Item mongo.msi -Force; \ - \ - Write-Host 'Complete.'; - -# TODO docker-entrypoint.ps1 ? (for "docker run --flag --flag --flag") - -VOLUME C:\\data\\db C:\\data\\configdb - -EXPOSE 27017 -CMD ["mongod", "--bind_ip_all"] diff --git a/7.0/windows/windowsservercore-ltsc2025/Dockerfile b/7.0/windows/windowsservercore-ltsc2025/Dockerfile deleted file mode 100644 index 71e0df0feb..0000000000 --- a/7.0/windows/windowsservercore-ltsc2025/Dockerfile +++ /dev/null @@ -1,67 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" -# -# PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM mcr.microsoft.com/windows/servercore:ltsc2025 - -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] - -# https://docs.mongodb.org/master/release-notes/7.0/ -ENV MONGO_VERSION 7.0.45 -# 09/24/2026, https://github.com/mongodb/mongo/tree/a52313e13ab55c9bddf7c3ff91dab286fa381796 - -ENV MONGO_DOWNLOAD_URL https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-7.0.45-signed.msi -ENV MONGO_DOWNLOAD_SHA256=c523c13eec4bfe0900f6d0a4db9f7033276bafeda6786f388297c59f13eaee63 - -RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ - (New-Object System.Net.WebClient).DownloadFile($env:MONGO_DOWNLOAD_URL, 'mongo.msi'); \ - \ - if ($env:MONGO_DOWNLOAD_SHA256) { \ - Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256); \ - if ((Get-FileHash mongo.msi -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { \ - Write-Host 'FAILED!'; \ - exit 1; \ - }; \ - }; \ - \ - Write-Host 'Installing ...'; \ -# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#install-mongodb-community-edition - Start-Process msiexec -Wait \ - -ArgumentList @( \ - '/i', \ - 'mongo.msi', \ - '/quiet', \ - '/qn', \ - '/l*v', 'install.log', \ -# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter - 'INSTALLLOCATION=C:\mongodb', \ - 'ADDLOCAL=MiscellaneousTools,Router,ServerNoService' \ - ); \ - if (-Not (Test-Path C:\mongodb\bin\mongod.exe -PathType Leaf)) { \ - Write-Host 'Installer failed!'; \ - Get-Content install.log; \ - exit 1; \ - }; \ - Remove-Item install.log; \ - \ - $env:PATH = 'C:\mongodb\bin;' + $env:PATH; \ - [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \ - \ - Write-Host 'Verifying install ...'; \ - Write-Host ' mongod --version'; mongod --version; \ - \ - Write-Host 'Removing ...'; \ - Remove-Item C:\windows\installer\*.msi -Force; \ - Remove-Item mongo.msi -Force; \ - \ - Write-Host 'Complete.'; - -# TODO docker-entrypoint.ps1 ? (for "docker run --flag --flag --flag") - -VOLUME C:\\data\\db C:\\data\\configdb - -EXPOSE 27017 -CMD ["mongod", "--bind_ip_all"] diff --git a/8.0/docker-entrypoint.sh b/8.0/docker-entrypoint.sh deleted file mode 100755 index d37d1b92bb..0000000000 --- a/8.0/docker-entrypoint.sh +++ /dev/null @@ -1,420 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail - -if [ "${1:0:1}" = '-' ]; then - set -- mongod "$@" -fi - -originalArgOne="$1" - -# allow the container to be started with `--user` -# all mongo* commands should be dropped to the correct user -if [[ "$originalArgOne" == mongo* ]] && [ "$(id -u)" = '0' ]; then - if [ "$originalArgOne" = 'mongod' ]; then - find -L /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}' + - fi - - # make sure we can write to stdout and stderr as "mongodb" - # (for our "initdb" code later; see "--logpath" below) - chown --dereference mongodb "/proc/$$/fd/1" "/proc/$$/fd/2" || : - # ignore errors thanks to https://github.com/docker-library/mongo/issues/149 - - exec gosu mongodb "$BASH_SOURCE" "$@" -fi - -dpkgArch="$(dpkg --print-architecture)" -case "$dpkgArch" in - amd64) # https://github.com/docker-library/mongo/issues/485#issuecomment-891991814 - if ! grep -qE '^flags.* avx( .*|$)' /proc/cpuinfo; then - { - echo - echo 'WARNING: MongoDB 5.0+ requires a CPU with AVX support, and your current system does not appear to have that!' - echo ' see https://jira.mongodb.org/browse/SERVER-54407' - echo ' see also https://www.mongodb.com/community/forums/t/mongodb-5-0-cpu-intel-g4650-compatibility/116610/2' - echo ' see also https://github.com/docker-library/mongo/issues/485#issuecomment-891991814' - echo - } >&2 - fi - ;; - - arm64) # https://github.com/docker-library/mongo/issues/485#issuecomment-970864306 - # https://en.wikichip.org/wiki/arm/armv8#ARMv8_Extensions_and_Processor_Features - # http://javathunderx.blogspot.com/2018/11/cheat-sheet-for-cpuinfo-features-on.html - if ! grep -qE '^Features.* (fphp|dcpop|sha3|sm3|sm4|asimddp|sha512|sve)( .*|$)' /proc/cpuinfo; then - { - echo - echo 'WARNING: MongoDB requires ARMv8.2-A or higher, and your current system does not appear to implement any of the common features for that!' - echo ' applies to all versions ≥5.0, any of 4.4 ≥4.4.19' - echo ' see https://jira.mongodb.org/browse/SERVER-71772' - echo ' see https://jira.mongodb.org/browse/SERVER-55178' - echo ' see also https://en.wikichip.org/wiki/arm/armv8#ARMv8_Extensions_and_Processor_Features' - echo ' see also https://github.com/docker-library/mongo/issues/485#issuecomment-970864306' - echo - } >&2 - fi - ;; -esac - -# you should use numactl to start your mongod instances, including the config servers, mongos instances, and any clients. -# https://docs.mongodb.com/manual/administration/production-notes/#configuring-numa-on-linux -if [[ "$originalArgOne" == mongo* ]]; then - numa='numactl --interleave=all' - if $numa true &> /dev/null; then - set -- $numa "$@" - fi -fi - -# usage: file_env VAR [DEFAULT] -# ie: file_env 'XYZ_DB_PASSWORD' 'example' -# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of -# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) -file_env() { - local var="$1" - local fileVar="${var}_FILE" - local def="${2:-}" - if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then - echo >&2 "error: both $var and $fileVar are set (but are exclusive)" - exit 1 - fi - local val="$def" - if [ "${!var:-}" ]; then - val="${!var}" - elif [ "${!fileVar:-}" ]; then - val="$(< "${!fileVar}")" - fi - export "$var"="$val" - unset "$fileVar" -} - -# see https://github.com/docker-library/mongo/issues/147 (mongod is picky about duplicated arguments) -_mongod_hack_have_arg() { - local checkArg="$1"; shift - local arg - for arg; do - case "$arg" in - "$checkArg"|"$checkArg"=*) - return 0 - ;; - esac - done - return 1 -} -# _mongod_hack_get_arg_val '--some-arg' "$@" -_mongod_hack_get_arg_val() { - local checkArg="$1"; shift - while [ "$#" -gt 0 ]; do - local arg="$1"; shift - case "$arg" in - "$checkArg") - echo "$1" - return 0 - ;; - "$checkArg"=*) - echo "${arg#$checkArg=}" - return 0 - ;; - esac - done - return 1 -} -declare -a mongodHackedArgs -# _mongod_hack_ensure_arg '--some-arg' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_arg() { - local ensureArg="$1"; shift - mongodHackedArgs=( "$@" ) - if ! _mongod_hack_have_arg "$ensureArg" "$@"; then - mongodHackedArgs+=( "$ensureArg" ) - fi -} -# _mongod_hack_ensure_no_arg '--some-unwanted-arg' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_no_arg() { - local ensureNoArg="$1"; shift - mongodHackedArgs=() - while [ "$#" -gt 0 ]; do - local arg="$1"; shift - if [ "$arg" = "$ensureNoArg" ]; then - continue - fi - mongodHackedArgs+=( "$arg" ) - done -} -# _mongod_hack_ensure_no_arg '--some-unwanted-arg' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_no_arg_val() { - local ensureNoArg="$1"; shift - mongodHackedArgs=() - while [ "$#" -gt 0 ]; do - local arg="$1"; shift - case "$arg" in - "$ensureNoArg") - shift # also skip the value - continue - ;; - "$ensureNoArg"=*) - # value is already included - continue - ;; - esac - mongodHackedArgs+=( "$arg" ) - done -} -# _mongod_hack_ensure_arg_val '--some-arg' 'some-val' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_arg_val() { - local ensureArg="$1"; shift - local ensureVal="$1"; shift - _mongod_hack_ensure_no_arg_val "$ensureArg" "$@" - mongodHackedArgs+=( "$ensureArg" "$ensureVal" ) -} - -# _js_escape 'some "string" value' -_js_escape() { - jq --null-input --arg 'str' "$1" '$str' -} - -: "${TMPDIR:=/tmp}" -jsonConfigFile="$TMPDIR/docker-entrypoint-config.json" -tempConfigFile="$TMPDIR/docker-entrypoint-temp-config.json" -_parse_config() { - if [ -s "$tempConfigFile" ]; then - return 0 - fi - - local configPath - if configPath="$(_mongod_hack_get_arg_val --config "$@")" && [ -s "$configPath" ]; then - # if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys) - # see https://docs.mongodb.com/manual/reference/configuration-options/ - if grep -vEm1 '^[[:space:]]*(#|$)' "$configPath" | grep -qE '^[[:space:]]*[^=:]+[[:space:]]*='; then - # if the first non-comment/non-blank line of the config file looks like "foo = ...", this is probably the 2.4 and older "ini-style config format" - # mongod tries to parse config as yaml and then falls back to ini-style parsing - # https://github.com/mongodb/mongo/blob/r6.0.3/src/mongo/util/options_parser/options_parser.cpp#L1883-L1894 - echo >&2 - echo >&2 "WARNING: it appears that '$configPath' is in the older INI-style format (replaced by YAML in MongoDB 2.6)" - echo >&2 ' This script does not parse the older INI-style format, and thus will ignore it.' - echo >&2 - return 1 - fi - if [ "$mongoShell" = 'mongo' ]; then - "$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile" - else - # https://www.mongodb.com/docs/manual/reference/method/js-native/#std-label-native-in-mongosh - "$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); JSON.stringify(jsyaml.load(fs.readFileSync($(_js_escape "$configPath"), 'utf8')))" > "$jsonConfigFile" - fi - if [ "$(head -c1 "$jsonConfigFile")" != '{' ] || [ "$(tail -c2 "$jsonConfigFile")" != '}' ]; then - # if the file doesn't start with "{" and end with "}", it's *probably* an error ("uncaught exception: YAMLException: foo" for example), so we should print it out - echo >&2 'error: unexpected "js-yaml.js" output while parsing config:' - cat >&2 "$jsonConfigFile" - exit 1 - fi - jq 'del(.systemLog, .processManagement, .net, .security, .replication)' "$jsonConfigFile" > "$tempConfigFile" - return 0 - fi - - return 1 -} -dbPath= -_dbPath() { - if [ -n "$dbPath" ]; then - echo "$dbPath" - return - fi - - if ! dbPath="$(_mongod_hack_get_arg_val --dbpath "$@")"; then - if _parse_config "$@"; then - dbPath="$(jq -r '.storage.dbPath // empty' "$jsonConfigFile")" - fi - fi - - if [ -z "$dbPath" ]; then - if _mongod_hack_have_arg --configsvr "$@" || { - _parse_config "$@" \ - && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ - && [ "$clusterRole" = 'configsvr' ] - }; then - # if running as config server, then the default dbpath is /data/configdb - # https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr - dbPath=/data/configdb - fi - fi - - : "${dbPath:=/data/db}" - - echo "$dbPath" -} - -if [ "$originalArgOne" = 'mongod' ]; then - file_env 'MONGO_INITDB_ROOT_USERNAME' - file_env 'MONGO_INITDB_ROOT_PASSWORD' - - mongoShell='mongo' - if ! command -v "$mongoShell" > /dev/null; then - mongoShell='mongosh' - fi - - # pre-check a few factors to see if it's even worth bothering with initdb - shouldPerformInitdb= - if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - # if we have a username/password, let's set "--auth" - _mongod_hack_ensure_arg '--auth' "$@" - set -- "${mongodHackedArgs[@]}" - shouldPerformInitdb='true' - elif [ "$MONGO_INITDB_ROOT_USERNAME" ] || [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - cat >&2 <<-'EOF' - - error: missing 'MONGO_INITDB_ROOT_USERNAME' or 'MONGO_INITDB_ROOT_PASSWORD' - both must be specified for a user to be created - - EOF - exit 1 - fi - - if [ -z "$shouldPerformInitdb" ]; then - # if we've got any /docker-entrypoint-initdb.d/* files to parse later, we should initdb - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh|*.js) # this should match the set of files we check for below - shouldPerformInitdb="$f" - break - ;; - esac - done - fi - - # check for a few known paths (to determine whether we've already initialized and should thus skip our initdb scripts) - if [ -n "$shouldPerformInitdb" ]; then - dbPath="$(_dbPath "$@")" - for path in \ - "$dbPath/WiredTiger" \ - "$dbPath/journal" \ - "$dbPath/local.0" \ - "$dbPath/storage.bson" \ - ; do - if [ -e "$path" ]; then - shouldPerformInitdb= - break - fi - done - fi - - if [ -n "$shouldPerformInitdb" ]; then - mongodHackedArgs=( "$@" ) - if _parse_config "$@"; then - _mongod_hack_ensure_arg_val --config "$tempConfigFile" "${mongodHackedArgs[@]}" - fi - _mongod_hack_ensure_arg_val --bind_ip 127.0.0.1 "${mongodHackedArgs[@]}" - _mongod_hack_ensure_arg_val --port 27017 "${mongodHackedArgs[@]}" - _mongod_hack_ensure_no_arg --bind_ip_all "${mongodHackedArgs[@]}" - - # remove "--auth" and "--replSet" for our initial startup (see https://docs.mongodb.com/manual/tutorial/enable-authentication/#start-mongodb-without-access-control) - # https://github.com/docker-library/mongo/issues/211 - _mongod_hack_ensure_no_arg --auth "${mongodHackedArgs[@]}" - # "keyFile implies security.authorization" - # https://docs.mongodb.com/manual/reference/configuration-options/#mongodb-setting-security.keyFile - _mongod_hack_ensure_no_arg_val --keyFile "${mongodHackedArgs[@]}" - if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - _mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}" - fi - - # "BadValue: need sslPEMKeyFile when SSL is enabled" vs "BadValue: need to enable SSL via the sslMode flag when using SSL configuration parameters" - tlsMode='disabled' - if _mongod_hack_have_arg '--tlsCertificateKeyFile' "$@"; then - tlsMode='allowTLS' - fi - _mongod_hack_ensure_arg_val --tlsMode "$tlsMode" "${mongodHackedArgs[@]}" - - if stat "/proc/$$/fd/1" > /dev/null && [ -w "/proc/$$/fd/1" ]; then - # https://github.com/mongodb/mongo/blob/38c0eb538d0fd390c6cb9ce9ae9894153f6e8ef5/src/mongo/db/initialize_server_global_state.cpp#L237-L251 - # https://github.com/docker-library/mongo/issues/164#issuecomment-293965668 - _mongod_hack_ensure_arg_val --logpath "/proc/$$/fd/1" "${mongodHackedArgs[@]}" - else - initdbLogPath="$(_dbPath "$@")/docker-initdb.log" - echo >&2 "warning: initdb logs cannot write to '/proc/$$/fd/1', so they are in '$initdbLogPath' instead" - _mongod_hack_ensure_arg_val --logpath "$initdbLogPath" "${mongodHackedArgs[@]}" - fi - _mongod_hack_ensure_arg --logappend "${mongodHackedArgs[@]}" - - pidfile="$TMPDIR/docker-entrypoint-temp-mongod.pid" - rm -f "$pidfile" - _mongod_hack_ensure_arg_val --pidfilepath "$pidfile" "${mongodHackedArgs[@]}" - - "${mongodHackedArgs[@]}" --fork - - mongo=( "$mongoShell" --host 127.0.0.1 --port 27017 --quiet ) - - # check to see that our "mongod" actually did start up (catches "--help", "--version", slow prealloc, etc) - # https://jira.mongodb.org/browse/SERVER-16292 - tries=30 - while true; do - if ! { [ -s "$pidfile" ] && ps "$(< "$pidfile")" &> /dev/null; }; then - # bail ASAP if "mongod" isn't even running - echo >&2 - echo >&2 "error: $originalArgOne does not appear to have stayed running -- perhaps it had an error?" - echo >&2 - exit 1 - fi - if "${mongo[@]}" 'admin' --eval 'quit(0)' &> /dev/null; then - # success! - break - fi - (( tries-- )) - if [ "$tries" -le 0 ]; then - echo >&2 - echo >&2 "error: $originalArgOne does not appear to have accepted connections quickly enough -- perhaps it had an error?" - echo >&2 - exit 1 - fi - sleep 1 - done - - if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - rootAuthDatabase='admin' - - "${mongo[@]}" "$rootAuthDatabase" <<-EOJS - db.createUser({ - user: $(_js_escape "$MONGO_INITDB_ROOT_USERNAME"), - pwd: $(_js_escape "$MONGO_INITDB_ROOT_PASSWORD"), - roles: [ { role: 'root', db: $(_js_escape "$rootAuthDatabase") } ] - }) - EOJS - fi - - export MONGO_INITDB_DATABASE="${MONGO_INITDB_DATABASE:-test}" - - echo - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; - *.js) echo "$0: running $f"; "${mongo[@]}" "$MONGO_INITDB_DATABASE" "$f"; echo ;; - *) echo "$0: ignoring $f" ;; - esac - echo - done - - "${mongodHackedArgs[@]}" --shutdown - rm -f "$pidfile" - - echo - echo 'MongoDB init process complete; ready for start up.' - echo - fi - - # MongoDB defaults to localhost-only binding - haveBindIp= - if _mongod_hack_have_arg --bind_ip "$@" || _mongod_hack_have_arg --bind_ip_all "$@"; then - haveBindIp=1 - elif _parse_config "$@" && jq --exit-status '.net.bindIp // .net.bindIpAll' "$jsonConfigFile" > /dev/null; then - haveBindIp=1 - fi - if [ -z "$haveBindIp" ]; then - # so if no "--bind_ip" is specified, let's add "--bind_ip_all" - set -- "$@" --bind_ip_all - fi - - unset "${!MONGO_INITDB_@}" -fi - -rm -f "$jsonConfigFile" "$tempConfigFile" - -exec "$@" diff --git a/8.0/windows/nanoserver-ltsc2022/Dockerfile b/8.0/windows/nanoserver-ltsc2022/Dockerfile deleted file mode 100644 index 3cd1004104..0000000000 --- a/8.0/windows/nanoserver-ltsc2022/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" -# -# PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 - -SHELL ["cmd", "/S", "/C"] - -# PATH isn't actually set in the Docker image, so we have to set it from within the container -USER ContainerAdministrator -RUN setx /m PATH "C:\mongodb\bin;%PATH%" -USER ContainerUser -# doing this first to share cache across versions more aggressively - -COPY --from=mongo:8.0.17-windowsservercore-ltsc2022 \ - C:\\Windows\\System32\\msvcp140.dll \ - C:\\Windows\\System32\\msvcp140_1.dll \ - C:\\Windows\\System32\\vcruntime140.dll \ - C:\\Windows\\System32\\vcruntime140_1.dll \ - C:\\Windows\\System32\\ - -# https://docs.mongodb.org/master/release-notes/8.0/ -ENV MONGO_VERSION 8.0.17 -# 12/16/2025, https://github.com/mongodb/mongo/tree/b20e43625b72f4bb43cc15107f80ac966ae13b6d - -COPY --from=mongo:8.0.17-windowsservercore-ltsc2022 C:\\mongodb C:\\mongodb -RUN mongod --version - -VOLUME C:\\data\\db C:\\data\\configdb - -EXPOSE 27017 -CMD ["mongod", "--bind_ip_all"] diff --git a/8.0/windows/windowsservercore-ltsc2022/Dockerfile b/8.0/windows/windowsservercore-ltsc2022/Dockerfile deleted file mode 100644 index e326678158..0000000000 --- a/8.0/windows/windowsservercore-ltsc2022/Dockerfile +++ /dev/null @@ -1,67 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" -# -# PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM mcr.microsoft.com/windows/servercore:ltsc2022 - -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] - -# https://docs.mongodb.org/master/release-notes/8.0/ -ENV MONGO_VERSION 8.0.17 -# 12/16/2025, https://github.com/mongodb/mongo/tree/b20e43625b72f4bb43cc15107f80ac966ae13b6d - -ENV MONGO_DOWNLOAD_URL https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-8.0.17-signed.msi -ENV MONGO_DOWNLOAD_SHA256=4481f5af2795a6a1d74f22bcb5f0e52eeead96ac993a45ccbc50107e4a38b489 - -RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ - (New-Object System.Net.WebClient).DownloadFile($env:MONGO_DOWNLOAD_URL, 'mongo.msi'); \ - \ - if ($env:MONGO_DOWNLOAD_SHA256) { \ - Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256); \ - if ((Get-FileHash mongo.msi -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { \ - Write-Host 'FAILED!'; \ - exit 1; \ - }; \ - }; \ - \ - Write-Host 'Installing ...'; \ -# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#install-mongodb-community-edition - Start-Process msiexec -Wait \ - -ArgumentList @( \ - '/i', \ - 'mongo.msi', \ - '/quiet', \ - '/qn', \ - '/l*v', 'install.log', \ -# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter - 'INSTALLLOCATION=C:\mongodb', \ - 'ADDLOCAL=MiscellaneousTools,Router,ServerNoService' \ - ); \ - if (-Not (Test-Path C:\mongodb\bin\mongod.exe -PathType Leaf)) { \ - Write-Host 'Installer failed!'; \ - Get-Content install.log; \ - exit 1; \ - }; \ - Remove-Item install.log; \ - \ - $env:PATH = 'C:\mongodb\bin;' + $env:PATH; \ - [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \ - \ - Write-Host 'Verifying install ...'; \ - Write-Host ' mongod --version'; mongod --version; \ - \ - Write-Host 'Removing ...'; \ - Remove-Item C:\windows\installer\*.msi -Force; \ - Remove-Item mongo.msi -Force; \ - \ - Write-Host 'Complete.'; - -# TODO docker-entrypoint.ps1 ? (for "docker run --flag --flag --flag") - -VOLUME C:\\data\\db C:\\data\\configdb - -EXPOSE 27017 -CMD ["mongod", "--bind_ip_all"] diff --git a/8.0/windows/windowsservercore-ltsc2025/Dockerfile b/8.0/windows/windowsservercore-ltsc2025/Dockerfile deleted file mode 100644 index db6ffe851c..0000000000 --- a/8.0/windows/windowsservercore-ltsc2025/Dockerfile +++ /dev/null @@ -1,67 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" -# -# PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM mcr.microsoft.com/windows/servercore:ltsc2025 - -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] - -# https://docs.mongodb.org/master/release-notes/8.0/ -ENV MONGO_VERSION 8.0.17 -# 12/16/2025, https://github.com/mongodb/mongo/tree/b20e43625b72f4bb43cc15107f80ac966ae13b6d - -ENV MONGO_DOWNLOAD_URL https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-8.0.17-signed.msi -ENV MONGO_DOWNLOAD_SHA256=4481f5af2795a6a1d74f22bcb5f0e52eeead96ac993a45ccbc50107e4a38b489 - -RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ - (New-Object System.Net.WebClient).DownloadFile($env:MONGO_DOWNLOAD_URL, 'mongo.msi'); \ - \ - if ($env:MONGO_DOWNLOAD_SHA256) { \ - Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256); \ - if ((Get-FileHash mongo.msi -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { \ - Write-Host 'FAILED!'; \ - exit 1; \ - }; \ - }; \ - \ - Write-Host 'Installing ...'; \ -# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#install-mongodb-community-edition - Start-Process msiexec -Wait \ - -ArgumentList @( \ - '/i', \ - 'mongo.msi', \ - '/quiet', \ - '/qn', \ - '/l*v', 'install.log', \ -# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter - 'INSTALLLOCATION=C:\mongodb', \ - 'ADDLOCAL=MiscellaneousTools,Router,ServerNoService' \ - ); \ - if (-Not (Test-Path C:\mongodb\bin\mongod.exe -PathType Leaf)) { \ - Write-Host 'Installer failed!'; \ - Get-Content install.log; \ - exit 1; \ - }; \ - Remove-Item install.log; \ - \ - $env:PATH = 'C:\mongodb\bin;' + $env:PATH; \ - [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \ - \ - Write-Host 'Verifying install ...'; \ - Write-Host ' mongod --version'; mongod --version; \ - \ - Write-Host 'Removing ...'; \ - Remove-Item C:\windows\installer\*.msi -Force; \ - Remove-Item mongo.msi -Force; \ - \ - Write-Host 'Complete.'; - -# TODO docker-entrypoint.ps1 ? (for "docker run --flag --flag --flag") - -VOLUME C:\\data\\db C:\\data\\configdb - -EXPOSE 27017 -CMD ["mongod", "--bind_ip_all"] diff --git a/AGENTS.md b/AGENTS.md index c08b4a373a..bc126a54d9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,68 +1,75 @@ -# Finter MongoDB Docker — version upgrade playbook +# Finter MongoDB Docker image -This fork of `docker-library/mongo` publishes -`ghcr.io/fintermobilityas/mongo-enterprise:` for youpark.no. +This repository publishes `ghcr.io/fintermobilityas/mongo-enterprise:`, +the MongoDB Enterprise image for youpark.no. It keeps only the files of that +image. It started as a fork of `docker-library/mongo` and no longer tracks it. -## What's actually built +## What is built -`publish.ps1` builds **`./8.0/Dockerfile`** regardless of the version being -released. The directory name is historical — it is the Finter-customized -Dockerfile (enterprise package, PGP keys, etc.). Everything passed through -`--build-arg` overrides the defaults inside that Dockerfile. +| Path | What it is | +|---|---| +| `image/Dockerfile` | The recipe: Ubuntu noble, the Enterprise packages from `repo.mongodb.com`, the release signing keys | +| `image/docker-entrypoint.sh` | The entrypoint, which the Dockerfile copies | +| `publish.ps1` | The version and the apt channels (its parameter defaults), and the manual publish fallback | +| `.github/workflows/publish.yml` | "Publish image": builds, checks and publishes | -The other version directories (today `7.0/`) are regenerated from the -`mongo-vendor` upstream templates by `apply-templates.sh` from `versions.json`, -and are **not** used by the build. `apply-templates.sh` skips `8.0/`, so the -"Verify Templating" check never overwrites the image recipe. +`publish.ps1` builds `./image` with `--build-arg MONGO_VERSION`, `MONGO_MAJOR` +and `MONGOSH_CHANNEL`. The `ARG` defaults in `image/Dockerfile` must be the +same values; "Publish image" checks that. -## Branch layout +## Branches -- `master` — tracks `mongo-vendor/master` (upstream `docker-library/mongo`). -- `finter-` — per-release-line branches. The GitHub default - branch points at the currently-shipping one. A new major/minor bump gets a - new branch; patch bumps go on the existing one. -- Default branch for `fintermobilityas/mongo` is set via - `gh api -X PATCH repos/fintermobilityas/mongo -f default_branch=`. +- `main` is the only working branch and the default branch. Each change goes + to `main`, also a new minor or major line. There is no default-branch switch. +- `master` and the `finter-*` branches are the history of the old layout + (upstream tracking and one branch for each release line). They stay for + reference; do not work on them. -## Apt channels (critical — trips everyone up) +## Apt channels (critical: this trips everyone up) Two MongoDB apt channels are relevant: | Channel | URL tail | Versions look like | When to use | |---|---|---|---| | `development` | `/mongodb-enterprise/development` | `X.Y.Z~latest` (rolling) | Pre-GA (RCs, unreleased majors) | -| `` GA | `/mongodb-enterprise/8.2` etc. | `X.Y.Z` (pinned) | Once that line has GA'd | +| `` GA | `/mongodb-enterprise/9.0` etc. | `X.Y.Z` (pinned) | Once that line has GA'd | -`mongodb-enterprise/8.3/` etc. **exist before the line GAs** but only -contain `mongodb-database-tools` until GA. `mongodb-enterprise=8.3.0` will +`mongodb-enterprise/9.1/` etc. **exist before the line GAs** but only +contain `mongodb-database-tools` until GA. `mongodb-enterprise=9.1.0` will not install from that channel until MongoDB tags the GA build. `~` sorts as less-than-empty in dpkg semantics, so -`apt-get install mongodb-enterprise=8.3.0` will **not** match -`8.3.0~latest`. Use the suffixed version explicitly when pulling from +`apt-get install mongodb-enterprise=9.1.0` will **not** match +`9.1.0~latest`. Use the suffixed version explicitly when pulling from `development`. ## Release signing keys (the other channel trap) -Every GA release line is signed by its own key, and `8.0/Dockerfile` must +Each major GA series has its own signing key, and `image/Dockerfile` must import it or apt refuses the channel outright: `The repository '... mongodb-enterprise/9.0 InRelease' is not signed`. -The `development` channel is signed by `server-dev.asc`, which is why a -pre-GA image can build while the GA channel of the same version cannot. +The Dockerfile imports `server-8.0.asc` (every 8.x GA channel), +`server-9.asc` (every 9.x GA channel) and `server-dev.asc` (the +`development` channel), and exports their fingerprints to +`/etc/apt/keyrings/mongodb.asc`. The 9.x key is published **major-only** as `https://pgp.mongodb.com/server-9.asc` (`B3B42B6C39E5CDDEC0A27E3CF366D55B602E502D`, "MongoDB 9 Release Signing -Key") — `server-9.0.asc` is a 404. Confirm which key signs a channel with: +Key"); `server-9.0.asc` is a 404. Confirm which key signs a channel with: ```bash curl -fsSL https://repo.mongodb.com/apt/ubuntu/dists/noble/mongodb-enterprise//InRelease | gpg --verify ``` +A new major (for example 10.0) needs its key: add the download and the +fingerprint to the key block of `image/Dockerfile`, after you confirm them +with the command above. + ## Release discovery and package gate For an update request that does not name a version, check the tracked release -line's official release notes first (currently [MongoDB 8.3](https://www.mongodb.com/docs/manual/release-notes/8.3/)). +line's official release notes first (currently [MongoDB 9.0](https://www.mongodb.com/docs/manual/release-notes/9.0/)). The newest patch listed there is the latest officially released target, even when the Enterprise apt feed has not caught up. @@ -72,30 +79,71 @@ establishes whether this image can be built. If the target is absent from the GA feed and no exact development package has been explicitly approved, stop before creating branches, images, or file changes and report the feed lag. -Always commit and push the exact Dockerfile and `publish.ps1` source before -publishing the image. After publication, verify that the manifest provenance -records that committed revision. +## Update the image (GA patch, minor or major) + +The same steps for each kind of release. + +1. Fetch `origin/main` and create a separate worktree on a new branch from + its exact commit. Never update from a shared checkout or a cached + remote-tracking ref. +2. Edit the defaults of `publish.ps1`: + - `$MongoVersion` (the image tag) and `$MongoPackageVersion` (the apt + version): `"X.Y.Z"`. + - `$MongoAptChannel` and `$MongoMongoshChannel`: `"X.Y"`. They change + only for a new minor or major line. +3. Edit the `ARG MONGO_VERSION`, `ARG MONGO_MAJOR` and `ARG MONGOSH_CHANNEL` + defaults of `image/Dockerfile` to the same values. For a new major, add + its signing key (see above). +4. Commit `publish.ps1` and `image/Dockerfile` as `Update to mongodb X.Y.Z` + and open a pull request into `main`. "Publish image" builds and checks the + image as a dry run on the pull request; it must pass. +5. Merge the pull request. The push to `main` starts "Publish image", which + builds, checks and publishes the tag from the merged commit. +6. Read the manifest digest and provenance revision from that run and check + them against the merge commit. +7. Open a version-bump PR in `../youpark.no` (see below). + +A pre-GA build from the `development` channel (`X.Y.Z~latest` or +`X.Y.Z~`, `$MongoAptChannel = "development"`, and +`$MongoMongoshChannel` the last GA channel that has `mongodb-mongosh`) needs +a person's approval first. A pre-GA build holds the tag of its GA version, +and the workflow never overwrites a published tag, so the GA build then needs +a person too. + +To build and smoke test by hand: + +```bash +docker build \ + --build-arg MONGO_VERSION=9.0.4 \ + --build-arg MONGO_MAJOR=9.0 \ + --build-arg MONGOSH_CHANNEL=9.0 \ + -t mongo-enterprise:9.0.4 ./image +docker run --rm -e GLIBC_TUNABLES=glibc.pthread.rseq=1 mongo-enterprise:9.0.4 mongod --version +``` ## Publishing through the workflow `.github/workflows/publish.yml` ("Publish image") publishes the image. A push -to a `finter-*` branch that changes `publish.ps1` or `8.0/Dockerfile` starts -it, also when the push creates the branch. It builds `./8.0` once with the -parameter defaults of `publish.ps1` and pushes that image without a tag, -checks the Enterprise package inventory, `mongod --version` and the -provenance revision of that exact image, and only then tags its digest -`ghcr.io/fintermobilityas/mongo-enterprise:`, with the job's -token. It prints `Published :@` plus the provenance -revision. A run that fails a check leaves an untagged version in the package. It refuses to overwrite a published tag and to create a package. -So when a pre-GA build was published under the version it gets at GA (as -9.0.0 was from `9.0.0~latest`), the workflow cannot replace that tag with the -GA build; a person decides and publishes it with `pwsh ./publish.ps1`. - -- Dry run: `gh workflow run publish.yml -R fintermobilityas/mongo --ref -f push=false`. +to `main` that changes `publish.ps1` or a file in `image/` starts it. It +builds `./image` once with the parameter defaults of `publish.ps1` and pushes +that image without a tag, checks the Enterprise package inventory, +`mongod --version` and the provenance revision of that exact image, and only +then tags its digest `ghcr.io/fintermobilityas/mongo-enterprise:`, +with the job's token. It prints `Published :@` plus the +provenance revision. A run that fails a check leaves an untagged version in +the package. + +- It never overwrites a published tag and never creates a package. When the + tag exists and the push did not change `$MongoVersion` (for example a change + of the entrypoint only), there is nothing to publish: the run ends green + with the notice "Nothing to publish". When the push changed the version to + one whose tag exists, the run fails. +- Pull requests that change `publish.ps1`, `image/` or the workflow get a dry + run: the same build and checks, with nothing pushed. +- Dry run by hand: `gh workflow run publish.yml -R fintermobilityas/mongo --ref main -f push=false`. - Publish again after a failed or cancelled run: the same with `-f push=true`. - Publishing runs from every branch wait for each other, so two runs never - check and push the same tag at once. -- Pull requests that change those files get a dry run. + Publishing runs wait for each other, so two runs never check and push the + same tag at once. The package is private and linked to `fintermobilityas/youpark.no`. Never change its visibility or its repository link. Its **Manage Actions access** @@ -105,66 +153,6 @@ package's web settings. `pwsh ./publish.ps1` from a machine with Docker and a ghcr login (see Pre-flight checks) stays the manual fallback for a person. -## Upgrade recipes - -### Patch bump on the current release line (e.g. 8.2.7 → 8.2.8) - -Do it on the existing `finter-` branch. - -1. Fetch `origin/finter-8.2` and create a separate worktree from its exact - commit. Never update from a shared checkout or a cached remote-tracking ref. -2. Edit `publish.ps1`: - - `$MongoVersion` → `"8.2.8"` (Docker image tag). - - `$MongoPackageVersion` → `"8.2.8"` (pinned, from `/8.2` GA channel) **or** - `"8.2.8~latest"` if pulling from `development`. -3. Edit `8.0/Dockerfile` `ARG MONGO_VERSION` to match. -4. Commit `publish.ps1` and `8.0/Dockerfile` as - `Update to mongodb 8.2.8`, then push the commit to `finter-8.2`. -5. The push starts the publish workflow, which builds, checks and pushes the - image from that clean committed source. -6. Read the manifest digest and provenance revision from the workflow run and - check them against the pushed source commit. -7. Open a version-bump PR in `../youpark.no` (see below). - -### Minor/major bump (e.g. 8.2 → 8.3) - -New release line. Create a new branch. - -1. `git fetch origin && git checkout -b finter-8.3 origin/finter-8.2`. -2. Edit `publish.ps1`: - - `$MongoVersion` = `"8.3.0"` (image tag). - - `$MongoPackageVersion` = `"8.3.0~latest"` until 8.3 GA's, then switch - to `"8.3.0"` + channel `"8.3"`. - - `$MongoAptChannel` = `"development"` pre-GA, `"8.3"` post-GA. - - `$MongoMongoshChannel` = last GA channel that has `mongodb-mongosh` - (`"8.2"` while 8.3 is pre-GA — the `/8.3` channel only has - `mongodb-database-tools` until GA). Switch to `"8.3"` once mongosh - lands there. -3. Commit the image source and push the new `finter-8.3` branch. The push - starts the publish workflow, which builds, checks and pushes the image. -4. To build and smoke test by hand instead: - - ```bash - docker build \ - --build-arg MONGO_VERSION=8.3.0~latest \ - --build-arg MONGO_MAJOR=development \ - --build-arg MONGOSH_CHANNEL=8.2 \ - -t mongo-enterprise:8.3.0 ./8.0 - docker run --rm mongo-enterprise:8.3.0 mongod --version - ``` - -5. Read the digest and provenance of `ghcr.io/fintermobilityas/mongo-enterprise:8.3.0` - from the workflow run (`pwsh ./publish.ps1` is the manual fallback). -6. Verify the manifest digest and provenance against the pushed source commit. -7. Change GitHub default branch (needs admin access; a maintenance agent - leaves this one step to a person and names it in its report): - - ```bash - gh api -X PATCH repos/fintermobilityas/mongo -f default_branch=finter-8.3 - ``` - -8. Open a version-bump PR in `../youpark.no`. - ## youpark.no version-bump PR The MongoDB version and immutable image digest in youpark.no live in shared @@ -190,14 +178,14 @@ green"), run this loop in the PR's worktree: 2. **Feedback gate**: poll unresolved review threads (GraphQL `reviewThreads { id isResolved }`) plus new comments via `gh api repos///pulls//comments` (inline) and - `gh api repos///issues//comments` (issue-level) — do not + `gh api repos///issues//comments` (issue-level); do not rely on `.../pulls//reviews` alone, it only lists review events. Verify each new comment against the code; if valid, fix, push, reply to the thread with the commit hash, then resolve the thread with the `resolveReviewThread` mutation. If invalid, reply with evidence and leave it open unless the user pre-approved closing. 3. **Polling**: check CI and threads together every ~30 s in one loop with an - explicit timeout (~60 min budget). A push resets CI — re-evaluate from the + explicit timeout (~60 min budget). A push resets CI; re-evaluate from the new head commit. 4. **Merge gate**: only when the head commit is CI-green, has zero unresolved threads, and `mergeStateStatus` is CLEAN, run `gh pr merge --squash` @@ -208,30 +196,20 @@ green"), run this loop in the PR's worktree: For publishing through the workflow, only `gh auth status` applies. The rest is for the manual `pwsh ./publish.ps1` fallback. -- `docker info` — daemon running. -- `docker login ghcr.io` — check `~/.docker/config.json` has `ghcr.io`. -- `gh auth status` — need `repo` and ideally `admin:org` for default-branch - changes. -- `which pwsh` — needed for `publish.ps1`. +- `docker info`: daemon running. +- `docker login ghcr.io`: check `~/.docker/config.json` has `ghcr.io`. +- `gh auth status`: need `repo`. +- `which pwsh`: needed for `publish.ps1`. ## Gotchas -- `publish.ps1` hardcodes `$buildPath = "8.0"`. Don't add or rename build +- `publish.ps1` hardcodes `$buildPath = "image"`. Don't add or rename build directories expecting `publish.ps1` to find them. -- This fork has no upstream "GitHub CI" workflow (`ci.yml`, the bashbrew - matrix of docker-library). Its action `docker-library/bashbrew` is not on - the Actions allowlist of the organization, and it builds the template - folders and Windows images that this fork does not ship. "Publish image" - builds and checks the image that it ships. Do not bring `ci.yml` back in a - merge from `mongo-vendor`. +- This repository has none of the upstream docker-library files: no + templates, no `versions.json`, no other version folders, and no "GitHub CI" + or "Verify Templating" workflow. "Publish image" builds and checks the one + image that it ships. Do not merge `docker-library/mongo` into `main`. - `mongodb-enterprise-cryptd` resolves to the highest version in the chosen apt channel, which can be higher than the other packages (e.g. `9.0.0~latest` while the rest are `8.3.0~latest`). That's how MongoDB publishes it; nothing to fix. -- The other version directories (today `7.0/`) are upstream-regenerated from - `mongo-vendor` templates via `update.sh`. They drift from what we actually - ship; don't treat them as the source of truth. Never edit them by hand: - "Verify Templating" fails when a file differs from what `apply-templates.sh` - writes. To refresh them, run `./update.sh 7.0 8.0` (or the lines that - `versions.json` lists): `versions.sh` reads the release data of MongoDB, and - a line past its end of life becomes `null` and its directory goes away. diff --git a/Dockerfile-linux.template b/Dockerfile-linux.template deleted file mode 100644 index a6c121fd72..0000000000 --- a/Dockerfile-linux.template +++ /dev/null @@ -1,134 +0,0 @@ -{{ def target: .targets[.linux] -}} -FROM {{ target.image }} - -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN set -eux; \ - groupadd --gid 999 --system mongodb; \ - useradd --uid 999 --system --gid mongodb --home-dir /data/db mongodb; \ - mkdir -p /data/db /data/configdb; \ - chown -R mongodb:mongodb /data/db /data/configdb - -RUN set -eux; \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - jq \ - numactl \ - procps \ - ; \ - rm -rf /var/lib/apt/lists/* - -# grab gosu for easy step-down from root (https://github.com/tianon/gosu/releases) -ENV GOSU_VERSION 1.19 -# grab "js-yaml" for parsing mongod's YAML config files (https://github.com/nodeca/js-yaml/releases) -ENV JSYAML_VERSION 3.13.1 -ENV JSYAML_CHECKSUM 662e32319bdd378e91f67578e56a34954b0a2e33aca11d70ab9f4826af24b941 - -RUN set -eux; \ - \ - savedAptMark="$(apt-mark showmanual)"; \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - gnupg \ - wget \ - ; \ - rm -rf /var/lib/apt/lists/*; \ - \ -# download/install gosu - dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \ - wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ - wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ - export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ - gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ - gpgconf --kill all; \ - rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \ - \ -# download/install js-yaml - mkdir -p /opt/js-yaml/; \ - wget -O /opt/js-yaml/js-yaml.tgz https://registry.npmjs.org/js-yaml/-/js-yaml-${JSYAML_VERSION}.tgz; \ - echo "$JSYAML_CHECKSUM */opt/js-yaml/js-yaml.tgz" | sha256sum -c -; \ - tar -xz --strip-components=1 -f /opt/js-yaml/js-yaml.tgz -C /opt/js-yaml package/dist/js-yaml.js package/package.json; \ - rm /opt/js-yaml/js-yaml.tgz; \ - ln -s /opt/js-yaml/dist/js-yaml.js /js-yaml.js; \ - \ -# download/install MongoDB PGP keys - export GNUPGHOME="$(mktemp -d)"; \ - wget -O KEYS {{ [ .pgp[].url ] | map(@sh) | join(" ") }}; \ - gpg --batch --import KEYS; \ - mkdir -p /etc/apt/keyrings; \ - gpg --batch --export --armor {{ [ .pgp[].fingerprints[] ] | map(@sh) | join(" ") }} > /etc/apt/keyrings/mongodb.asc; \ - gpgconf --kill all; \ - rm -rf "$GNUPGHOME" KEYS; \ - \ - apt-mark auto '.*' > /dev/null; \ - apt-mark manual $savedAptMark > /dev/null; \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ - \ -# smoke test - chmod +x /usr/local/bin/gosu; \ - gosu --version; \ - gosu nobody true - -RUN mkdir /docker-entrypoint-initdb.d - -# Allow build-time overrides (eg. to build image with MongoDB Enterprise version) -# Options for MONGO_PACKAGE: mongodb-org OR mongodb-enterprise -# Options for MONGO_REPO: repo.mongodb.org OR repo.mongodb.com -# Example: docker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com . -ARG MONGO_PACKAGE=mongodb-org{{ if (env.version != env.rcVersion) and (env.rcVersion | split(".")[1] | tonumber % 2 == 1) then "-unstable" else "" end }} -ARG MONGO_REPO=repo.mongodb.org -ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO} - -ENV MONGO_MAJOR {{ if env.version != env.rcVersion then "testing" else env.version end }} -RUN echo "deb [ signed-by=/etc/apt/keyrings/mongodb.asc ] http://$MONGO_REPO/apt/{{ target.image | gsub(":.*$"; "") }} {{ target.suite }}/${MONGO_PACKAGE%-unstable}/$MONGO_MAJOR {{ if target.image | test("^debian") then "main" else "multiverse" end }}" | tee "/etc/apt/sources.list.d/${MONGO_PACKAGE%-unstable}.list" -{{ if env.version != env.rcVersion then ( -}} -# add GA repo for mongodb-mongosh and mongodb-database-tools -RUN echo "deb [ signed-by=/etc/apt/keyrings/mongodb.asc ] http://$MONGO_REPO/apt/{{ target.image | gsub(":.*$"; "") }} {{ target.suite }}/${MONGO_PACKAGE%-unstable}/{{ env.rcVersion }} {{ if target.image | test("^debian") then "main" else "multiverse" end }}" | tee "/etc/apt/sources.list.d/mongodb-{{ env.rcVersion }}.list" -{{ ) else "" end -}} - -{{ if .notes then ( -}} -# {{ .notes }} -{{ ) else "" end -}} -ENV MONGO_VERSION {{ .version | gsub("-"; "~") }} -{{ if .date or .githash then ( -}} -# {{ [ .date // empty, "https://github.com/mongodb/mongo/tree/" + .githash // empty ] | join(", ") }} -{{ ) else "" end -}} - -RUN set -x \ -# installing "mongodb-enterprise" pulls in "tzdata" which prompts for input - && export DEBIAN_FRONTEND=noninteractive \ - && apt-get update \ - && apt-get install -y \ - ${MONGO_PACKAGE}=$MONGO_VERSION \ - ${MONGO_PACKAGE}-server=$MONGO_VERSION \ - ${MONGO_PACKAGE}-shell=$MONGO_VERSION \ - ${MONGO_PACKAGE}-mongos=$MONGO_VERSION \ - ${MONGO_PACKAGE}-tools=$MONGO_VERSION \ -{{ if (env.rcVersion | tonumber >= 6) then ( -}} -{{ # TODO: auto update this list of packages or just pin them -}} - ${MONGO_PACKAGE}-database=$MONGO_VERSION \ - ${MONGO_PACKAGE}-database-tools-extra=$MONGO_VERSION \ -{{ ) else "" end -}} - && rm -rf /var/lib/apt/lists/* \ - && rm -rf /var/lib/mongodb \ - && mv /etc/mongod.conf /etc/mongod.conf.orig - -VOLUME /data/db /data/configdb - -# ensure that if running as custom user that "mongosh" has a valid "HOME" -# https://github.com/docker-library/mongo/issues/524 -ENV HOME /data/db -{{ if (env.rcVersion | tonumber >= 8) then ( -}} -{{ # TODO remove this when it is no longer necessary: https://www.mongodb.com/docs/manual/administration/tcmalloc-performance/#enable-per-cpu-caches -}} - -# ensure that glibc isn't using rseq so that google-tcmalloc can -# https://www.mongodb.com/docs/manual/administration/tcmalloc-performance/#disable-glibc-rseq -ENV GLIBC_TUNABLES glibc.pthread.rseq=0 -{{ ) else "" end -}} - -COPY docker-entrypoint.sh /usr/local/bin/ -ENTRYPOINT ["docker-entrypoint.sh"] - -EXPOSE 27017 -CMD ["mongod"] diff --git a/Dockerfile-windows.template b/Dockerfile-windows.template deleted file mode 100644 index d084debdba..0000000000 --- a/Dockerfile-windows.template +++ /dev/null @@ -1,101 +0,0 @@ -{{ - def has_client: - .targets.windows.features | index("Client") --}} -FROM mcr.microsoft.com/windows/{{ env.windowsVariant }}:{{ env.windowsRelease }} - -{{ if env.windowsVariant == "servercore" then ( -}} -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] - -{{ if .notes then ( -}} -# {{ .notes }} -{{ ) else "" end -}} -ENV MONGO_VERSION {{ .version }} -{{ if .date or .githash then ( -}} -# {{ [ .date // empty, "https://github.com/mongodb/mongo/tree/" + .githash // empty ] | join(", ") }} -{{ ) else "" end -}} - -ENV MONGO_DOWNLOAD_URL {{ .targets.windows.msi }} -ENV MONGO_DOWNLOAD_SHA256={{ .targets.windows.sha256 }} - -RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ - (New-Object System.Net.WebClient).DownloadFile($env:MONGO_DOWNLOAD_URL, 'mongo.msi'); \ - \ - if ($env:MONGO_DOWNLOAD_SHA256) { \ - Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256); \ - if ((Get-FileHash mongo.msi -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { \ - Write-Host 'FAILED!'; \ - exit 1; \ - }; \ - }; \ - \ - Write-Host 'Installing ...'; \ -# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#install-mongodb-community-edition - Start-Process msiexec -Wait \ - -ArgumentList @( \ - '/i', \ - 'mongo.msi', \ - '/quiet', \ - '/qn', \ - '/l*v', 'install.log', \ -# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter - 'INSTALLLOCATION=C:\mongodb', \ - 'ADDLOCAL={{ .targets.windows.features | join(",") }}' \ - ); \ - if (-Not (Test-Path C:\mongodb\bin\mongod.exe -PathType Leaf)) { \ - Write-Host 'Installer failed!'; \ - Get-Content install.log; \ - exit 1; \ - }; \ - Remove-Item install.log; \ - \ - $env:PATH = 'C:\mongodb\bin;' + $env:PATH; \ - [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \ - \ - Write-Host 'Verifying install ...'; \ -{{ if has_client then ( -}} - Write-Host ' mongo --version'; mongo --version; \ -{{ ) else "" end -}} - Write-Host ' mongod --version'; mongod --version; \ - \ - Write-Host 'Removing ...'; \ - Remove-Item C:\windows\installer\*.msi -Force; \ - Remove-Item mongo.msi -Force; \ - \ - Write-Host 'Complete.'; - -# TODO docker-entrypoint.ps1 ? (for "docker run --flag --flag --flag") -{{ ) else ( -}} -SHELL ["cmd", "/S", "/C"] - -# PATH isn't actually set in the Docker image, so we have to set it from within the container -USER ContainerAdministrator -RUN setx /m PATH "C:\mongodb\bin;%PATH%" -USER ContainerUser -# doing this first to share cache across versions more aggressively - -{{ def copy_from: "mongo:" + .version + "-windowsservercore-" + env.windowsRelease -}} -COPY --from={{ copy_from }} \ - C:\\Windows\\System32\\msvcp140.dll \ - C:\\Windows\\System32\\msvcp140_1.dll \ - C:\\Windows\\System32\\vcruntime140.dll \ - C:\\Windows\\System32\\vcruntime140_1.dll \ - C:\\Windows\\System32\\ - -{{ if .notes then ( -}} -# {{ .notes }} -{{ ) else "" end -}} -ENV MONGO_VERSION {{ .version }} -{{ if .date or .githash then ( -}} -# {{ [ .date // empty, "https://github.com/mongodb/mongo/tree/" + .githash // empty ] | join(", ") }} -{{ ) else "" end -}} - -COPY --from={{ copy_from }} C:\\mongodb C:\\mongodb -RUN {{ if has_client then ( }}mongo --version && {{ ) else "" end }}mongod --version -{{ ) end -}} - -VOLUME C:\\data\\db C:\\data\\configdb - -EXPOSE 27017 -CMD ["mongod", "--bind_ip_all"] diff --git a/README.md b/README.md index 1f4377ea8d..681a804883 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,11 @@ -# https://github.com/docker-library/mongo +# mongo-enterprise image -## Maintained by: [the Docker Community](https://github.com/docker-library/mongo) +This repository builds and publishes `ghcr.io/fintermobilityas/mongo-enterprise:`, a MongoDB Enterprise image on Ubuntu. The package is private. -This is the Git repo of the [Docker "Official Image"](https://github.com/docker-library/official-images#what-are-official-images) for [`mongo`](https://hub.docker.com/_/mongo/) (not to be confused with any official `mongo` image provided by `mongo` upstream). See [the Docker Hub page](https://hub.docker.com/_/mongo/) for the full readme on how to use this Docker image and for information regarding contributing and issues. +- `image/` holds the Dockerfile and the entrypoint. +- `publish.ps1` holds the version and the apt channels. +- The "Publish image" workflow builds and checks the image on each pull request, and publishes the version tag when a change reaches `main`. -The [full image description on Docker Hub](https://hub.docker.com/_/mongo/) is generated/maintained over in [the docker-library/docs repository](https://github.com/docker-library/docs), specifically in [the `mongo` directory](https://github.com/docker-library/docs/tree/master/mongo). +To publish a new MongoDB release, change the version in `publish.ps1` and `image/Dockerfile` in a pull request into `main`, and merge it after its dry run passes. [AGENTS.md](AGENTS.md) has the full steps. -## See a change merged here that doesn't show up on Docker Hub yet? - -For more information about the full official images change lifecycle, see [the "An image's source changed in Git, now what?" FAQ entry](https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what). - -For outstanding `mongo` image PRs, check [PRs with the "library/mongo" label on the official-images repository](https://github.com/docker-library/official-images/labels/library%2Fmongo). For the current "source of truth" for [`mongo`](https://hub.docker.com/_/mongo/), see [the `library/mongo` file in the official-images repository](https://github.com/docker-library/official-images/blob/master/library/mongo). - - +The image started from [docker-library/mongo](https://github.com/docker-library/mongo) (see [LICENSE](LICENSE)). diff --git a/apply-templates.sh b/apply-templates.sh deleted file mode 100755 index c877b1f63b..0000000000 --- a/apply-templates.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail - -[ -f versions.json ] # run "versions.sh" first - -jqt='.jq-template.awk' -if [ -n "${BASHBREW_SCRIPTS:-}" ]; then - jqt="$BASHBREW_SCRIPTS/jq-template.awk" -elif [ "$BASH_SOURCE" -nt "$jqt" ]; then - # https://github.com/docker-library/bashbrew/blob/master/scripts/jq-template.awk - wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk' -fi - -if [ "$#" -eq 0 ]; then - versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)" - eval "set -- $versions" -fi - -generated_warning() { - cat <<-EOH - # - # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" - # - # PLEASE DO NOT EDIT IT DIRECTLY. - # - - EOH -} - -for version; do - rcVersion="${version%-rc}" - export version rcVersion - - # Finter: 8.0/ holds the recipe of the published Enterprise image (see AGENTS.md), so the - # templates do not own it. - if [ "$version" = '8.0' ]; then - echo "skipping $version (the Finter image recipe) ..." - continue - fi - - rm -rf "$version" - - if jq -e '.[env.version] | not' versions.json > /dev/null; then - echo "skipping $version ..." - continue - fi - - echo "processing $version ..." - - mkdir -p "$version" - { - generated_warning - gawk -f "$jqt" Dockerfile-linux.template - } > "$version/Dockerfile" - - cp -a docker-entrypoint.sh "$version/" - - variants="$(jq -r '.[env.version].targets.windows.variants | map(@sh) | join(" ")' versions.json)" - eval "variants=( $variants )" - for variant in "${variants[@]}"; do - windowsVariant="${variant%%-*}" # "windowsservercore", "nanoserver" - windowsRelease="${variant#$windowsVariant-}" # "ltsc2022", "1809", etc - windowsVariant="${windowsVariant#windows}" # "servercore", "nanoserver" - export windowsVariant windowsRelease - - dir="$version/windows/$variant" - echo "processing $dir ..." - - mkdir -p "$dir" - { - generated_warning - gawk -f "$jqt" Dockerfile-windows.template - } > "$dir/Dockerfile" - done -done diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100755 index d37d1b92bb..0000000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,420 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail - -if [ "${1:0:1}" = '-' ]; then - set -- mongod "$@" -fi - -originalArgOne="$1" - -# allow the container to be started with `--user` -# all mongo* commands should be dropped to the correct user -if [[ "$originalArgOne" == mongo* ]] && [ "$(id -u)" = '0' ]; then - if [ "$originalArgOne" = 'mongod' ]; then - find -L /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}' + - fi - - # make sure we can write to stdout and stderr as "mongodb" - # (for our "initdb" code later; see "--logpath" below) - chown --dereference mongodb "/proc/$$/fd/1" "/proc/$$/fd/2" || : - # ignore errors thanks to https://github.com/docker-library/mongo/issues/149 - - exec gosu mongodb "$BASH_SOURCE" "$@" -fi - -dpkgArch="$(dpkg --print-architecture)" -case "$dpkgArch" in - amd64) # https://github.com/docker-library/mongo/issues/485#issuecomment-891991814 - if ! grep -qE '^flags.* avx( .*|$)' /proc/cpuinfo; then - { - echo - echo 'WARNING: MongoDB 5.0+ requires a CPU with AVX support, and your current system does not appear to have that!' - echo ' see https://jira.mongodb.org/browse/SERVER-54407' - echo ' see also https://www.mongodb.com/community/forums/t/mongodb-5-0-cpu-intel-g4650-compatibility/116610/2' - echo ' see also https://github.com/docker-library/mongo/issues/485#issuecomment-891991814' - echo - } >&2 - fi - ;; - - arm64) # https://github.com/docker-library/mongo/issues/485#issuecomment-970864306 - # https://en.wikichip.org/wiki/arm/armv8#ARMv8_Extensions_and_Processor_Features - # http://javathunderx.blogspot.com/2018/11/cheat-sheet-for-cpuinfo-features-on.html - if ! grep -qE '^Features.* (fphp|dcpop|sha3|sm3|sm4|asimddp|sha512|sve)( .*|$)' /proc/cpuinfo; then - { - echo - echo 'WARNING: MongoDB requires ARMv8.2-A or higher, and your current system does not appear to implement any of the common features for that!' - echo ' applies to all versions ≥5.0, any of 4.4 ≥4.4.19' - echo ' see https://jira.mongodb.org/browse/SERVER-71772' - echo ' see https://jira.mongodb.org/browse/SERVER-55178' - echo ' see also https://en.wikichip.org/wiki/arm/armv8#ARMv8_Extensions_and_Processor_Features' - echo ' see also https://github.com/docker-library/mongo/issues/485#issuecomment-970864306' - echo - } >&2 - fi - ;; -esac - -# you should use numactl to start your mongod instances, including the config servers, mongos instances, and any clients. -# https://docs.mongodb.com/manual/administration/production-notes/#configuring-numa-on-linux -if [[ "$originalArgOne" == mongo* ]]; then - numa='numactl --interleave=all' - if $numa true &> /dev/null; then - set -- $numa "$@" - fi -fi - -# usage: file_env VAR [DEFAULT] -# ie: file_env 'XYZ_DB_PASSWORD' 'example' -# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of -# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) -file_env() { - local var="$1" - local fileVar="${var}_FILE" - local def="${2:-}" - if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then - echo >&2 "error: both $var and $fileVar are set (but are exclusive)" - exit 1 - fi - local val="$def" - if [ "${!var:-}" ]; then - val="${!var}" - elif [ "${!fileVar:-}" ]; then - val="$(< "${!fileVar}")" - fi - export "$var"="$val" - unset "$fileVar" -} - -# see https://github.com/docker-library/mongo/issues/147 (mongod is picky about duplicated arguments) -_mongod_hack_have_arg() { - local checkArg="$1"; shift - local arg - for arg; do - case "$arg" in - "$checkArg"|"$checkArg"=*) - return 0 - ;; - esac - done - return 1 -} -# _mongod_hack_get_arg_val '--some-arg' "$@" -_mongod_hack_get_arg_val() { - local checkArg="$1"; shift - while [ "$#" -gt 0 ]; do - local arg="$1"; shift - case "$arg" in - "$checkArg") - echo "$1" - return 0 - ;; - "$checkArg"=*) - echo "${arg#$checkArg=}" - return 0 - ;; - esac - done - return 1 -} -declare -a mongodHackedArgs -# _mongod_hack_ensure_arg '--some-arg' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_arg() { - local ensureArg="$1"; shift - mongodHackedArgs=( "$@" ) - if ! _mongod_hack_have_arg "$ensureArg" "$@"; then - mongodHackedArgs+=( "$ensureArg" ) - fi -} -# _mongod_hack_ensure_no_arg '--some-unwanted-arg' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_no_arg() { - local ensureNoArg="$1"; shift - mongodHackedArgs=() - while [ "$#" -gt 0 ]; do - local arg="$1"; shift - if [ "$arg" = "$ensureNoArg" ]; then - continue - fi - mongodHackedArgs+=( "$arg" ) - done -} -# _mongod_hack_ensure_no_arg '--some-unwanted-arg' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_no_arg_val() { - local ensureNoArg="$1"; shift - mongodHackedArgs=() - while [ "$#" -gt 0 ]; do - local arg="$1"; shift - case "$arg" in - "$ensureNoArg") - shift # also skip the value - continue - ;; - "$ensureNoArg"=*) - # value is already included - continue - ;; - esac - mongodHackedArgs+=( "$arg" ) - done -} -# _mongod_hack_ensure_arg_val '--some-arg' 'some-val' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_arg_val() { - local ensureArg="$1"; shift - local ensureVal="$1"; shift - _mongod_hack_ensure_no_arg_val "$ensureArg" "$@" - mongodHackedArgs+=( "$ensureArg" "$ensureVal" ) -} - -# _js_escape 'some "string" value' -_js_escape() { - jq --null-input --arg 'str' "$1" '$str' -} - -: "${TMPDIR:=/tmp}" -jsonConfigFile="$TMPDIR/docker-entrypoint-config.json" -tempConfigFile="$TMPDIR/docker-entrypoint-temp-config.json" -_parse_config() { - if [ -s "$tempConfigFile" ]; then - return 0 - fi - - local configPath - if configPath="$(_mongod_hack_get_arg_val --config "$@")" && [ -s "$configPath" ]; then - # if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys) - # see https://docs.mongodb.com/manual/reference/configuration-options/ - if grep -vEm1 '^[[:space:]]*(#|$)' "$configPath" | grep -qE '^[[:space:]]*[^=:]+[[:space:]]*='; then - # if the first non-comment/non-blank line of the config file looks like "foo = ...", this is probably the 2.4 and older "ini-style config format" - # mongod tries to parse config as yaml and then falls back to ini-style parsing - # https://github.com/mongodb/mongo/blob/r6.0.3/src/mongo/util/options_parser/options_parser.cpp#L1883-L1894 - echo >&2 - echo >&2 "WARNING: it appears that '$configPath' is in the older INI-style format (replaced by YAML in MongoDB 2.6)" - echo >&2 ' This script does not parse the older INI-style format, and thus will ignore it.' - echo >&2 - return 1 - fi - if [ "$mongoShell" = 'mongo' ]; then - "$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile" - else - # https://www.mongodb.com/docs/manual/reference/method/js-native/#std-label-native-in-mongosh - "$mongoShell" --norc --nodb --quiet --eval "load('/js-yaml.js'); JSON.stringify(jsyaml.load(fs.readFileSync($(_js_escape "$configPath"), 'utf8')))" > "$jsonConfigFile" - fi - if [ "$(head -c1 "$jsonConfigFile")" != '{' ] || [ "$(tail -c2 "$jsonConfigFile")" != '}' ]; then - # if the file doesn't start with "{" and end with "}", it's *probably* an error ("uncaught exception: YAMLException: foo" for example), so we should print it out - echo >&2 'error: unexpected "js-yaml.js" output while parsing config:' - cat >&2 "$jsonConfigFile" - exit 1 - fi - jq 'del(.systemLog, .processManagement, .net, .security, .replication)' "$jsonConfigFile" > "$tempConfigFile" - return 0 - fi - - return 1 -} -dbPath= -_dbPath() { - if [ -n "$dbPath" ]; then - echo "$dbPath" - return - fi - - if ! dbPath="$(_mongod_hack_get_arg_val --dbpath "$@")"; then - if _parse_config "$@"; then - dbPath="$(jq -r '.storage.dbPath // empty' "$jsonConfigFile")" - fi - fi - - if [ -z "$dbPath" ]; then - if _mongod_hack_have_arg --configsvr "$@" || { - _parse_config "$@" \ - && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ - && [ "$clusterRole" = 'configsvr' ] - }; then - # if running as config server, then the default dbpath is /data/configdb - # https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr - dbPath=/data/configdb - fi - fi - - : "${dbPath:=/data/db}" - - echo "$dbPath" -} - -if [ "$originalArgOne" = 'mongod' ]; then - file_env 'MONGO_INITDB_ROOT_USERNAME' - file_env 'MONGO_INITDB_ROOT_PASSWORD' - - mongoShell='mongo' - if ! command -v "$mongoShell" > /dev/null; then - mongoShell='mongosh' - fi - - # pre-check a few factors to see if it's even worth bothering with initdb - shouldPerformInitdb= - if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - # if we have a username/password, let's set "--auth" - _mongod_hack_ensure_arg '--auth' "$@" - set -- "${mongodHackedArgs[@]}" - shouldPerformInitdb='true' - elif [ "$MONGO_INITDB_ROOT_USERNAME" ] || [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - cat >&2 <<-'EOF' - - error: missing 'MONGO_INITDB_ROOT_USERNAME' or 'MONGO_INITDB_ROOT_PASSWORD' - both must be specified for a user to be created - - EOF - exit 1 - fi - - if [ -z "$shouldPerformInitdb" ]; then - # if we've got any /docker-entrypoint-initdb.d/* files to parse later, we should initdb - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh|*.js) # this should match the set of files we check for below - shouldPerformInitdb="$f" - break - ;; - esac - done - fi - - # check for a few known paths (to determine whether we've already initialized and should thus skip our initdb scripts) - if [ -n "$shouldPerformInitdb" ]; then - dbPath="$(_dbPath "$@")" - for path in \ - "$dbPath/WiredTiger" \ - "$dbPath/journal" \ - "$dbPath/local.0" \ - "$dbPath/storage.bson" \ - ; do - if [ -e "$path" ]; then - shouldPerformInitdb= - break - fi - done - fi - - if [ -n "$shouldPerformInitdb" ]; then - mongodHackedArgs=( "$@" ) - if _parse_config "$@"; then - _mongod_hack_ensure_arg_val --config "$tempConfigFile" "${mongodHackedArgs[@]}" - fi - _mongod_hack_ensure_arg_val --bind_ip 127.0.0.1 "${mongodHackedArgs[@]}" - _mongod_hack_ensure_arg_val --port 27017 "${mongodHackedArgs[@]}" - _mongod_hack_ensure_no_arg --bind_ip_all "${mongodHackedArgs[@]}" - - # remove "--auth" and "--replSet" for our initial startup (see https://docs.mongodb.com/manual/tutorial/enable-authentication/#start-mongodb-without-access-control) - # https://github.com/docker-library/mongo/issues/211 - _mongod_hack_ensure_no_arg --auth "${mongodHackedArgs[@]}" - # "keyFile implies security.authorization" - # https://docs.mongodb.com/manual/reference/configuration-options/#mongodb-setting-security.keyFile - _mongod_hack_ensure_no_arg_val --keyFile "${mongodHackedArgs[@]}" - if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - _mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}" - fi - - # "BadValue: need sslPEMKeyFile when SSL is enabled" vs "BadValue: need to enable SSL via the sslMode flag when using SSL configuration parameters" - tlsMode='disabled' - if _mongod_hack_have_arg '--tlsCertificateKeyFile' "$@"; then - tlsMode='allowTLS' - fi - _mongod_hack_ensure_arg_val --tlsMode "$tlsMode" "${mongodHackedArgs[@]}" - - if stat "/proc/$$/fd/1" > /dev/null && [ -w "/proc/$$/fd/1" ]; then - # https://github.com/mongodb/mongo/blob/38c0eb538d0fd390c6cb9ce9ae9894153f6e8ef5/src/mongo/db/initialize_server_global_state.cpp#L237-L251 - # https://github.com/docker-library/mongo/issues/164#issuecomment-293965668 - _mongod_hack_ensure_arg_val --logpath "/proc/$$/fd/1" "${mongodHackedArgs[@]}" - else - initdbLogPath="$(_dbPath "$@")/docker-initdb.log" - echo >&2 "warning: initdb logs cannot write to '/proc/$$/fd/1', so they are in '$initdbLogPath' instead" - _mongod_hack_ensure_arg_val --logpath "$initdbLogPath" "${mongodHackedArgs[@]}" - fi - _mongod_hack_ensure_arg --logappend "${mongodHackedArgs[@]}" - - pidfile="$TMPDIR/docker-entrypoint-temp-mongod.pid" - rm -f "$pidfile" - _mongod_hack_ensure_arg_val --pidfilepath "$pidfile" "${mongodHackedArgs[@]}" - - "${mongodHackedArgs[@]}" --fork - - mongo=( "$mongoShell" --host 127.0.0.1 --port 27017 --quiet ) - - # check to see that our "mongod" actually did start up (catches "--help", "--version", slow prealloc, etc) - # https://jira.mongodb.org/browse/SERVER-16292 - tries=30 - while true; do - if ! { [ -s "$pidfile" ] && ps "$(< "$pidfile")" &> /dev/null; }; then - # bail ASAP if "mongod" isn't even running - echo >&2 - echo >&2 "error: $originalArgOne does not appear to have stayed running -- perhaps it had an error?" - echo >&2 - exit 1 - fi - if "${mongo[@]}" 'admin' --eval 'quit(0)' &> /dev/null; then - # success! - break - fi - (( tries-- )) - if [ "$tries" -le 0 ]; then - echo >&2 - echo >&2 "error: $originalArgOne does not appear to have accepted connections quickly enough -- perhaps it had an error?" - echo >&2 - exit 1 - fi - sleep 1 - done - - if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - rootAuthDatabase='admin' - - "${mongo[@]}" "$rootAuthDatabase" <<-EOJS - db.createUser({ - user: $(_js_escape "$MONGO_INITDB_ROOT_USERNAME"), - pwd: $(_js_escape "$MONGO_INITDB_ROOT_PASSWORD"), - roles: [ { role: 'root', db: $(_js_escape "$rootAuthDatabase") } ] - }) - EOJS - fi - - export MONGO_INITDB_DATABASE="${MONGO_INITDB_DATABASE:-test}" - - echo - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; - *.js) echo "$0: running $f"; "${mongo[@]}" "$MONGO_INITDB_DATABASE" "$f"; echo ;; - *) echo "$0: ignoring $f" ;; - esac - echo - done - - "${mongodHackedArgs[@]}" --shutdown - rm -f "$pidfile" - - echo - echo 'MongoDB init process complete; ready for start up.' - echo - fi - - # MongoDB defaults to localhost-only binding - haveBindIp= - if _mongod_hack_have_arg --bind_ip "$@" || _mongod_hack_have_arg --bind_ip_all "$@"; then - haveBindIp=1 - elif _parse_config "$@" && jq --exit-status '.net.bindIp // .net.bindIpAll' "$jsonConfigFile" > /dev/null; then - haveBindIp=1 - fi - if [ -z "$haveBindIp" ]; then - # so if no "--bind_ip" is specified, let's add "--bind_ip_all" - set -- "$@" --bind_ip_all - fi - - unset "${!MONGO_INITDB_@}" -fi - -rm -f "$jsonConfigFile" "$tempConfigFile" - -exec "$@" diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh deleted file mode 100755 index ee6f476ad1..0000000000 --- a/generate-stackbrew-library.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail - -declare -A aliases=( - [8.2]='8 latest' - [7.0]='7' - [6.0]='6' -) - -self="$(basename "$BASH_SOURCE")" -cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" - -if [ "$#" -eq 0 ]; then - versions="$(jq -r 'to_entries | map(if .value then .key | @sh else empty end) | join(" ")' versions.json)" - eval "set -- $versions" -fi - -# sort version numbers with highest first -IFS=$'\n'; set -- $(sort -rV <<<"$*"); unset IFS - -# get the most recent commit which modified any of "$@" -fileCommit() { - git log -1 --format='format:%H' HEAD -- "$@" -} - -# get the most recent commit which modified "$1/Dockerfile" or any file COPY'd from "$1/Dockerfile" -dirCommit() { - local dir="$1"; shift - ( - cd "$dir" - fileCommit \ - Dockerfile \ - $(git show HEAD:./Dockerfile | awk ' - toupper($1) == "COPY" { - for (i = 2; i < NF; i++) { - print $i - } - } - ') - ) -} - -getArches() { - local repo="$1"; shift - local officialImagesBase="${BASHBREW_LIBRARY:-https://github.com/docker-library/official-images/raw/HEAD/library}/" - - local parentRepoToArchesStr - parentRepoToArchesStr="$( - find -name 'Dockerfile' -exec awk -v officialImagesBase="$officialImagesBase" ' - toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|.*\/.*)(:|$)/ { - printf "%s%s\n", officialImagesBase, $2 - } - ' '{}' + \ - | sort -u \ - | xargs -r bashbrew cat --format '["{{ .RepoName }}:{{ .TagName }}"]="{{ join " " .TagEntry.Architectures }}"' - )" - eval "declare -g -A parentRepoToArches=( $parentRepoToArchesStr )" -} -getArches 'mongo' - -cat <<-EOH -# this file is generated via https://github.com/docker-library/mongo/blob/$(fileCommit "$self")/$self - -Maintainers: Tianon Gravi (@tianon), - Joseph Ferguson (@yosifkit) -GitRepo: https://github.com/docker-library/mongo.git -EOH - -# prints "$2$1$3$1...$N" -join() { - local sep="$1"; shift - local out; printf -v out "${sep//%/%%}%s" "$@" - echo "${out#$sep}" -} - -for version; do - rcVersion="${version%-rc}" - export version rcVersion - - if ! fullVersion="$(jq -er '.[env.version] | if . then .version else empty end' versions.json)"; then - continue - fi - - if [ "$rcVersion" != "$version" ] && [ -e "$rcVersion/Dockerfile" ]; then - # if this is a "-rc" release, let's make sure the release it contains isn't already GA (and thus something we should not publish anymore) - rcFullVersion="$(jq -r '.[env.rcVersion].version' versions.json)" - latestVersion="$({ echo "$fullVersion"; echo "$rcFullVersion"; } | sort -V | tail -1)" - if [[ "$fullVersion" == "$rcFullVersion"* ]] || [ "$latestVersion" = "$rcFullVersion" ]; then - # "x.y.z-rc1" == x.y.z* - continue - fi - fi - - versionAliases=( - $fullVersion - $version - ${aliases[$version]:-} - ) - - variants="$(jq -r '.[env.version].targets.windows.variants | [""] + map("windows/" + .) | map(@sh) | join(" ")' versions.json)" - eval "variants=( $variants )" - - for v in "${variants[@]}"; do - dir="$version${v:+/$v}" - commit="$(dirCommit "$dir")" - - if [ -z "$v" ]; then - variant="$(jq -r '.[env.version] | .targets[.linux].suite' versions.json)" # "bionic", etc. - else - variant="$(basename "$v")" # windowsservercore-1809, etc. - fi - - variantAliases=( "${versionAliases[@]/%/-$variant}" ) - variantAliases=( "${variantAliases[@]//latest-/}" ) - - sharedTags=() - for windowsShared in windowsservercore nanoserver; do - if [[ "$variant" == "$windowsShared"* ]]; then - sharedTags=( "${versionAliases[@]/%/-$windowsShared}" ) - sharedTags=( "${sharedTags[@]//latest-/}" ) - break - fi - done - if [[ "$variant" == 'windowsservercore'* ]] || [ -z "$v" ]; then - sharedTags+=( "${versionAliases[@]}" ) - fi - - case "$v" in - windows/*) - # this is the really long way to say "windows-amd64" - variantArches="$(jq -r '.[env.version] | .targets.windows.arches | map("windows-" + . | @sh) | join(" ")' versions.json)" - ;; - *) - variantArches="$(jq -r '.[env.version] | .targets[.linux].arches | map(@sh) | join(" ")' versions.json)" - ;; - esac - eval "variantArches=( $variantArches )" - - constraints= - if [ -n "$v" ]; then - constraints="$variant" - if [[ "$variant" == nanoserver-* ]]; then - # nanoserver variants "COPY --from=...:...-windowsservercore-... ..." - constraints+=", windowsservercore-${variant#nanoserver-}" - fi - fi - - echo - echo "Tags: $(join ', ' "${variantAliases[@]}")" - if [ "${#sharedTags[@]}" -gt 0 ]; then - echo "SharedTags: $(join ', ' "${sharedTags[@]}")" - fi - cat <<-EOE - Architectures: $(join ', ' "${variantArches[@]}") - GitCommit: $commit - Directory: $dir - EOE - [ -z "$constraints" ] || echo "Constraints: $constraints" - done -done diff --git a/8.0/Dockerfile b/image/Dockerfile similarity index 93% rename from 8.0/Dockerfile rename to image/Dockerfile index 7cd1e0d7e3..d886fcac4e 100644 --- a/8.0/Dockerfile +++ b/image/Dockerfile @@ -1,8 +1,7 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" -# -# PLEASE DO NOT EDIT IT DIRECTLY. -# +# The recipe of ghcr.io/fintermobilityas/mongo-enterprise (see AGENTS.md). It +# started as the mongo image of docker-library/mongo. publish.ps1 passes +# MONGO_VERSION, MONGO_MAJOR and MONGOSH_CHANNEL; the defaults below must be the +# same values, and the "Publish image" workflow checks that. FROM ubuntu:noble @@ -91,15 +90,15 @@ ARG MONGO_PACKAGE=mongodb-enterprise ARG MONGO_REPO=repo.mongodb.com ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO} -ARG MONGO_MAJOR=8.3 -ARG MONGOSH_CHANNEL=8.3 +ARG MONGO_MAJOR=9.0 +ARG MONGOSH_CHANNEL=9.0 ENV MONGO_MAJOR=${MONGO_MAJOR} MONGOSH_CHANNEL=${MONGOSH_CHANNEL} RUN echo "deb [ signed-by=/etc/apt/keyrings/mongodb.asc ] http://$MONGO_REPO/apt/ubuntu noble/${MONGO_PACKAGE%-unstable}/$MONGO_MAJOR multiverse" | tee "/etc/apt/sources.list.d/${MONGO_PACKAGE%-unstable}.list" \ && if [ -n "$MONGOSH_CHANNEL" ] && [ "$MONGOSH_CHANNEL" != "$MONGO_MAJOR" ]; then \ echo "deb [ signed-by=/etc/apt/keyrings/mongodb.asc ] http://$MONGO_REPO/apt/ubuntu noble/${MONGO_PACKAGE%-unstable}/$MONGOSH_CHANNEL multiverse" | tee /etc/apt/sources.list.d/mongodb-mongosh.list; \ fi -# https://docs.mongodb.org/master/release-notes/8.0/ +# https://www.mongodb.com/docs/manual/release-notes/9.0/ ARG MONGO_VERSION=9.0.4 ENV MONGO_VERSION=${MONGO_VERSION} # 2026-10-13, mongodb-enterprise 9.0.4 from the 9.0 GA apt channel diff --git a/7.0/docker-entrypoint.sh b/image/docker-entrypoint.sh similarity index 100% rename from 7.0/docker-entrypoint.sh rename to image/docker-entrypoint.sh diff --git a/pgp-keys.json b/pgp-keys.json deleted file mode 100644 index 88fce4479a..0000000000 --- a/pgp-keys.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "dev": { - "url": "https://pgp.mongodb.com/server-dev.asc", - "fingerprints": [ - "28DE23AF08040FB24C33F36381B0EBBBADCEA95C" - ] - }, - "8.0": { - "url": "https://pgp.mongodb.com/server-8.0.asc", - "fingerprints": [ - "4B0752C1BCA238C0B4EE14DC41DE058A4E7DCA05" - ] - }, - "7.0": { - "url": "https://pgp.mongodb.com/server-7.0.asc", - "fingerprints": [ - "E58830201F7DD82CD808AA84160D26BB1785BA38" - ] - }, - "6.0": { - "url": "https://pgp.mongodb.com/server-6.0.asc", - "fingerprints": [ - "39BD841E4BE5FB195A65400E6A26B1AE64C3C388" - ] - }, - "5.0": { - "url": "https://pgp.mongodb.com/server-5.0.asc", - "fingerprints": [ - "F5679A222C647C87527C2F8CB00A0BD1E2C63C11" - ] - }, - "4.4": { - "url": "https://pgp.mongodb.com/server-4.4.asc", - "fingerprints": [ - "20691EEC35216C63CAF66CE1656408E390CFB1F5" - ] - }, - "4.2": { - "url": "https://pgp.mongodb.com/server-4.2.asc", - "fingerprints": [ - "E162F504A20CDF15827F718D4B7C549A058F8B6B" - ] - }, - "4.0": { - "url": "https://pgp.mongodb.com/server-4.0.asc", - "fingerprints": [ - "9DA31620334BD75D9DCB49F368818C72E52529D4" - ] - } -} diff --git a/pgp-keys.sh b/pgp-keys.sh deleted file mode 100755 index 35d01a47bd..0000000000 --- a/pgp-keys.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail - -versions="$(jq -r 'keys_unsorted | map(@sh) | join(" ")' pgp-keys.json)" -eval "set -- $versions" - -json='{}' - -for version; do - url="https://pgp.mongodb.com/server-$version.asc" - export version url - fingerprints="$( - docker run --rm --env url buildpack-deps:bookworm-curl bash -Eeuo pipefail -xc ' - wget -O key.asc "$url" >&2 - gpg --batch --import key.asc >&2 - gpg --batch --fingerprint --with-colons | grep "^fpr:" | cut -d: -f10 - ' - )" - export fingerprints - json="$(jq <<<"$json" -c ' - .[env.version] = { - url: env.url, - fingerprints: ( - env.fingerprints - | rtrimstr("\n") - | split("\n") - ), - } - ')" -done - -jq <<<"$json" ' - to_entries - | sort_by(.key | split(".") | map(tonumber? // .)) - | reverse - | from_entries -' > pgp-keys.json diff --git a/publish.ps1 b/publish.ps1 index 24f45af9aa..5d5de8e26c 100644 --- a/publish.ps1 +++ b/publish.ps1 @@ -6,7 +6,7 @@ param ( ) $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition -$buildPath = Join-Path -Path $scriptPath -ChildPath "8.0" +$buildPath = Join-Path -Path $scriptPath -ChildPath "image" $buildArgs = @() diff --git a/update.sh b/update.sh deleted file mode 100755 index bac2d7581c..0000000000 --- a/update.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail - -cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" - -./versions.sh "$@" -./apply-templates.sh "$@" diff --git a/versions.json b/versions.json deleted file mode 100644 index cd0907969e..0000000000 --- a/versions.json +++ /dev/null @@ -1,139 +0,0 @@ -{ - "7.0": { - "changes": "https://jira.mongodb.org/issues/?jql=project%20%3D%20SERVER%20AND%20fixVersion%20%3D%20%227.0.45%22%20ORDER%20BY%20status%20DESC%2C%20priority%20DESC", - "date": "09/24/2026", - "eol": "2027-08-31", - "githash": "a52313e13ab55c9bddf7c3ff91dab286fa381796", - "linux": "ubuntu2204", - "notes": "https://docs.mongodb.org/master/release-notes/7.0/", - "pgp": [ - { - "fingerprints": [ - "E58830201F7DD82CD808AA84160D26BB1785BA38" - ], - "url": "https://pgp.mongodb.com/server-7.0.asc" - } - ], - "targets": { - "debian11": { - "arches": [ - "amd64" - ], - "image": "debian:bullseye-slim", - "suite": "bullseye" - }, - "debian12": { - "arches": [ - "amd64" - ], - "image": "debian:bookworm-slim", - "suite": "bookworm" - }, - "ubuntu2004": { - "arches": [ - "amd64", - "arm64v8" - ], - "image": "ubuntu:focal", - "suite": "focal" - }, - "ubuntu2204": { - "arches": [ - "amd64", - "arm64v8" - ], - "image": "ubuntu:jammy", - "suite": "jammy" - }, - "windows": { - "arches": [ - "amd64" - ], - "features": [ - "MiscellaneousTools", - "Router", - "ServerNoService" - ], - "msi": "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-7.0.45-signed.msi", - "sha256": "c523c13eec4bfe0900f6d0a4db9f7033276bafeda6786f388297c59f13eaee63", - "variants": [ - "windowsservercore-ltsc2025", - "windowsservercore-ltsc2022", - "nanoserver-ltsc2022" - ] - } - }, - "version": "7.0.45" - }, - "7.0-rc": null, - "8.0": { - "changes": "https://jira.mongodb.org/issues/?jql=project%20%3D%20SERVER%20AND%20fixVersion%20%3D%20%228.0.34%22%20ORDER%20BY%20status%20DESC%2C%20priority%20DESC", - "date": "09/24/2026", - "eol": "2029-10-31", - "githash": "51db4515a6597aedcf6188ee4e48a27e65b065ae", - "linux": "ubuntu2404", - "notes": "https://docs.mongodb.org/master/release-notes/8.0/", - "pgp": [ - { - "fingerprints": [ - "4B0752C1BCA238C0B4EE14DC41DE058A4E7DCA05" - ], - "url": "https://pgp.mongodb.com/server-8.0.asc" - } - ], - "targets": { - "debian12": { - "arches": [ - "amd64" - ], - "image": "debian:bookworm-slim", - "suite": "bookworm" - }, - "ubuntu2004": { - "arches": [ - "amd64", - "arm64v8" - ], - "image": "ubuntu:focal", - "suite": "focal" - }, - "ubuntu2204": { - "arches": [ - "amd64", - "arm64v8" - ], - "image": "ubuntu:jammy", - "suite": "jammy" - }, - "ubuntu2404": { - "arches": [ - "amd64", - "arm64v8" - ], - "image": "ubuntu:noble", - "suite": "noble" - }, - "windows": { - "arches": [ - "amd64" - ], - "features": [ - "MiscellaneousTools", - "Router", - "ServerNoService" - ], - "msi": "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-8.0.34-signed.msi", - "sha256": "2e6250a847696803729cb657251d479bed08fc26f94ddf835657e2747b71e45f", - "variants": [ - "windowsservercore-ltsc2025", - "windowsservercore-ltsc2022", - "nanoserver-ltsc2022" - ] - } - }, - "version": "8.0.34" - }, - "8.0-rc": null, - "8.2": null, - "8.2-rc": null -} diff --git a/versions.sh b/versions.sh deleted file mode 100755 index e26bb38d73..0000000000 --- a/versions.sh +++ /dev/null @@ -1,244 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail - -shell="$( - wget -qO- 'https://downloads.mongodb.org/current.json' \ - | jq -r ' - [ - .versions[] - - # filter out download objects we are definitely not interested in (enterprise, rhel, etc) - | del(.downloads[] | select( - ( - .edition == "base" - or .edition == "targeted" - ) - and ( - .target // "" - | ( - test("^(" + ([ - "debian[0-9]+", # debian10, debian11, etc - "ubuntu[0-9]{4}", # ubuntu2004, ubuntu1804, etc - "windows.*" # windows, windows_x86_64, windows_x86_64-2012plus, etc - ] | join("|")) + ")$") - and ( - # a few things old enough we do not want anything to do with them /o\. - test("^(" + ([ - "debian[89].*", - "ubuntu1[0-9].*" - ] | join("|")) + ")$") - | not - ) - ) - ) - | not)) - - | { - version: ( - # convert "4.4.x" into "4.4" and "4.9.x-rcY" into "4.9-rc" - (.version | split(".")[0:2] | join(".")) - + if .release_candidate then "-rc" else "" end - ), - meta: ., - } - - # inject upstream EOL dates - | .meta.eol = ( - .version - | rtrimstr("-rc") - | { - # https://www.mongodb.com/support-policy/lifecycles - # (only needs to list versions that currently exist in "current.json" that we are scraping, and only because they do not get removed promptly at EOL) - - "8.0": "2029-10-31", - "7.0": "2027-08-31", - "6.0": "2025-07-31", - "5.0": "2024-10-31", - "4.4": "2024-02-29", - - # "Rapid Releases" and "Minor Releases" - "8.2": "2026-03-30", - }[.] - ) - # ... so we can filter out EOL versions (because "current.json" continues to list them for some period of time, but with no explicitly differentiating metadata about their EOL state) - | select( - .meta.eol - | not or . >= (now | strftime("%Y-%m-%d")) - # (ie, only keep versions whose EOL status is unknown because we need to update the table above or versions we know are not yet EOL) - ) - ] - - # in case of duplicates that map to the same "X.Y[-rc]", prefer the first one (the upstream file is typically in descending sorted order, so we do not need to get much more complicated than this) - # *not* doing this was actually totally fine/sane up until 2024-08-14, because prior to that there were never any duplicates in the upstream file so everything "just worked" - # on 2024-08-14, upstream released 7.0.14-rc0, but (accidentally?) left 7.0.13-rc1 listed in the file, and without this fix, we prefer the later entry due to how we export the data below - | unique_by(.version) - - # now convert all that data to a basic shell list + map so we can loop over/use it appropriately - | "allVersions=( " + ( - map(.version | ., if endswith("-rc") then rtrimstr("-rc") else . + "-rc" end) - | unique - | map(@sh) - | join(" ") - ) + " )\n" - + "declare -A versionMeta=(\n" + ( - map( - "\t[" + (.version | @sh) + "]=" - + (.meta | @json | @sh) - ) | join("\n") - ) + "\n)" - ' -)" -eval "$shell" - -versions=( "$@" ) -if [ ${#versions[@]} -eq 0 ]; then - versions=( "${allVersions[@]}" ) - json='{}' -else - versions=( "${versions[@]%/}" ) - json="$(< versions.json)" -fi - -for version in "${versions[@]}"; do - export version - - if [ -z "${versionMeta[$version]:+foo}" ]; then - echo >&2 "warning: skipping/removing '$version' (does not appear to exist upstream)" - json="$(jq <<<"$json" -c '.[env.version] = null')" - continue - fi - _jq() { jq <<<"${versionMeta[$version]}" "$@"; } - - #echo "$version: $fullVersion" - _jq -r 'env.version + ": " + .version' - - # download the Windows MSI sha256 (so we can embed it) - msiUrl="$(_jq -r '.downloads[] | select(.target | test("^windows")) | .msi // ""')" - [ -n "$msiUrl" ] - [[ "$msiUrl" != *$'\n'* ]] # just in case they do something wild like support windows-arm64 :D - # 4.3 doesn't seem to have a sha256 file (403 forbidden), so this has to be optional :( - msiSha256="$(wget -qO- "$msiUrl.sha256" || :)" - msiSha256="${msiSha256%% *}" - export msiUrl msiSha256 - - json="$( - { - jq <<<"$json" -c . - _jq --slurpfile pgpKeys pgp-keys.json '{ (env.version): ( - $pgpKeys[0] as $pgp - | (env.version | rtrimstr("-rc")) as $rcVersion - | with_entries(select(IN(.key; - # interesting bits of raw upstream metadata - "changes", - "date", - "githash", - "notes", - "version", - "eol", # not exactly "upstream" metadata, but metadata from upstream that we carefully injected - empty - ))) - + { - pgp: [ - if env.version != $rcVersion then - # the "testing" repository (used for RCs) has a dedicated PGP key (but still needs the "release" key for the release line) - $pgp.dev - else empty end, - - ( - $pgp[$rcVersion] # prefer an exact match (4.4 resurrection for CVE-2025-14847 "MongoBleed") - // $pgp[$rcVersion | sub("[.][0-9]+$"; ".0")] # normalizing 8.x to 8.0 because "Rapid Releases" use the key of the most recent major - ), - - empty - ], - targets: ( - reduce ( - .downloads[] - | .target |= sub("^windows.*$"; "windows") - ) as $d ({}; $d.target as $t | - .[$t].arches |= (. + [ - { - # mapping from "current.json" arch values to bashbrew arch values - "aarch64": "arm64v8", - "arm64": "arm64v8", - "s390x": "s390x", - "x86_64": "amd64", - }[$d.arch] // ("unknown:" + $d.arch) - ] | sort) - | if $t | test("^(debian|ubuntu)") then - .[$t].image = ( - { - "debian10": "debian:buster-slim", - "debian11": "debian:bullseye-slim", - "debian12": "debian:bookworm-slim", - "debian13": "debian:trixie-slim", - "debian14": "debian:forky-slim", - "ubuntu1604": "ubuntu:xenial", - "ubuntu1804": "ubuntu:bionic", - "ubuntu2004": "ubuntu:focal", - "ubuntu2204": "ubuntu:jammy", - "ubuntu2404": "ubuntu:noble", - }[$t] // "unknown" - ) - | .[$t].suite = ( - .[$t].image - | gsub("^.*:|-slim$"; "") - ) - else . end - ) - ), - } - | .targets.windows += { - msi: env.msiUrl, - sha256: env.msiSha256, - variants: [ - "windowsservercore-ltsc2025", - "windowsservercore-ltsc2022", - #"nanoserver-ltsc2025", # The command "cmd /S /C mongod --version" returned a non-zero code: 3221225785 - "nanoserver-ltsc2022", - empty # trailing comma - ], - features: ([ - # https://github.com/mongodb/mongo/blob/r6.0.0/src/mongo/installer/msi/wxs/FeatureFragment.wxs#L9-L85 (no Client) - # https://github.com/mongodb/mongo/blob/r4.4.2/src/mongo/installer/msi/wxs/FeatureFragment.wxs#L9-L92 (no MonitoringTools,ImportExportTools) - "ServerNoService", - if [ "5.0" ] | index(env.version | rtrimstr("-rc")) then - "Client" - else empty end, - "Router", - "MiscellaneousTools", - empty - ] | sort), - } - # ignore anything that does not support amd64 - | del(.targets[] | select(.arches | index("amd64") | not)) - | .linux = ( - # automatically choose an appropriate linux target, preferring (in order): - # - more supported architectures - # - debian over ubuntu - # - newer release over older - .targets - | to_entries - | [ .[] | select(.key | test("^(debian|ubuntu)")) ] - | sort_by([ - (.value.arches | length), - ( - .key - | if startswith("ubuntu") then - 1 - elif startswith("debian") then - 2 - else 0 end - ), - (.key | sub("^(debian|ubuntu)"; "") | tonumber), # 10, 11, 2004, 1804, etc - .key - ]) - | reverse[0].key - ) - | . - ) }' - } | jq -cs add - )" -done - -jq <<<"$json" -S . > versions.json