Skip to content

Commit 69ff4ee

Browse files
committed
Adjust "ADDLOCAL" to disable the Windows service
Also, update Dockerfile to provide installer logs when the installer fails in an obvious way.
1 parent da7e52d commit 69ff4ee

File tree

10 files changed

+103
-9
lines changed

10 files changed

+103
-9
lines changed

3.6/windows/windowsservercore-1809/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
2626
'mongo.msi', \
2727
'/quiet', \
2828
'/qn', \
29+
'/l*v', 'install.log', \
30+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter
2931
'INSTALLLOCATION=C:\mongodb', \
30-
'ADDLOCAL=all' \
32+
'ADDLOCAL=Server,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \
3133
); \
34+
if (-Not (Test-Path C:\mongodb\bin\mongo.exe -PathType Leaf)) { \
35+
Write-Host 'Installer failed!'; \
36+
Get-Content install.log; \
37+
exit 1; \
38+
}; \
39+
Remove-Item install.log; \
40+
\
3241
$env:PATH = 'C:\mongodb\bin;' + $env:PATH; \
3342
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
3443
\

3.6/windows/windowsservercore-ltsc2016/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
2626
'mongo.msi', \
2727
'/quiet', \
2828
'/qn', \
29+
'/l*v', 'install.log', \
30+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter
2931
'INSTALLLOCATION=C:\mongodb', \
30-
'ADDLOCAL=all' \
32+
'ADDLOCAL=Server,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \
3133
); \
34+
if (-Not (Test-Path C:\mongodb\bin\mongo.exe -PathType Leaf)) { \
35+
Write-Host 'Installer failed!'; \
36+
Get-Content install.log; \
37+
exit 1; \
38+
}; \
39+
Remove-Item install.log; \
40+
\
3241
$env:PATH = 'C:\mongodb\bin;' + $env:PATH; \
3342
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
3443
\

4.0/windows/windowsservercore-1809/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
2626
'mongo.msi', \
2727
'/quiet', \
2828
'/qn', \
29+
'/l*v', 'install.log', \
30+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter
2931
'INSTALLLOCATION=C:\mongodb', \
30-
'ADDLOCAL=all' \
32+
'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \
3133
); \
34+
if (-Not (Test-Path C:\mongodb\bin\mongo.exe -PathType Leaf)) { \
35+
Write-Host 'Installer failed!'; \
36+
Get-Content install.log; \
37+
exit 1; \
38+
}; \
39+
Remove-Item install.log; \
40+
\
3241
$env:PATH = 'C:\mongodb\bin;' + $env:PATH; \
3342
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
3443
\

4.0/windows/windowsservercore-ltsc2016/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
2626
'mongo.msi', \
2727
'/quiet', \
2828
'/qn', \
29+
'/l*v', 'install.log', \
30+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter
2931
'INSTALLLOCATION=C:\mongodb', \
30-
'ADDLOCAL=all' \
32+
'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \
3133
); \
34+
if (-Not (Test-Path C:\mongodb\bin\mongo.exe -PathType Leaf)) { \
35+
Write-Host 'Installer failed!'; \
36+
Get-Content install.log; \
37+
exit 1; \
38+
}; \
39+
Remove-Item install.log; \
40+
\
3241
$env:PATH = 'C:\mongodb\bin;' + $env:PATH; \
3342
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
3443
\

4.2/windows/windowsservercore-1809/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
2626
'mongo.msi', \
2727
'/quiet', \
2828
'/qn', \
29+
'/l*v', 'install.log', \
30+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter
2931
'INSTALLLOCATION=C:\mongodb', \
30-
'ADDLOCAL=all' \
32+
'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \
3133
); \
34+
if (-Not (Test-Path C:\mongodb\bin\mongo.exe -PathType Leaf)) { \
35+
Write-Host 'Installer failed!'; \
36+
Get-Content install.log; \
37+
exit 1; \
38+
}; \
39+
Remove-Item install.log; \
40+
\
3241
$env:PATH = 'C:\mongodb\bin;' + $env:PATH; \
3342
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
3443
\

4.2/windows/windowsservercore-ltsc2016/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
2626
'mongo.msi', \
2727
'/quiet', \
2828
'/qn', \
29+
'/l*v', 'install.log', \
30+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter
2931
'INSTALLLOCATION=C:\mongodb', \
30-
'ADDLOCAL=all' \
32+
'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools,MonitoringTools,ImportExportTools' \
3133
); \
34+
if (-Not (Test-Path C:\mongodb\bin\mongo.exe -PathType Leaf)) { \
35+
Write-Host 'Installer failed!'; \
36+
Get-Content install.log; \
37+
exit 1; \
38+
}; \
39+
Remove-Item install.log; \
40+
\
3241
$env:PATH = 'C:\mongodb\bin;' + $env:PATH; \
3342
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
3443
\

4.4/windows/windowsservercore-1809/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
2626
'mongo.msi', \
2727
'/quiet', \
2828
'/qn', \
29+
'/l*v', 'install.log', \
30+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter
2931
'INSTALLLOCATION=C:\mongodb', \
30-
'ADDLOCAL=all' \
32+
'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools' \
3133
); \
34+
if (-Not (Test-Path C:\mongodb\bin\mongo.exe -PathType Leaf)) { \
35+
Write-Host 'Installer failed!'; \
36+
Get-Content install.log; \
37+
exit 1; \
38+
}; \
39+
Remove-Item install.log; \
40+
\
3241
$env:PATH = 'C:\mongodb\bin;' + $env:PATH; \
3342
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
3443
\

4.4/windows/windowsservercore-ltsc2016/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
2626
'mongo.msi', \
2727
'/quiet', \
2828
'/qn', \
29+
'/l*v', 'install.log', \
30+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter
2931
'INSTALLLOCATION=C:\mongodb', \
30-
'ADDLOCAL=all' \
32+
'ADDLOCAL=ServerNoService,Client,Router,MiscellaneousTools' \
3133
); \
34+
if (-Not (Test-Path C:\mongodb\bin\mongo.exe -PathType Leaf)) { \
35+
Write-Host 'Installer failed!'; \
36+
Get-Content install.log; \
37+
exit 1; \
38+
}; \
39+
Remove-Item install.log; \
40+
\
3241
$env:PATH = 'C:\mongodb\bin;' + $env:PATH; \
3342
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
3443
\

Dockerfile-windows.template

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
2626
'mongo.msi', \
2727
'/quiet', \
2828
'/qn', \
29+
'/l*v', 'install.log', \
30+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#run-the-windows-installer-from-the-windows-command-interpreter
2931
'INSTALLLOCATION=C:\mongodb', \
30-
'ADDLOCAL=all' \
32+
'ADDLOCAL=placeholder' \
3133
); \
34+
if (-Not (Test-Path C:\mongodb\bin\mongo.exe -PathType Leaf)) { \
35+
Write-Host 'Installer failed!'; \
36+
Get-Content install.log; \
37+
exit 1; \
38+
}; \
39+
Remove-Item install.log; \
40+
\
3241
$env:PATH = 'C:\mongodb\bin;' + $env:PATH; \
3342
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
3443
\

update.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ for version in "${versions[@]}"; do
180180
# 4.3 doesn't seem to have a sha256 file (403 forbidden), so this has to be optional :(
181181
windowsSha256="$(curl -fsSL "$windowsMsi.sha256" | cut -d' ' -f1 || :)"
182182

183+
# https://github.com/mongodb/mongo/blob/r4.4.2/src/mongo/installer/msi/wxs/FeatureFragment.wxs#L9-L92 (no MonitoringTools,ImportExportTools)
184+
# https://github.com/mongodb/mongo/blob/r4.2.11/src/mongo/installer/msi/wxs/FeatureFragment.wxs#L9-L116
185+
# https://github.com/mongodb/mongo/blob/r4.0.21/src/mongo/installer/msi/wxs/FeatureFragment.wxs#L9-L128
186+
# https://github.com/mongodb/mongo/blob/r3.6.21/src/mongo/installer/msi/wxs/FeatureFragment.wxs#L9-L102 (no ServerNoService, only Server)
187+
windowsFeatures='ServerNoService,Client,Router,MiscellaneousTools'
188+
case "$rcVersion" in
189+
4.2 | 4.0 | 3.6) windowsFeatures+=',MonitoringTools,ImportExportTools' ;;
190+
esac
191+
if [ "$rcVersion" = '3.6' ]; then
192+
windowsFeatures="${windowsFeatures//ServerNoService/Server}"
193+
fi
194+
183195
for winVariant in \
184196
windowsservercore-{1809,ltsc2016} \
185197
; do
@@ -190,6 +202,7 @@ for version in "${versions[@]}"; do
190202
-e 's!^(ENV MONGO_DOWNLOAD_URL) .*!\1 '"$windowsMsi"'!' \
191203
-e 's/^(ENV MONGO_DOWNLOAD_SHA256)=.*/\1='"$windowsSha256"'/' \
192204
-e 's!^(FROM .+):.+!\1:'"${winVariant#*-}"'!' \
205+
-e 's!(ADDLOCAL)=placeholder!\1='"$windowsFeatures"'!' \
193206
Dockerfile-windows.template \
194207
> "$version/windows/$winVariant/Dockerfile"
195208
done

0 commit comments

Comments
 (0)