forked from docker-library/mongo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile-windows.template
59 lines (53 loc) · 1.96 KB
/
Dockerfile-windows.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM mcr.microsoft.com/windows/servercore:placeholder
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
ENV MONGO_VERSION placeholder
ENV MONGO_DOWNLOAD_URL placeholder
ENV MONGO_DOWNLOAD_SHA256=placeholder
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=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); \
\
Write-Host 'Verifying install ...'; \
Write-Host ' mongo --version'; mongo --version; \
Write-Host ' mongod --version'; mongod --version; \
\
Write-Host 'Removing ...'; \
Remove-Item C:\windows\installer\*.msi -Force; \
Remove-Item mongo.msi -Force; \
\
Write-Host 'Complete.';
VOLUME C:\\data\\db C:\\data\\configdb
# TODO docker-entrypoint.ps1 ? (for "docker run <image> --flag --flag --flag")
EXPOSE 27017
CMD ["mongod", "--bind_ip_all"]