-
Notifications
You must be signed in to change notification settings - Fork 633
/
Copy pathDockerfile
48 lines (42 loc) · 1.61 KB
/
Dockerfile
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
FROM microsoft/windowsservercore
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
ENV MONGO_VERSION 3.4.0
ENV MONGO_DOWNLOAD_URL http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-${MONGO_VERSION}-signed.msi
ENV MONGO_DOWNLOAD_SHA256 4fb83583305d97e8600f705944ba9586fd8e121a1c989165b8fd4ddb28358b4d
RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
(New-Object System.Net.WebClient).DownloadFile($env:MONGO_DOWNLOAD_URL, 'mongo.msi'); \
\
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', \
'INSTALLLOCATION=C:\mongodb', \
'ADDLOCAL=all' \
); \
$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:\mongodb\bin\*.pdb -Force; \
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"]