Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -1,57 +1,93 @@ |
| 1 |
-# This file describes the standard way to build Docker, using docker on TP4 |
|
| 1 |
+# This file describes the standard way to build Docker, using a docker container on Windows |
|
| 2 |
+# Server 2016 |
|
| 2 | 3 |
# |
| 3 | 4 |
# Usage: |
| 4 | 5 |
# |
| 5 |
-# # Assemble the full dev environment. This is slow the first time. |
|
| 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 |
|
| 9 |
+# |
|
| 6 | 10 |
# docker build -t docker -f Dockerfile.windows . |
| 7 | 11 |
# |
| 8 |
-# # Mount your source in an interactive container for quick testing: |
|
| 9 |
-# docker run -it -v ${pwd}\bundles:c:/go/src/github.com/docker/docker/bundles docker cmd
|
|
| 10 | 12 |
# |
| 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. |
|
| 16 |
+# |
|
| 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 |
+# |
|
| 19 |
+# Important notes: |
|
| 20 |
+# --------------- |
|
| 21 |
+# |
|
| 22 |
+# Multiple commands in a single powershell RUN command are deliberately not done. This is |
|
| 23 |
+# because PS doesn't have a concept quite like set -e in bash. It would be possible to use |
|
| 24 |
+# try-catch script blocks, but that would make this file unreadable. The problem is that |
|
| 25 |
+# if there are two commands eg "RUN powershell -command fail; succeed", as far as docker |
|
| 26 |
+# would be concerned, the return code from the overall RUN is succeed. This doesn't apply to |
|
| 27 |
+# RUN which uses cmd as the command interpreter such as "RUN fail; succeed". |
|
| 28 |
+# |
|
| 29 |
+# 'sleep 5' is a deliberate workaround for a current problem on containers in Windows |
|
| 30 |
+# Server 2016. It ensures that the network is up and available for when the command is |
|
| 31 |
+# network related. This bug is being tracked internally at Microsoft and exists in TP4. |
|
| 32 |
+# Generally sleep 1 or 2 is probably enough, but making it 5 to make the build file |
|
| 33 |
+# as bullet proof as possible. This isn't a big deal as this only runs the first time. |
|
| 34 |
+# |
|
| 35 |
+# The cygwin posix utilities from GIT aren't usable interactively as at January 2016. This |
|
| 36 |
+# is because they require a console window which isn't present in a container in Windows. |
|
| 37 |
+# See the example at the top of this file. Do NOT use -it in that docker run!!! |
|
| 38 |
+# |
|
| 39 |
+# Don't try to use a volume for passing the source through. The cygwin posix utilities will |
|
| 40 |
+# balk at reparse points. Again, see the example at the top of this file on how use a volume |
|
| 41 |
+# to get the built binary out of the container. |
|
| 11 | 42 |
|
| 12 | 43 |
FROM windowsservercore |
| 13 | 44 |
|
| 14 |
-ENV GO_VERSION=1.5.3 \ |
|
| 45 |
+# Environment variable notes: |
|
| 46 |
+# - GOLANG_VERSION should be updated to be consistent with the Linux dockerfile. |
|
| 47 |
+# - FROM_DOCKERFILE is used for detection of building within a container. |
|
| 48 |
+ENV GOLANG_VERSION=1.5.3 \ |
|
| 15 | 49 |
GIT_VERSION=2.7.0 \ |
| 16 |
- RSRC_COMMIT=e48dbf1b7fc464a9e85fcec450dddf80816b76e0 \ |
|
| 50 |
+ RSRC_COMMIT=ba14da1f827188454a4591717fff29999010887f \ |
|
| 17 | 51 |
GOPATH=C:/go;C:/go/src/github.com/docker/docker/vendor \ |
| 18 | 52 |
FROM_DOCKERFILE=1 |
| 19 | 53 |
|
| 54 |
+# Make sure we're in temp for the downloads |
|
| 20 | 55 |
WORKDIR c:/windows/temp |
| 21 | 56 |
|
| 22 |
-RUN powershell -command \ |
|
| 23 |
- sleep 2 ; \ |
|
| 24 |
- iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
|
|
| 25 |
- |
|
| 26 |
-RUN powershell -command \ |
|
| 27 |
- sleep 2 ; \ |
|
| 28 |
- choco install curl -y -v ; \ |
|
| 29 |
- choco install git -y -v --version=%GIT_VERSION% -params '"/GitAndUnixToolsOnPath"' |
|
| 30 |
- |
|
| 31 |
-RUN setx /M Path "c:\ProgramData\chocolatey\bin;c:\Program Files\Git\usr\bin;%Path%;c:\gcc\bin" |
|
| 57 |
+# Download everything else we need to install |
|
| 58 |
+# We want a 64-bit make.exe, not 16 or 32-bit. This was hard to find, so documenting the links |
|
| 59 |
+# - http://sourceforge.net/p/mingw-w64/wiki2/Make/ --> |
|
| 60 |
+# - http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/ --> |
|
| 61 |
+# - http://sourceforge.net/projects/mingw-w64/files/External binary packages %28Win64 hosted%29/make/ |
|
| 62 |
+RUN powershell -command sleep 5; Invoke-WebRequest -UserAgent 'DockerCI' -outfile make.zip http://downloads.sourceforge.net/project/mingw-w64/External%20binary%20packages%20%28Win64%20hosted%29/make/make-3.82.90-20111115.zip |
|
| 63 |
+RUN powershell -command sleep 5; Invoke-WebRequest -UserAgent 'DockerCI' -outfile gcc.zip http://downloads.sourceforge.net/project/tdm-gcc/TDM-GCC%205%20series/5.1.0-tdm64-1/gcc-5.1.0-tdm64-1-core.zip |
|
| 64 |
+RUN powershell -command sleep 5; Invoke-WebRequest -UserAgent 'DockerCI' -outfile runtime.zip http://downloads.sourceforge.net/project/tdm-gcc/MinGW-w64%20runtime/GCC%205%20series/mingw64runtime-v4-git20150618-gcc5-tdm64-1.zip |
|
| 65 |
+RUN powershell -command sleep 5; Invoke-WebRequest -UserAgent 'DockerCI' -outfile binutils.zip http://downloads.sourceforge.net/project/tdm-gcc/GNU%20binutils/binutils-2.25-tdm64-1.zip |
|
| 66 |
+RUN powershell -command sleep 5; Invoke-WebRequest -UserAgent 'DockerCI' -outfile 7zsetup.exe http://www.7-zip.org/a/7z1514-x64.exe |
|
| 67 |
+RUN powershell -command sleep 5; Invoke-WebRequest -UserAgent 'DockerCI' -outfile lzma.7z http://www.7-zip.org/a/lzma1514.7z |
|
| 68 |
+RUN powershell -command sleep 5; Invoke-WebRequest -UserAgent 'DockerCI' -outfile gitsetup.exe https://github.com/git-for-windows/git/releases/download/v%GIT_VERSION%.windows.1/Git-%GIT_VERSION%-64-bit.exe |
|
| 69 |
+RUN powershell -command sleep 5; Invoke-WebRequest -UserAgent 'DockerCI' -outfile go.msi https://storage.googleapis.com/golang/go%GOLANG_VERSION%.windows-amd64.msi |
|
| 32 | 70 |
|
| 33 |
-RUN powershell -command \ |
|
| 34 |
- sleep 2; \ |
|
| 35 |
- curl.exe -L -k -o go.msi https://storage.googleapis.com/golang/go%GO_VERSION%.windows-amd64.msi; \ |
|
| 36 |
- curl.exe -L -k -o gcc.zip http://downloads.sourceforge.net/project/tdm-gcc/TDM-GCC%205%20series/5.1.0-tdm64-1/gcc-5.1.0-tdm64-1-core.zip ; \ |
|
| 37 |
- curl.exe -L -k -o runtime.zip http://downloads.sourceforge.net/project/tdm-gcc/MinGW-w64%20runtime/GCC%205%20series/mingw64runtime-v4-git20150618-gcc5-tdm64-1.zip ; \ |
|
| 38 |
- curl.exe -L -k -o binutils.zip http://downloads.sourceforge.net/project/tdm-gcc/GNU%20binutils/binutils-2.25-tdm64-1.zip |
|
| 71 |
+# Path |
|
| 72 |
+RUN setx /M Path "c:\git\cmd;c:\git\bin;c:\git\usr\bin;%Path%;c:\gcc\bin;c:\7zip" |
|
| 39 | 73 |
|
| 40 |
-RUN powershell -command \ |
|
| 41 |
- .\go.msi /quiet ; \ |
|
| 42 |
- Expand-Archive gcc.zip \gcc -Force ; \ |
|
| 43 |
- Expand-Archive runtime.zip \gcc -Force ; \ |
|
| 44 |
- Expand-Archive binutils.zip \gcc -Force |
|
| 74 |
+# Install and expand the bits we downloaded. |
|
| 75 |
+# Note: The git, 7z and go.msi installers execute asynchronously. |
|
| 76 |
+RUN powershell -command start-process .\gitsetup.exe -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /CLOSEAPPLICATIONS /DIR=c:\git' -Wait |
|
| 77 |
+RUN powershell -command start-process .\7zsetup -ArgumentList '/S /D=c:/7zip' -Wait |
|
| 78 |
+RUN powershell -command start-process .\go.msi -ArgumentList '/quiet' -Wait |
|
| 79 |
+RUN powershell -command Expand-Archive gcc.zip \gcc -Force |
|
| 80 |
+RUN powershell -command Expand-Archive runtime.zip \gcc -Force |
|
| 81 |
+RUN powershell -command Expand-Archive binutils.zip \gcc -Force |
|
| 82 |
+RUN powershell -command 7z e lzma.7z bin/lzma.exe |
|
| 83 |
+RUN powershell -command 7z x make.zip make-3.82.90-20111115/bin_amd64/make.exe |
|
| 84 |
+RUN powershell -command mv make-3.82.90-20111115/bin_amd64/make.exe /gcc/bin/ |
|
| 45 | 85 |
|
| 46 |
-RUN del go.msi gcc.zip runtime.zip binutils.zip |
|
| 47 |
- |
|
| 48 |
-RUN powershell -Command \ |
|
| 49 |
- sleep 2 ; \ |
|
| 50 |
- git clone https://github.com/akavel/rsrc.git c:\go\src\github.com\akavel\rsrc ; \ |
|
| 51 |
- cd \go\src\github.com\akavel\rsrc ; \ |
|
| 52 |
- git checkout -q $env:RSRC_COMMIT ; \ |
|
| 53 |
- go install -v |
|
| 54 |
- |
|
| 55 |
-WORKDIR c:/go/src/github.com/docker/docker |
|
| 86 |
+# RSRC for manifest and icon |
|
| 87 |
+RUN powershell -command sleep 5 ; git clone https://github.com/akavel/rsrc.git c:\go\src\github.com\akavel\rsrc |
|
| 88 |
+RUN cd c:/go/src/github.com/akavel/rsrc && git checkout -q %RSRC_COMMIT% && go install -v |
|
| 56 | 89 |
|
| 90 |
+# Prepare for building |
|
| 91 |
+WORKDIR c:/ |
|
| 57 | 92 |
COPY . /go/src/github.com/docker/docker |
| 93 |
+ |