Skip to content

Commit 0916d53

Browse files
committed
Use gpg signature check and multi-stage build
1 parent 488ac40 commit 0916d53

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

node/7.8/Dockerfile

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,49 @@ FROM microsoft/windowsservercore
22

33
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
44

5-
ENV NPM_CONFIG_LOGLEVEL info
5+
ENV GPG_VERSION 2.3.3
6+
7+
RUN Invoke-WebRequest $('https://files.gpg4win.org/gpg4win-vanilla-{0}.exe' -f $env:GPG_VERSION) -OutFile 'gpg4win.exe' -UseBasicParsing ; \
8+
Start-Process .\gpg4win.exe -ArgumentList '/S' -NoNewWindow -Wait
9+
10+
RUN @( \
11+
'9554F04D7259F04124DE6B476D5A82AC7E37093B', \
12+
'94AE36675C464D64BAFA68DD7434390BDBE9B9C5', \
13+
'FD3A5288F042B6850C66B31F09FE44734EB7990E', \
14+
'71DCFD284A79C3B38668286BC97EC7A07EDE3FC1', \
15+
'DD8F2338BAE7501E3DD5AC78C273792F7D83545D', \
16+
'B9AE9905FFD7803F25714661B63B535A4C206CA9', \
17+
'C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8', \
18+
'56730D5401028683275BD23C23EFEFE93C4CFFFE' \
19+
) | foreach { \
20+
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys $_ ; \
21+
}
22+
623
ENV NODE_VERSION 7.8.0
7-
ENV NODE_SHA256 49eb820e2e8a01c6b9c2f94e019ee4149ce01553a809dc39eebdc83a1fa1792d
24+
25+
RUN Invoke-WebRequest $('https://nodejs.org/dist/v{0}/SHASUMS256.txt.asc' -f $env:NODE_VERSION) -OutFile 'SHASUMS256.txt.asc' -UseBasicParsing ; \
26+
gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc
827

928
RUN Invoke-WebRequest $('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION) -OutFile 'node.zip' -UseBasicParsing ; \
10-
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $env:NODE_SHA256) {exit 1} ; \
29+
$sum = $(cat SHASUMS256.txt.asc | sls $(' node-v{0}-win-x64.zip' -f $env:NODE_VERSION)) -Split ' ' ; \
30+
if ((Get-FileHash node.zip -Algorithm sha256).Hash -ne $sum[0]) { Write-Error 'SHA256 mismatch' } ; \
1131
Expand-Archive node.zip -DestinationPath C:\ ; \
1232
Rename-Item -Path $('C:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs' ; \
1333
New-Item $($env:APPDATA + '\npm') ; \
1434
$env:PATH = 'C:\nodejs;{0}\npm;{1}' -f $env:APPDATA, $env:PATH ; \
1535
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine) ; \
1636
Remove-Item -Path node.zip
1737

38+
FROM microsoft/windowsservercore
39+
40+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
41+
42+
ENV NPM_CONFIG_LOGLEVEL info
43+
44+
COPY --from=0 /nodejs /nodejs
45+
46+
RUN New-Item $($env:APPDATA + '\npm') ; \
47+
$env:PATH = 'C:\nodejs;{0}\npm;{1}' -f $env:APPDATA, $env:PATH ; \
48+
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine) ; \
49+
1850
CMD [ "node.exe" ]

node/build.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Write-Host Updating Docker engine to master for PR docker/docker#31257
2+
Stop-Service docker
3+
$wc = New-Object net.webclient
4+
$wc.Downloadfile("https://master.dockerproject.org/windows/amd64/dockerd.exe", "$env:ProgramFiles\docker\dockerd.exe")
5+
$wc.Downloadfile("https://master.dockerproject.org/windows/amd64/docker.exe", "$env:ProgramFiles\docker\docker.exe")
6+
Start-Service docker
7+
docker version
8+
19
function buildVersion($majorMinorPatch, $majorMinor, $major) {
210
docker build -t node:$majorMinorPatch $majorMinor
311
docker tag node:$majorMinorPatch node:latest

0 commit comments

Comments
 (0)