From 69ff4eedfbae6012b7c56de2c0fed730b70b3d18 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Mon, 30 Nov 2020 12:53:01 -0800 Subject: [PATCH] Adjust "ADDLOCAL" to disable the Windows service Also, update Dockerfile to provide installer logs when the installer fails in an obvious way. --- 3.6/windows/windowsservercore-1809/Dockerfile | 11 ++++++++++- 3.6/windows/windowsservercore-ltsc2016/Dockerfile | 11 ++++++++++- 4.0/windows/windowsservercore-1809/Dockerfile | 11 ++++++++++- 4.0/windows/windowsservercore-ltsc2016/Dockerfile | 11 ++++++++++- 4.2/windows/windowsservercore-1809/Dockerfile | 11 ++++++++++- 4.2/windows/windowsservercore-ltsc2016/Dockerfile | 11 ++++++++++- 4.4/windows/windowsservercore-1809/Dockerfile | 11 ++++++++++- 4.4/windows/windowsservercore-ltsc2016/Dockerfile | 11 ++++++++++- Dockerfile-windows.template | 11 ++++++++++- update.sh | 13 +++++++++++++ 10 files changed, 103 insertions(+), 9 deletions(-) diff --git a/3.6/windows/windowsservercore-1809/Dockerfile b/3.6/windows/windowsservercore-1809/Dockerfile index 2858395e23..4aa098ee26 100644 --- a/3.6/windows/windowsservercore-1809/Dockerfile +++ b/3.6/windows/windowsservercore-1809/Dockerfile @@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ '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=all' \ + 'ADDLOCAL=Server,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \ ); \ + if (-Not (Test-Path C:\mongodb\bin\mongo.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); \ \ diff --git a/3.6/windows/windowsservercore-ltsc2016/Dockerfile b/3.6/windows/windowsservercore-ltsc2016/Dockerfile index b3142dd905..157102a460 100644 --- a/3.6/windows/windowsservercore-ltsc2016/Dockerfile +++ b/3.6/windows/windowsservercore-ltsc2016/Dockerfile @@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ '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=all' \ + 'ADDLOCAL=Server,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \ ); \ + if (-Not (Test-Path C:\mongodb\bin\mongo.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); \ \ diff --git a/4.0/windows/windowsservercore-1809/Dockerfile b/4.0/windows/windowsservercore-1809/Dockerfile index 64cf086660..3c55436b9f 100644 --- a/4.0/windows/windowsservercore-1809/Dockerfile +++ b/4.0/windows/windowsservercore-1809/Dockerfile @@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ '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=all' \ + 'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \ ); \ + if (-Not (Test-Path C:\mongodb\bin\mongo.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); \ \ diff --git a/4.0/windows/windowsservercore-ltsc2016/Dockerfile b/4.0/windows/windowsservercore-ltsc2016/Dockerfile index ac42d7ae03..6f81a3c354 100644 --- a/4.0/windows/windowsservercore-ltsc2016/Dockerfile +++ b/4.0/windows/windowsservercore-ltsc2016/Dockerfile @@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ '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=all' \ + 'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \ ); \ + if (-Not (Test-Path C:\mongodb\bin\mongo.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); \ \ diff --git a/4.2/windows/windowsservercore-1809/Dockerfile b/4.2/windows/windowsservercore-1809/Dockerfile index ed59b8b745..5409edd951 100644 --- a/4.2/windows/windowsservercore-1809/Dockerfile +++ b/4.2/windows/windowsservercore-1809/Dockerfile @@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ '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=all' \ + 'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \ ); \ + if (-Not (Test-Path C:\mongodb\bin\mongo.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); \ \ diff --git a/4.2/windows/windowsservercore-ltsc2016/Dockerfile b/4.2/windows/windowsservercore-ltsc2016/Dockerfile index 218b6d2e35..b63574389d 100644 --- a/4.2/windows/windowsservercore-ltsc2016/Dockerfile +++ b/4.2/windows/windowsservercore-ltsc2016/Dockerfile @@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ '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=all' \ + 'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \ ); \ + if (-Not (Test-Path C:\mongodb\bin\mongo.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); \ \ diff --git a/4.4/windows/windowsservercore-1809/Dockerfile b/4.4/windows/windowsservercore-1809/Dockerfile index aac63f5ea5..7f20cd6dcb 100644 --- a/4.4/windows/windowsservercore-1809/Dockerfile +++ b/4.4/windows/windowsservercore-1809/Dockerfile @@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ '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=all' \ + 'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools' \ ); \ + if (-Not (Test-Path C:\mongodb\bin\mongo.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); \ \ diff --git a/4.4/windows/windowsservercore-ltsc2016/Dockerfile b/4.4/windows/windowsservercore-ltsc2016/Dockerfile index 87bc3de750..770ab7428e 100644 --- a/4.4/windows/windowsservercore-ltsc2016/Dockerfile +++ b/4.4/windows/windowsservercore-ltsc2016/Dockerfile @@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ '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=all' \ + 'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools' \ ); \ + if (-Not (Test-Path C:\mongodb\bin\mongo.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); \ \ diff --git a/Dockerfile-windows.template b/Dockerfile-windows.template index 8644f02f9b..7a06c1f099 100644 --- a/Dockerfile-windows.template +++ b/Dockerfile-windows.template @@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ '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=all' \ + 'ADDLOCAL=placeholder' \ ); \ + if (-Not (Test-Path C:\mongodb\bin\mongo.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); \ \ diff --git a/update.sh b/update.sh index 7732eda75a..29b064d15f 100755 --- a/update.sh +++ b/update.sh @@ -180,6 +180,18 @@ for version in "${versions[@]}"; do # 4.3 doesn't seem to have a sha256 file (403 forbidden), so this has to be optional :( windowsSha256="$(curl -fsSL "$windowsMsi.sha256" | cut -d' ' -f1 || :)" + # https://github.com/mongodb/mongo/blob/r4.4.2/src/mongo/installer/msi/wxs/FeatureFragment.wxs#L9-L92 (no MonitoringTools,ImportExportTools) + # https://github.com/mongodb/mongo/blob/r4.2.11/src/mongo/installer/msi/wxs/FeatureFragment.wxs#L9-L116 + # https://github.com/mongodb/mongo/blob/r4.0.21/src/mongo/installer/msi/wxs/FeatureFragment.wxs#L9-L128 + # https://github.com/mongodb/mongo/blob/r3.6.21/src/mongo/installer/msi/wxs/FeatureFragment.wxs#L9-L102 (no ServerNoService, only Server) + windowsFeatures='ServerNoService,Client,Router,MiscellaneousTools' + case "$rcVersion" in + 4.2 | 4.0 | 3.6) windowsFeatures+=',MonitoringTools,ImportExportTools' ;; + esac + if [ "$rcVersion" = '3.6' ]; then + windowsFeatures="${windowsFeatures//ServerNoService/Server}" + fi + for winVariant in \ windowsservercore-{1809,ltsc2016} \ ; do @@ -190,6 +202,7 @@ for version in "${versions[@]}"; do -e 's!^(ENV MONGO_DOWNLOAD_URL) .*!\1 '"$windowsMsi"'!' \ -e 's/^(ENV MONGO_DOWNLOAD_SHA256)=.*/\1='"$windowsSha256"'/' \ -e 's!^(FROM .+):.+!\1:'"${winVariant#*-}"'!' \ + -e 's!(ADDLOCAL)=placeholder!\1='"$windowsFeatures"'!' \ Dockerfile-windows.template \ > "$version/windows/$winVariant/Dockerfile" done