forked from Azure-Samples/nodejs-docs-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile安装软件示例
62 lines (42 loc) · 2.15 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
如何构建Node.js Nano Server Docker基础映像
参考文章:https://stefanscherer.github.io/how-to-build-nodejs-nanoserver-image/
nanoserver 不支持安装msi文件,所以通过上面一篇文章可以查看间接安装方法
nanoserver不支持windows的任何安装,只支持zip等压缩包解压配置环境变量形式的安装
FROM microsoft/windowsservercore
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV chocolateyUseWindowsCompression false
RUN iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'));
RUN choco install -y nodejs -version 7.3.0
RUN choco install -y git -params "/GitAndUnixToolsOnPath"
RUN npm install --global --production windows-build-tools
RUN git clone https://github.com/nodejs/node.git
RUN cd node ; git pull ; \
$env:PATH += ';C:\Users\ContainerAdministrator\.windows-build-tools\python27' ; \
.\vcbuild.bat test nosign
//
windows-build-tools的作用是在window上面安装常见的编译工具,如python、Visual C++ Compilers tools等
npm install --global windows-build-tools
参考手册如下
https://www.npmjs.com/package/windows-build-tools
//================================================
FROM microsoft/nanoserver
ARG NODE_VERSION=4.6.1
RUN powershell -Command \
Invoke-WebRequest https://nodejs.org/dist/v$env:NODE_VERSION/win-x64/node.exe \
-OutFile node.exe -UseBasicParsing
CMD [ "node.exe" ]
# 如上,用--build-arg NODE_VERSION可以将参数传递到Dockerfile中覆盖ARG NODE_VERSION的默认值
docker build -t nodeexe:4.6.1 --build-arg NODE_VERSION=4.6.1 .
//================================================
powershell的if elseif 等流程控制语句
If
Conditionally perform a command.
Syntax
if ( condition ) { commands_to_execute }
[ elseif ( condition2 ) { commands_to_execute } ]
[ else {commands_to_execute} ]
Key
Condition An expression that will evaluate to true or false,
often utilising one or more comparison operators.
commands_to_execute
A PowerShell or external command to run if the condition is true.