From ebdf10abdfe46e19b9c0fd419ec3dad31f20ffa8 Mon Sep 17 00:00:00 2001 From: Stefan Scherer Date: Thu, 25 Aug 2016 18:08:03 +0200 Subject: [PATCH] Introduce Dockerfiles for nanoserver Signed-off-by: Stefan Scherer --- 4.5/windows/nanoserver/Dockerfile | 27 +++++++++++++++++++++++ 4.5/windows/nanoserver/onbuild/Dockerfile | 10 +++++++++ 6.4/windows/nanoserver/Dockerfile | 27 +++++++++++++++++++++++ 6.4/windows/nanoserver/onbuild/Dockerfile | 10 +++++++++ test-build.ps1 | 5 +++++ 5 files changed, 79 insertions(+) create mode 100644 4.5/windows/nanoserver/Dockerfile create mode 100644 4.5/windows/nanoserver/onbuild/Dockerfile create mode 100644 6.4/windows/nanoserver/Dockerfile create mode 100644 6.4/windows/nanoserver/onbuild/Dockerfile create mode 100755 test-build.ps1 diff --git a/4.5/windows/nanoserver/Dockerfile b/4.5/windows/nanoserver/Dockerfile new file mode 100644 index 0000000000..a76fad0931 --- /dev/null +++ b/4.5/windows/nanoserver/Dockerfile @@ -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" ] diff --git a/4.5/windows/nanoserver/onbuild/Dockerfile b/4.5/windows/nanoserver/onbuild/Dockerfile new file mode 100644 index 0000000000..88adbc4065 --- /dev/null +++ b/4.5/windows/nanoserver/onbuild/Dockerfile @@ -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" ] diff --git a/6.4/windows/nanoserver/Dockerfile b/6.4/windows/nanoserver/Dockerfile new file mode 100644 index 0000000000..d4de2047ce --- /dev/null +++ b/6.4/windows/nanoserver/Dockerfile @@ -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" ] diff --git a/6.4/windows/nanoserver/onbuild/Dockerfile b/6.4/windows/nanoserver/onbuild/Dockerfile new file mode 100644 index 0000000000..325f31b070 --- /dev/null +++ b/6.4/windows/nanoserver/onbuild/Dockerfile @@ -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" ] diff --git a/test-build.ps1 b/test-build.ps1 new file mode 100755 index 0000000000..e890b912d8 --- /dev/null +++ b/test-build.ps1 @@ -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