Skip to content

Commit

Permalink
Introduce Dockerfiles for nanoserver
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Scherer <[email protected]>
  • Loading branch information
StefanScherer committed Aug 25, 2016
1 parent 73b0a6e commit ebdf10a
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 4.5/windows/nanoserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM microsoft/nanoserver

ENV NPM_CONFIG_LOGLEVEL info
ENV NODE_VERSION 4.5.0
ENV NODE_SHA256 16aab15b29e79746d1bae708f6a5dbed8ef3c87426a9408f7261163d0cda0f56

RUN powershell.exe -Command \
$ErrorActionPreference = 'Stop' ; \
$handler = New-Object System.Net.Http.HttpClientHandler ; \
$client = New-Object System.Net.Http.HttpClient($handler) ; \
$client.Timeout = New-Object System.TimeSpan(0, 30, 0) ; \
$cancelTokenSource = [System.Threading.CancellationTokenSource]::new() ; \
$responseMsg = $client.GetAsync([System.Uri]::new('https://nodejs.org/dist/v%NODE_VERSION%/node-v%NODE_VERSION%-win-x64.zip'), $cancelTokenSource.Token) ; \
$responseMsg.Wait() ; \
$downloadedFileStream = [System.IO.FileStream]::new('C:\node.zip', [System.IO.FileMode]::Create, [System.IO.FileAccess]::Write) ; \
$response = $responseMsg.Result ; \
$copyStreamOp = $response.Content.CopyToAsync($downloadedFileStream) ; \
$copyStreamOp.Wait() ; \
$downloadedFileStream.Close() ; \
[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\node.zip','c:\') ; \
Rename-Item 'C:\node-v%NODE_VERSION%-win-x64' 'C:\nodejs' ; \
New-Item '%APPDATA%\npm' ; \
$env:PATH = 'C:\nodejs;%APPDATA%\npm;' + $env:PATH ; \
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH ; \
Remove-Item -Path node.zip

CMD [ "node.exe" ]
10 changes: 10 additions & 0 deletions 4.5/windows/nanoserver/onbuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:4.5.0-nanoserver

RUN mkdir \app
WORKDIR /app

ONBUILD COPY package.json package.json
ONBUILD RUN npm install & rd /s /q %APPDATA%\npm-cache & for /d %G in ("%TEMP%\npm-*") do rd /s /q "%~G"
ONBUILD COPY . .

CMD [ "npm.cmd", "start" ]
27 changes: 27 additions & 0 deletions 6.4/windows/nanoserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM microsoft/nanoserver

ENV NPM_CONFIG_LOGLEVEL info
ENV NODE_VERSION 6.4.0
ENV NODE_SHA256 bb994370e43c1539e11588a86e69064459141b6984b705f1c79a1a13181193b9

RUN powershell.exe -Command \
$ErrorActionPreference = 'Stop' ; \
$handler = New-Object System.Net.Http.HttpClientHandler ; \
$client = New-Object System.Net.Http.HttpClient($handler) ; \
$client.Timeout = New-Object System.TimeSpan(0, 30, 0) ; \
$cancelTokenSource = [System.Threading.CancellationTokenSource]::new() ; \
$responseMsg = $client.GetAsync([System.Uri]::new('https://nodejs.org/dist/v%NODE_VERSION%/node-v%NODE_VERSION%-win-x64.zip'), $cancelTokenSource.Token) ; \
$responseMsg.Wait() ; \
$downloadedFileStream = [System.IO.FileStream]::new('C:\node.zip', [System.IO.FileMode]::Create, [System.IO.FileAccess]::Write) ; \
$response = $responseMsg.Result ; \
$copyStreamOp = $response.Content.CopyToAsync($downloadedFileStream) ; \
$copyStreamOp.Wait() ; \
$downloadedFileStream.Close() ; \
[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\node.zip','c:\') ; \
Rename-Item 'C:\node-v%NODE_VERSION%-win-x64' 'C:\nodejs' ; \
New-Item '%APPDATA%\npm' ; \
$env:PATH = 'C:\nodejs;%APPDATA%\npm;' + $env:PATH ; \
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH ; \
Remove-Item -Path node.zip

CMD [ "node.exe" ]
10 changes: 10 additions & 0 deletions 6.4/windows/nanoserver/onbuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:6.4.0-nanoserver

RUN mkdir \app
WORKDIR /app

ONBUILD COPY package.json package.json
ONBUILD RUN npm install & rd /s /q %APPDATA%\npm-cache & for /d %G in ("%TEMP%\npm-*") do rd /s /q "%~G"
ONBUILD COPY . .

CMD [ "npm.cmd", "start" ]
5 changes: 5 additions & 0 deletions test-build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
docker build --isolation=hyperv -t node:4.5.0-nanoserver 4.5/windows/nanoserver
docker build --isolation=hyperv -t node:4.5.0-nanoserver-onbuild 4.5/windows/nanoserver/onbuild

docker build --isolation=hyperv -t node:6.4.0-nanoserver 6.4/windows/nanoserver
docker build --isolation=hyperv -t node:6.4.0-nanoserver-onbuild 6.4/windows/nanoserver/onbuild

0 comments on commit ebdf10a

Please sign in to comment.