|
...
|
...
|
@@ -1,87 +1,162 @@
|
|
1
|
|
-# This file describes the standard way to build Docker, using a docker container on Windows
|
|
2
|
|
-# Server 2016
|
|
|
1
|
+# escape=`
|
|
|
2
|
+
|
|
|
3
|
+# -----------------------------------------------------------------------------------------
|
|
|
4
|
+# This file describes the standard way to build Docker in a container on Windows
|
|
|
5
|
+# Server 2016 or Windows 10.
|
|
|
6
|
+#
|
|
|
7
|
+# Maintainer: @jhowardmsft
|
|
|
8
|
+# -----------------------------------------------------------------------------------------
|
|
|
9
|
+
|
|
|
10
|
+
|
|
|
11
|
+# Prerequisites:
|
|
|
12
|
+# --------------
|
|
|
13
|
+#
|
|
|
14
|
+# 1. Windows 10 or Windows Server 2016 with all Windows updates applied. Pre-release
|
|
|
15
|
+# versions of Windows are not supported (eg Windows Server 2016 TP5). The build
|
|
|
16
|
+# number must be at least 14393. This can be confirmed, for example, by running
|
|
|
17
|
+# the following from an elevated PowerShell prompt - this sample output is from a
|
|
|
18
|
+# fully up to date machine as at late October 2016:
|
|
3
|
19
|
#
|
|
|
20
|
+# >> PS C:\> $(gin).WindowsBuildLabEx
|
|
|
21
|
+# >> 14393.321.amd64fre.rs1_release_inmarket.161004-2338
|
|
|
22
|
+#
|
|
|
23
|
+# 2. Git for Windows (or another git client) must be installed. https://git-scm.com/download/win.
|
|
|
24
|
+#
|
|
|
25
|
+# 3. The machine must be configured to run containers. For example, by following
|
|
|
26
|
+# the quick start guidance at https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start or
|
|
|
27
|
+# https://github.com/docker/labs/blob/master/windows/windows-containers/Setup.md
|
|
|
28
|
+
|
|
|
29
|
+
|
|
|
30
|
+# -----------------------------------------------------------------------------------------
|
|
|
31
|
+
|
|
|
32
|
+
|
|
4
|
33
|
# Usage:
|
|
|
34
|
+# -----
|
|
|
35
|
+#
|
|
|
36
|
+# The following steps should be run from an (elevated*) Windows PowerShell prompt.
|
|
|
37
|
+#
|
|
|
38
|
+# (*In a default installation of containers on Windows following the quick-start guidance at
|
|
|
39
|
+# https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start,
|
|
|
40
|
+# the docker.exe client must run elevated to be able to connect to the daemon).
|
|
|
41
|
+#
|
|
|
42
|
+# 1. Clone the sources from github.com:
|
|
|
43
|
+#
|
|
|
44
|
+# >> git clone https://github.com/docker/docker.git c:\go\src\github.com\docker\docker
|
|
|
45
|
+# >> Cloning into 'c:\go\src\github.com\docker\docker'...
|
|
|
46
|
+# >> remote: Counting objects: 186216, done.
|
|
|
47
|
+# >> remote: Compressing objects: 100% (21/21), done.
|
|
|
48
|
+# >> remote: Total 186216 (delta 5), reused 0 (delta 0), pack-reused 186195
|
|
|
49
|
+# >> Receiving objects: 100% (186216/186216), 104.32 MiB | 8.18 MiB/s, done.
|
|
|
50
|
+# >> Resolving deltas: 100% (123139/123139), done.
|
|
|
51
|
+# >> Checking connectivity... done.
|
|
|
52
|
+# >> Checking out files: 100% (3912/3912), done.
|
|
|
53
|
+# >> PS C:\>
|
|
|
54
|
+#
|
|
|
55
|
+#
|
|
|
56
|
+# 2. Change directory to the cloned docker sources:
|
|
5
|
57
|
#
|
|
6
|
|
-# # Assemble the full dev environment. This is slow the first time. Run this from
|
|
7
|
|
-# # a directory containing the sources you are validating. For example from
|
|
8
|
|
-# # c:\go\src\github.com\docker\docker
|
|
|
58
|
+# >> cd c:\go\src\github.com\docker\docker
|
|
9
|
59
|
#
|
|
10
|
|
-# docker build -t docker -f Dockerfile.windows .
|
|
11
|
60
|
#
|
|
|
61
|
+# 3. Build a docker image with the components required to build the docker binaries from source:
|
|
12
|
62
|
#
|
|
13
|
|
-# # Build docker in a container. Run the following from a Windows cmd command prommpt,
|
|
14
|
|
-# # replacing c:\built with the directory you want the binaries to be placed on the
|
|
15
|
|
-# # host system.
|
|
|
63
|
+# >> docker build -t nativebuildimage -f Dockerfile.windows .
|
|
16
|
64
|
#
|
|
17
|
|
-# docker run --rm -v "c:\built:c:\target" docker sh -c 'cd /c/go/src/github.com/docker/docker; hack/make.sh binary; ec=$?; if [ $ec -eq 0 ]; then robocopy /c/go/src/github.com/docker/docker/bundles/$(cat VERSION)/binary /c/target/binary; fi; exit $ec'
|
|
18
|
65
|
#
|
|
|
66
|
+# 4. Build the docker executable binaries in a container:
|
|
|
67
|
+#
|
|
|
68
|
+# >> docker run --name binaries nativebuildimage sh -c 'cd /c/go/src/github.com/docker/docker; hack/make.sh binary'
|
|
|
69
|
+#
|
|
|
70
|
+#
|
|
|
71
|
+# 5. Copy the binaries out of the above container, replacing HostPath with an appropriate destination
|
|
|
72
|
+# folder on the host system where you want the binaries to be located.
|
|
|
73
|
+#
|
|
|
74
|
+# >> $v=$(Get-Content ".\VERSION" -raw).ToString().Replace("`n","").Trim()
|
|
|
75
|
+# >> docker cp binaries:c:\go\src\github.com\docker\docker\bundles\$v\binary-client\docker-$v.exe c:\HostPath\docker.exe
|
|
|
76
|
+# >> docker cp binaries:c:\go\src\github.com\docker\docker\bundles\$v\binary-daemon\dockerd.exe c:\HostPath\dockerd.exe
|
|
|
77
|
+# >> docker cp binaries:c:\go\src\github.com\docker\docker\bundles\$v\binary-daemon\docker-proxy-$v.exe c:\HostPath\docker-proxy.exe
|
|
|
78
|
+#
|
|
|
79
|
+#
|
|
|
80
|
+# 6. (Optional) Remove the interim container holding the built executable binaries:
|
|
|
81
|
+#
|
|
|
82
|
+# >> docker rm binaries
|
|
|
83
|
+#
|
|
|
84
|
+#
|
|
|
85
|
+# 7. (Optional) Remove the image used for the container in which the executable
|
|
|
86
|
+# binaries are build. Tip - it may be useful to keep this image around if you need to
|
|
|
87
|
+# build multiple times. Then you can take advantage of the builder cache to have an
|
|
|
88
|
+# image which has all the components required to build the binaries already installed.
|
|
|
89
|
+#
|
|
|
90
|
+# >> docker rmi nativebuildimage
|
|
|
91
|
+
|
|
|
92
|
+
|
|
|
93
|
+# -----------------------------------------------------------------------------------------
|
|
|
94
|
+
|
|
|
95
|
+
|
|
19
|
96
|
# Important notes:
|
|
20
|
97
|
# ---------------
|
|
21
|
98
|
#
|
|
22
|
|
-# The posix utilities from GIT aren't usable interactively as at January 2016. This
|
|
|
99
|
+# The posix utilities from git aren't usable interactively as at October 2016. This
|
|
23
|
100
|
# is because they require a console window which isn't present in a container in Windows.
|
|
24
|
|
-# See the example at the top of this file. Do NOT use -it in that docker run!!!
|
|
|
101
|
+# See the example at the top of this file. Do NOT use -it in that docker run. It will not work.
|
|
25
|
102
|
#
|
|
26
|
|
-# Don't try to use a volume for passing the source through. The posix utilities will
|
|
27
|
|
-# balk at reparse points. Again, see the example at the top of this file on how use a volume
|
|
28
|
|
-# to get the built binary out of the container.
|
|
|
103
|
+# Don't attempt to use a volume for passing the source through to the container. The posix utilities will
|
|
|
104
|
+# balk at reparse points.
|
|
29
|
105
|
#
|
|
30
|
|
-# The steps are minimised dramatically to improve performance
|
|
|
106
|
+# The downloaded files are not cleared from the image. go.zip is used by the Windows
|
|
|
107
|
+# CI servers to ensure the host and image are running consistent versions of go.
|
|
|
108
|
+#
|
|
|
109
|
+
|
|
|
110
|
+# -----------------------------------------------------------------------------------------
|
|
31
|
111
|
|
|
32
|
|
-FROM windowsservercore
|
|
|
112
|
+# The number of build steps below are explicitly minimised to improve performance.
|
|
|
113
|
+FROM microsoft/windowsservercore
|
|
33
|
114
|
|
|
34
|
115
|
# Environment variable notes:
|
|
35
|
116
|
# - GO_VERSION must consistent with 'Dockerfile' used by Linux'.
|
|
36
|
117
|
# - FROM_DOCKERFILE is used for detection of building within a container.
|
|
37
|
|
-ENV GO_VERSION=1.7.3 \
|
|
38
|
|
- GIT_LOCATION=https://github.com/git-for-windows/git/releases/download/v2.7.2.windows.1/Git-2.7.2-64-bit.exe \
|
|
39
|
|
- GOPATH=C:/go;C:/go/src/github.com/docker/docker/vendor \
|
|
|
118
|
+ENV GO_VERSION=1.7.3 `
|
|
|
119
|
+ GIT_LOCATION=https://github.com/git-for-windows/git/releases/download/v2.7.2.windows.1/Git-2.7.2-64-bit.exe `
|
|
|
120
|
+ GOPATH=C:/go;C:/go/src/github.com/docker/docker/vendor `
|
|
40
|
121
|
FROM_DOCKERFILE=1
|
|
41
|
122
|
|
|
42
|
123
|
WORKDIR c:/
|
|
43
|
124
|
|
|
44
|
|
-# Everything downloaded/installed in one go (better performance, esp on TP4)
|
|
45
|
|
-RUN \
|
|
46
|
|
- setx /M Path "c:\git\cmd;c:\git\bin;c:\git\usr\bin;%Path%;c:\gcc\bin;c:\go\bin" && \
|
|
47
|
|
- setx GOROOT "c:\go" && \
|
|
48
|
|
- powershell -command \
|
|
49
|
|
- $ErrorActionPreference = 'Stop'; \
|
|
50
|
|
- Function Download-File([string] $source, [string] $target) { \
|
|
51
|
|
- $wc = New-Object net.webclient; $wc.Downloadfile($source, $target) \
|
|
52
|
|
- } \
|
|
53
|
|
- \
|
|
54
|
|
- Write-Host INFO: Downloading git...; \
|
|
55
|
|
- Download-File %GIT_LOCATION% gitsetup.exe; \
|
|
56
|
|
- \
|
|
57
|
|
- Write-Host INFO: Downloading go...; \
|
|
58
|
|
- Download-File https://storage.googleapis.com/golang/go%GO_VERSION%.windows-amd64.msi go.msi; \
|
|
59
|
|
- \
|
|
60
|
|
- Write-Host INFO: Downloading compiler 1 of 3...; \
|
|
61
|
|
- Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/gcc.zip gcc.zip; \
|
|
62
|
|
- \
|
|
63
|
|
- Write-Host INFO: Downloading compiler 2 of 3...; \
|
|
64
|
|
- Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/runtime.zip runtime.zip; \
|
|
65
|
|
- \
|
|
66
|
|
- Write-Host INFO: Downloading compiler 3 of 3...; \
|
|
67
|
|
- Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/binutils.zip binutils.zip; \
|
|
68
|
|
- \
|
|
69
|
|
- Write-Host INFO: Installing git...; \
|
|
70
|
|
- Start-Process gitsetup.exe -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /CLOSEAPPLICATIONS /DIR=c:\git\' -Wait; \
|
|
71
|
|
- \
|
|
72
|
|
- Write-Host INFO: Installing go..."; \
|
|
73
|
|
- Start-Process msiexec -ArgumentList '-i go.msi -quiet' -Wait; \
|
|
74
|
|
- \
|
|
75
|
|
- Write-Host INFO: Unzipping compiler...; \
|
|
76
|
|
- c:\git\usr\bin\unzip.exe -q -o gcc.zip -d /c/gcc; \
|
|
77
|
|
- c:\git\usr\bin\unzip.exe -q -o runtime.zip -d /c/gcc; \
|
|
78
|
|
- c:\git\usr\bin\unzip.exe -q -o binutils.zip -d /c/gcc"; \
|
|
79
|
|
- \
|
|
80
|
|
- Write-Host INFO: Removing interim files; \
|
|
81
|
|
- Remove-Item *.zip; \
|
|
82
|
|
- Remove-Item go.msi; \
|
|
83
|
|
- Remove-Item gitsetup.exe; \
|
|
84
|
|
- \
|
|
|
125
|
+RUN `
|
|
|
126
|
+ setx /M Path "c:\git\cmd;c:\git\bin;c:\git\usr\bin;%Path%;c:\gcc\bin;c:\go\bin;" && `
|
|
|
127
|
+ setx GOROOT "c:\go" && `
|
|
|
128
|
+ powershell -command `
|
|
|
129
|
+ $ErrorActionPreference = 'Stop'; `
|
|
|
130
|
+ Function Download-File([string] $source, [string] $target) { `
|
|
|
131
|
+ $wc = New-Object net.webclient; $wc.Downloadfile($source, $target) `
|
|
|
132
|
+ } `
|
|
|
133
|
+ `
|
|
|
134
|
+ Write-Host INFO: Downloading git...; `
|
|
|
135
|
+ Download-File %GIT_LOCATION% gitsetup.exe; `
|
|
|
136
|
+ `
|
|
|
137
|
+ Write-Host INFO: Downloading go...; `
|
|
|
138
|
+ Download-File https://golang.org/dl/go%GO_VERSION%.windows-amd64.zip go.zip; `
|
|
|
139
|
+ `
|
|
|
140
|
+ Write-Host INFO: Downloading compiler 1 of 3...; `
|
|
|
141
|
+ Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/gcc.zip gcc.zip; `
|
|
|
142
|
+ `
|
|
|
143
|
+ Write-Host INFO: Downloading compiler 2 of 3...; `
|
|
|
144
|
+ Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/runtime.zip runtime.zip; `
|
|
|
145
|
+ `
|
|
|
146
|
+ Write-Host INFO: Downloading compiler 3 of 3...; `
|
|
|
147
|
+ Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/binutils.zip binutils.zip; `
|
|
|
148
|
+ `
|
|
|
149
|
+ Write-Host INFO: Installing git...; `
|
|
|
150
|
+ Start-Process gitsetup.exe -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /CLOSEAPPLICATIONS /DIR=c:\git\' -Wait; `
|
|
|
151
|
+ `
|
|
|
152
|
+ Write-Host INFO: Expanding go..."; `
|
|
|
153
|
+ Expand-Archive c:\go.zip -DestinationPath c:\; `
|
|
|
154
|
+ `
|
|
|
155
|
+ Write-Host INFO: Expanding compiler...; `
|
|
|
156
|
+ Expand-Archive c:\gcc.zip -DestinationPath c:\gcc -Force; `
|
|
|
157
|
+ Expand-Archive c:\runtime.zip -DestinationPath c:\gcc -Force; `
|
|
|
158
|
+ Expand-Archive c:\binutils.zip -DestinationPath c:\gcc -Force; `
|
|
|
159
|
+ `
|
|
85
|
160
|
Write-Host INFO: Completed
|
|
86
|
161
|
|
|
87
|
162
|
# Prepare for building
|