Skip to content

Commit 0f728ae

Browse files
authored
Merge pull request #109 from infosiftr/windows
Add new "windowsservercore" variants
2 parents 07f3923 + 89549b2 commit 0f728ae

File tree

5 files changed

+191
-0
lines changed

5 files changed

+191
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM microsoft/windowsservercore
2+
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
4+
5+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
6+
RUN [Environment]::SetEnvironmentVariable('PATH', 'C:\mongodb\bin;' + $env:PATH, [EnvironmentVariableTarget]::Machine);
7+
# doing this first to share cache across versions more aggressively
8+
9+
ENV MONGO_VERSION 3.0.12
10+
ENV MONGO_DOWNLOAD_URL http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-${MONGO_VERSION}-signed.msi
11+
ENV MONGO_DOWNLOAD_SHA256 be537b5fdc1763bb8640ac6384a44fa787c12499cfa648338c0695c5752de18a
12+
13+
RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
14+
(New-Object System.Net.WebClient).DownloadFile($env:MONGO_DOWNLOAD_URL, 'mongo.msi'); \
15+
\
16+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256); \
17+
if ((Get-FileHash mongo.msi -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { \
18+
Write-Host 'FAILED!'; \
19+
exit 1; \
20+
}; \
21+
\
22+
Write-Host 'Installing ...'; \
23+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#install-mongodb-community-edition
24+
Start-Process msiexec -Wait \
25+
-ArgumentList @( \
26+
'/i', \
27+
'mongo.msi', \
28+
'/quiet', \
29+
'/qn', \
30+
'INSTALLLOCATION=C:\mongodb', \
31+
'ADDLOCAL=all' \
32+
); \
33+
\
34+
Write-Host 'Verifying install ...'; \
35+
Write-Host ' mongo --version'; mongo --version; \
36+
Write-Host ' mongod --version'; mongod --version; \
37+
\
38+
Write-Host 'Removing ...'; \
39+
Remove-Item mongo.msi -Force; \
40+
\
41+
Write-Host 'Complete.';
42+
43+
VOLUME C:\\data\\db C:\\data\\configdb
44+
45+
# TODO docker-entrypoint.ps1 ? (for "docker run <image> --flag --flag --flag")
46+
47+
EXPOSE 27017
48+
CMD ["mongod"]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM microsoft/windowsservercore
2+
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
4+
5+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
6+
RUN [Environment]::SetEnvironmentVariable('PATH', 'C:\mongodb\bin;' + $env:PATH, [EnvironmentVariableTarget]::Machine);
7+
# doing this first to share cache across versions more aggressively
8+
9+
ENV MONGO_VERSION 3.2.9
10+
ENV MONGO_DOWNLOAD_URL http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-${MONGO_VERSION}-signed.msi
11+
ENV MONGO_DOWNLOAD_SHA256 348db5060e5c821acbd170331e806ea0233626837e6ea30e7d0e8dc72cc2e41f
12+
13+
RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
14+
(New-Object System.Net.WebClient).DownloadFile($env:MONGO_DOWNLOAD_URL, 'mongo.msi'); \
15+
\
16+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256); \
17+
if ((Get-FileHash mongo.msi -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { \
18+
Write-Host 'FAILED!'; \
19+
exit 1; \
20+
}; \
21+
\
22+
Write-Host 'Installing ...'; \
23+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#install-mongodb-community-edition
24+
Start-Process msiexec -Wait \
25+
-ArgumentList @( \
26+
'/i', \
27+
'mongo.msi', \
28+
'/quiet', \
29+
'/qn', \
30+
'INSTALLLOCATION=C:\mongodb', \
31+
'ADDLOCAL=all' \
32+
); \
33+
\
34+
Write-Host 'Verifying install ...'; \
35+
Write-Host ' mongo --version'; mongo --version; \
36+
Write-Host ' mongod --version'; mongod --version; \
37+
\
38+
Write-Host 'Removing ...'; \
39+
Remove-Item mongo.msi -Force; \
40+
\
41+
Write-Host 'Complete.';
42+
43+
VOLUME C:\\data\\db C:\\data\\configdb
44+
45+
# TODO docker-entrypoint.ps1 ? (for "docker run <image> --flag --flag --flag")
46+
47+
EXPOSE 27017
48+
CMD ["mongod"]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM microsoft/windowsservercore
2+
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
4+
5+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
6+
RUN [Environment]::SetEnvironmentVariable('PATH', 'C:\mongodb\bin;' + $env:PATH, [EnvironmentVariableTarget]::Machine);
7+
# doing this first to share cache across versions more aggressively
8+
9+
ENV MONGO_VERSION 3.3.11
10+
ENV MONGO_DOWNLOAD_URL http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-${MONGO_VERSION}-signed.msi
11+
ENV MONGO_DOWNLOAD_SHA256 cea09e54b6540bfd4f6c55a058f81d96a543557eb023289cad36d577424bd079
12+
13+
RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
14+
(New-Object System.Net.WebClient).DownloadFile($env:MONGO_DOWNLOAD_URL, 'mongo.msi'); \
15+
\
16+
Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256); \
17+
if ((Get-FileHash mongo.msi -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { \
18+
Write-Host 'FAILED!'; \
19+
exit 1; \
20+
}; \
21+
\
22+
Write-Host 'Installing ...'; \
23+
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#install-mongodb-community-edition
24+
Start-Process msiexec -Wait \
25+
-ArgumentList @( \
26+
'/i', \
27+
'mongo.msi', \
28+
'/quiet', \
29+
'/qn', \
30+
'INSTALLLOCATION=C:\mongodb', \
31+
'ADDLOCAL=all' \
32+
); \
33+
\
34+
Write-Host 'Verifying install ...'; \
35+
Write-Host ' mongo --version'; mongo --version; \
36+
Write-Host ' mongod --version'; mongod --version; \
37+
\
38+
Write-Host 'Removing ...'; \
39+
Remove-Item mongo.msi -Force; \
40+
\
41+
Write-Host 'Complete.';
42+
43+
VOLUME C:\\data\\db C:\\data\\configdb
44+
45+
# TODO docker-entrypoint.ps1 ? (for "docker run <image> --flag --flag --flag")
46+
47+
EXPOSE 27017
48+
CMD ["mongod"]

generate-stackbrew-library.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,26 @@ for version in "${versions[@]}"; do
7070
GitCommit: $commit
7171
Directory: $version
7272
EOE
73+
74+
for v in \
75+
windows/windowsservercore windows/nanoserver \
76+
; do
77+
dir="$version/$v"
78+
variant="$(basename "$v")"
79+
80+
[ -f "$dir/Dockerfile" ] || continue
81+
82+
commit="$(dirCommit "$dir")"
83+
84+
variantAliases=( "${versionAliases[@]/%/-$variant}" )
85+
variantAliases=( "${variantAliases[@]//latest-/}" )
86+
87+
echo
88+
cat <<-EOE
89+
Tags: $(join ', ' "${variantAliases[@]}")
90+
GitCommit: $commit
91+
Directory: $dir
92+
EOE
93+
[ "$variant" = "$v" ] || echo "Constraints: $variant"
94+
done
7395
done

update.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ travisEnv=
1616
for version in "${versions[@]}"; do
1717
rcVersion="${version%-rc}"
1818
major="$rcVersion"
19+
rcGrepV='-v'
1920
if [ "$rcVersion" != "$version" ]; then
21+
rcGrepV=
2022
major='testing'
2123
fi
2224

@@ -46,6 +48,29 @@ for version in "${versions[@]}"; do
4648
"$version/Dockerfile"
4749
)
4850

51+
if [ -d "$version/windows" ]; then
52+
windowsUrlPrefix='http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-'
53+
windowsUrlSuffix='-signed.msi'
54+
windowsVersions="$(
55+
curl -fsSL 'https://www.mongodb.org/dl/win32/x86_64-2008plus-ssl' \
56+
| grep --extended-regexp --only-matching '"'"${windowsUrlPrefix}${rcVersion//./\\.}"'\.[^"]+'"${windowsUrlSuffix}"'"' \
57+
| sed \
58+
-e 's!^"'"$windowsUrlPrefix"'!!' \
59+
-e 's!'"$windowsUrlSuffix"'"$!!' \
60+
| grep $rcGrepV -- '-rc'
61+
)"
62+
windowsLatest="$(echo "$windowsVersions" | head -1)"
63+
windowsSha256="$(curl -fsSL "${windowsUrlPrefix}${windowsLatest}${windowsUrlSuffix}.sha256" | cut -d' ' -f1)"
64+
65+
(
66+
set -x
67+
sed -ri \
68+
-e 's/^(ENV MONGO_VERSION) .*/\1 '"$windowsLatest"'/' \
69+
-e 's/^(ENV MONGO_DOWNLOAD_SHA256) .*/\1 '"$windowsSha256"'/' \
70+
"$version/windows/"*"/Dockerfile"
71+
)
72+
fi
73+
4974
travisEnv='\n - VERSION='"$version$travisEnv"
5075
done
5176

0 commit comments

Comments
 (0)