2016-10-20 20:02:26 -04:00
|
|
|
# escape=`
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------------------
|
|
|
|
# This file describes the standard way to build Docker in a container on Windows
|
2016-11-10 15:45:56 -05:00
|
|
|
# Server 2016.
|
2016-10-20 20:02:26 -04:00
|
|
|
#
|
|
|
|
# Maintainer: @jhowardmsft
|
|
|
|
# -----------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
# Prerequisites:
|
|
|
|
# --------------
|
|
|
|
#
|
2016-11-10 15:45:56 -05:00
|
|
|
# 1. Windows Server 2016 with all Windows updates applied. Pre-release versions
|
|
|
|
# of Windows are not supported (eg Windows Server 2016 TP5). The build number
|
|
|
|
# must be at least 14393. This can be confirmed, for example, by running the
|
|
|
|
# following from an elevated PowerShell prompt - this sample output is from a
|
2016-10-20 20:02:26 -04:00
|
|
|
# fully up to date machine as at late October 2016:
|
2015-12-01 03:47:19 -05:00
|
|
|
#
|
2016-10-20 20:02:26 -04:00
|
|
|
# >> PS C:\> $(gin).WindowsBuildLabEx
|
|
|
|
# >> 14393.321.amd64fre.rs1_release_inmarket.161004-2338
|
|
|
|
#
|
|
|
|
# 2. Git for Windows (or another git client) must be installed. https://git-scm.com/download/win.
|
|
|
|
#
|
|
|
|
# 3. The machine must be configured to run containers. For example, by following
|
|
|
|
# the quick start guidance at https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start or
|
|
|
|
# https://github.com/docker/labs/blob/master/windows/windows-containers/Setup.md
|
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2015-12-01 03:47:19 -05:00
|
|
|
# Usage:
|
2016-10-20 20:02:26 -04:00
|
|
|
# -----
|
|
|
|
#
|
|
|
|
# The following steps should be run from an (elevated*) Windows PowerShell prompt.
|
|
|
|
#
|
|
|
|
# (*In a default installation of containers on Windows following the quick-start guidance at
|
|
|
|
# https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start,
|
|
|
|
# the docker.exe client must run elevated to be able to connect to the daemon).
|
|
|
|
#
|
|
|
|
# 1. Clone the sources from github.com:
|
|
|
|
#
|
2016-10-30 16:57:40 -04:00
|
|
|
# >> git clone https://github.com/docker/docker.git C:\go\src\github.com\docker\docker
|
|
|
|
# >> Cloning into 'C:\go\src\github.com\docker\docker'...
|
2016-10-20 20:02:26 -04:00
|
|
|
# >> remote: Counting objects: 186216, done.
|
|
|
|
# >> remote: Compressing objects: 100% (21/21), done.
|
|
|
|
# >> remote: Total 186216 (delta 5), reused 0 (delta 0), pack-reused 186195
|
|
|
|
# >> Receiving objects: 100% (186216/186216), 104.32 MiB | 8.18 MiB/s, done.
|
|
|
|
# >> Resolving deltas: 100% (123139/123139), done.
|
|
|
|
# >> Checking connectivity... done.
|
|
|
|
# >> Checking out files: 100% (3912/3912), done.
|
|
|
|
# >> PS C:\>
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# 2. Change directory to the cloned docker sources:
|
2015-12-01 03:47:19 -05:00
|
|
|
#
|
2016-10-30 16:57:40 -04:00
|
|
|
# >> cd C:\go\src\github.com\docker\docker
|
2016-01-20 21:51:34 -05:00
|
|
|
#
|
2015-12-01 03:47:19 -05:00
|
|
|
#
|
2016-10-20 20:02:26 -04:00
|
|
|
# 3. Build a docker image with the components required to build the docker binaries from source:
|
2015-12-01 03:47:19 -05:00
|
|
|
#
|
2016-10-20 20:02:26 -04:00
|
|
|
# >> docker build -t nativebuildimage -f Dockerfile.windows .
|
2016-01-20 21:51:34 -05:00
|
|
|
#
|
|
|
|
#
|
2016-10-20 20:02:26 -04:00
|
|
|
# 4. Build the docker executable binaries in a container:
|
|
|
|
#
|
|
|
|
# >> docker run --name binaries nativebuildimage sh -c 'cd /c/go/src/github.com/docker/docker; hack/make.sh binary'
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# 5. Copy the binaries out of the above container, replacing HostPath with an appropriate destination
|
|
|
|
# folder on the host system where you want the binaries to be located.
|
|
|
|
#
|
|
|
|
# >> $v=$(Get-Content ".\VERSION" -raw).ToString().Replace("`n","").Trim()
|
2016-10-30 16:57:40 -04:00
|
|
|
# >> docker cp binaries:C:\go\src\github.com\docker\docker\bundles\$v\binary-client\docker-$v.exe C:\HostPath\docker.exe
|
|
|
|
# >> docker cp binaries:C:\go\src\github.com\docker\docker\bundles\$v\binary-daemon\dockerd.exe C:\HostPath\dockerd.exe
|
|
|
|
# >> docker cp binaries:C:\go\src\github.com\docker\docker\bundles\$v\binary-daemon\docker-proxy-$v.exe C:\HostPath\docker-proxy.exe
|
2016-10-20 20:02:26 -04:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# 6. (Optional) Remove the interim container holding the built executable binaries:
|
|
|
|
#
|
|
|
|
# >> docker rm binaries
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# 7. (Optional) Remove the image used for the container in which the executable
|
|
|
|
# binaries are build. Tip - it may be useful to keep this image around if you need to
|
|
|
|
# build multiple times. Then you can take advantage of the builder cache to have an
|
|
|
|
# image which has all the components required to build the binaries already installed.
|
|
|
|
#
|
|
|
|
# >> docker rmi nativebuildimage
|
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2016-01-20 21:51:34 -05:00
|
|
|
# Important notes:
|
|
|
|
# ---------------
|
|
|
|
#
|
2016-10-20 20:02:26 -04:00
|
|
|
# The posix utilities from git aren't usable interactively as at October 2016. This
|
2016-01-20 21:51:34 -05:00
|
|
|
# is because they require a console window which isn't present in a container in Windows.
|
2016-10-20 20:02:26 -04:00
|
|
|
# See the example at the top of this file. Do NOT use -it in that docker run. It will not work.
|
2016-01-20 21:51:34 -05:00
|
|
|
#
|
2016-10-20 20:02:26 -04:00
|
|
|
# Don't attempt to use a volume for passing the source through to the container. The posix utilities will
|
|
|
|
# balk at reparse points.
|
2016-01-30 23:50:11 -05:00
|
|
|
#
|
2016-10-20 20:02:26 -04:00
|
|
|
# The downloaded files are not cleared from the image. go.zip is used by the Windows
|
|
|
|
# CI servers to ensure the host and image are running consistent versions of go.
|
|
|
|
#
|
2016-10-21 22:56:16 -04:00
|
|
|
# The GIT installer isn't very good at unattended install. We use techniques described
|
|
|
|
# at the links below to force it to set the path and other options accordingly.
|
|
|
|
# >> http://superuser.com/questions/944576/git-for-windows-silent-install-silent-arguments
|
|
|
|
# and follow through to installer at
|
|
|
|
# >> https://github.com/ferventcoder/chocolatey-packages/blob/master/automatic/git.install/tools/chocolateyInstall.ps1
|
2016-11-10 15:45:56 -05:00
|
|
|
#
|
|
|
|
# As of October 2016, this does not work on Windows 10 client, just Windows Server 2016,
|
|
|
|
# and only with the default isolation mode (process). It does not work with isolation mode
|
|
|
|
# set to Hyper-V containers (hyperv).
|
2016-10-20 20:02:26 -04:00
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------------------
|
2015-12-01 03:47:19 -05:00
|
|
|
|
2016-10-20 20:02:26 -04:00
|
|
|
# The number of build steps below are explicitly minimised to improve performance.
|
|
|
|
FROM microsoft/windowsservercore
|
2015-12-01 03:47:19 -05:00
|
|
|
|
2016-10-30 16:57:40 -04:00
|
|
|
# Use PowerShell as the default shell
|
|
|
|
SHELL ["powershell", "-command"]
|
|
|
|
|
2016-01-20 21:51:34 -05:00
|
|
|
# Environment variable notes:
|
2016-10-30 16:57:40 -04:00
|
|
|
# - GO_VERSION must be consistent with 'Dockerfile' used by Linux.
|
2016-01-20 21:51:34 -05:00
|
|
|
# - FROM_DOCKERFILE is used for detection of building within a container.
|
2016-10-20 20:02:26 -04:00
|
|
|
ENV GO_VERSION=1.7.3 `
|
2016-10-21 22:56:16 -04:00
|
|
|
GIT_LOCATION=https://github.com/git-for-windows/git/releases/download/v2.10.1.windows.1/Git-2.10.1-64-bit.exe `
|
2016-10-31 14:22:28 -04:00
|
|
|
GOPATH=C:\go `
|
2015-12-01 03:47:19 -05:00
|
|
|
FROM_DOCKERFILE=1
|
|
|
|
|
2016-10-30 16:57:40 -04:00
|
|
|
WORKDIR C:\
|
2015-12-01 03:47:19 -05:00
|
|
|
|
2016-10-20 20:02:26 -04:00
|
|
|
RUN `
|
2016-10-30 16:57:40 -04:00
|
|
|
setx /M Path $($Env:PATH+';C:\gcc\bin;C:\go\bin'); `
|
|
|
|
`
|
2016-10-20 20:02:26 -04:00
|
|
|
$ErrorActionPreference = 'Stop'; `
|
|
|
|
Function Download-File([string] $source, [string] $target) { `
|
2016-10-30 16:57:40 -04:00
|
|
|
$wc = New-Object net.webclient; $wc.Downloadfile($source, $target) `
|
2016-10-20 20:02:26 -04:00
|
|
|
} `
|
|
|
|
`
|
|
|
|
Write-Host INFO: Downloading git...; `
|
2016-10-30 16:57:40 -04:00
|
|
|
Download-File $Env:GIT_LOCATION gitsetup.exe; `
|
2016-10-20 20:02:26 -04:00
|
|
|
`
|
|
|
|
Write-Host INFO: Downloading go...; `
|
2016-10-30 16:57:40 -04:00
|
|
|
Download-File $('https://golang.org/dl/go'+$Env:GO_VERSION+'.windows-amd64.zip') go.zip; `
|
2016-10-20 20:02:26 -04:00
|
|
|
`
|
|
|
|
Write-Host INFO: Downloading compiler 1 of 3...; `
|
|
|
|
Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/gcc.zip gcc.zip; `
|
|
|
|
`
|
|
|
|
Write-Host INFO: Downloading compiler 2 of 3...; `
|
|
|
|
Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/runtime.zip runtime.zip; `
|
|
|
|
`
|
|
|
|
Write-Host INFO: Downloading compiler 3 of 3...; `
|
|
|
|
Download-File https://raw.githubusercontent.com/jhowardmsft/docker-tdmgcc/master/binutils.zip binutils.zip; `
|
|
|
|
`
|
|
|
|
Write-Host INFO: Installing git...; `
|
2016-10-21 22:56:16 -04:00
|
|
|
$installPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'; `
|
|
|
|
$installItem = 'Git_is1'; `
|
|
|
|
New-Item -Path $installPath -Name $installItem -Force; `
|
|
|
|
$installKey = $installPath+'\'+$installItem; `
|
|
|
|
New-ItemProperty $installKey -Name 'Inno Setup CodeFile: Path Option' -Value 'CmdTools' -PropertyType 'String' -Force; `
|
|
|
|
New-ItemProperty $installKey -Name 'Inno Setup CodeFile: Bash Terminal Option' -Value 'ConHost' -PropertyType 'String' -Force; `
|
|
|
|
New-ItemProperty $installKey -Name 'Inno Setup CodeFile: CRLF Option' -Value 'CRLFCommitAsIs' -PropertyType 'String' -Force; `
|
2016-10-30 16:57:40 -04:00
|
|
|
Start-Process gitsetup.exe -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /CLOSEAPPLICATIONS /DIR=C:\git\' -Wait; `
|
2016-10-20 20:02:26 -04:00
|
|
|
`
|
2016-10-30 16:57:40 -04:00
|
|
|
Write-Host INFO: Expanding go...; `
|
|
|
|
Expand-Archive C:\go.zip -DestinationPath C:\; `
|
2016-10-20 20:02:26 -04:00
|
|
|
`
|
|
|
|
Write-Host INFO: Expanding compiler...; `
|
2016-10-30 16:57:40 -04:00
|
|
|
Expand-Archive C:\gcc.zip -DestinationPath C:\gcc -Force; `
|
|
|
|
Expand-Archive C:\runtime.zip -DestinationPath C:\gcc -Force; `
|
|
|
|
Expand-Archive C:\binutils.zip -DestinationPath C:\gcc -Force; `
|
2016-10-20 20:02:26 -04:00
|
|
|
`
|
2016-01-30 23:50:11 -05:00
|
|
|
Write-Host INFO: Completed
|
2016-04-23 18:11:08 -04:00
|
|
|
|
2016-01-20 21:51:34 -05:00
|
|
|
# Prepare for building
|
2016-10-30 16:57:40 -04:00
|
|
|
COPY . C:\go\src\github.com\docker\docker
|
2016-01-20 21:51:34 -05:00
|
|
|
|