This change adds file version information to docker.exe and dockerd.exe by
adding a Windows version resource with the windres tool.
This change adds a dependency to binutils-mingw-w64 on Linux, but removes
a dependency on rsrc. Most Windows build environments should already have
windres if they have gcc (which is necessary to build dockerd).
Signed-off-by: John Starks <jostarks@microsoft.com>
| ... | ... |
@@ -46,6 +46,7 @@ RUN apt-get update && apt-get install -y \ |
| 46 | 46 |
aufs-tools \ |
| 47 | 47 |
automake \ |
| 48 | 48 |
bash-completion \ |
| 49 |
+ binutils-mingw-w64 \ |
|
| 49 | 50 |
bsdmainutils \ |
| 50 | 51 |
btrfs-tools \ |
| 51 | 52 |
build-essential \ |
| ... | ... |
@@ -248,15 +249,6 @@ RUN set -x \ |
| 248 | 248 |
&& go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \ |
| 249 | 249 |
&& rm -rf "$GOPATH" |
| 250 | 250 |
|
| 251 |
-# Build/install the tool for embedding resources in Windows binaries |
|
| 252 |
-ENV RSRC_COMMIT ba14da1f827188454a4591717fff29999010887f |
|
| 253 |
-RUN set -x \ |
|
| 254 |
- && export GOPATH="$(mktemp -d)" \ |
|
| 255 |
- && git clone https://github.com/akavel/rsrc.git "$GOPATH/src/github.com/akavel/rsrc" \ |
|
| 256 |
- && (cd "$GOPATH/src/github.com/akavel/rsrc" && git checkout -q "$RSRC_COMMIT") \ |
|
| 257 |
- && go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \ |
|
| 258 |
- && rm -rf "$GOPATH" |
|
| 259 |
- |
|
| 260 | 251 |
# Install runc |
| 261 | 252 |
ENV RUNC_COMMIT e87436998478d222be209707503c27f6f91be0c5 |
| 262 | 253 |
RUN set -x \ |
| ... | ... |
@@ -191,14 +191,6 @@ RUN set -x \ |
| 191 | 191 |
&& go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \ |
| 192 | 192 |
&& rm -rf "$GOPATH" |
| 193 | 193 |
|
| 194 |
-# Build/install the tool for embedding resources in Windows binaries |
|
| 195 |
-ENV RSRC_VERSION v2 |
|
| 196 |
-RUN set -x \ |
|
| 197 |
- && export GOPATH="$(mktemp -d)" \ |
|
| 198 |
- && git clone --depth 1 -b "$RSRC_VERSION" https://github.com/akavel/rsrc.git "$GOPATH/src/github.com/akavel/rsrc" \ |
|
| 199 |
- && go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \ |
|
| 200 |
- && rm -rf "$GOPATH" |
|
| 201 |
- |
|
| 202 | 194 |
# Install runc |
| 203 | 195 |
ENV RUNC_COMMIT e87436998478d222be209707503c27f6f91be0c5 |
| 204 | 196 |
RUN set -x \ |
| ... | ... |
@@ -187,14 +187,6 @@ RUN set -x \ |
| 187 | 187 |
&& go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \ |
| 188 | 188 |
&& rm -rf "$GOPATH" |
| 189 | 189 |
|
| 190 |
-# Build/install the tool for embedding resources in Windows binaries |
|
| 191 |
-ENV RSRC_VERSION v2 |
|
| 192 |
-RUN set -x \ |
|
| 193 |
- && export GOPATH="$(mktemp -d)" \ |
|
| 194 |
- && git clone --depth 1 -b "$RSRC_VERSION" https://github.com/akavel/rsrc.git "$GOPATH/src/github.com/akavel/rsrc" \ |
|
| 195 |
- && go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \ |
|
| 196 |
- && rm -rf "$GOPATH" |
|
| 197 |
- |
|
| 198 | 190 |
# Install runc |
| 199 | 191 |
ENV RUNC_COMMIT e87436998478d222be209707503c27f6f91be0c5 |
| 200 | 192 |
RUN set -x \ |
| ... | ... |
@@ -169,14 +169,6 @@ RUN set -x \ |
| 169 | 169 |
&& go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \ |
| 170 | 170 |
&& rm -rf "$GOPATH" |
| 171 | 171 |
|
| 172 |
-# Build/install the tool for embedding resources in Windows binaries |
|
| 173 |
-ENV RSRC_VERSION v2 |
|
| 174 |
-RUN set -x \ |
|
| 175 |
- && export GOPATH="$(mktemp -d)" \ |
|
| 176 |
- && git clone --depth 1 -b "$RSRC_VERSION" https://github.com/akavel/rsrc.git "$GOPATH/src/github.com/akavel/rsrc" \ |
|
| 177 |
- && go build -v -o /usr/local/bin/rsrc github.com/akavel/rsrc \ |
|
| 178 |
- && rm -rf "$GOPATH" |
|
| 179 |
- |
|
| 180 | 172 |
# Install runc |
| 181 | 173 |
ENV RUNC_COMMIT e87436998478d222be209707503c27f6f91be0c5 |
| 182 | 174 |
RUN set -x \ |
| ... | ... |
@@ -1,10 +1,10 @@ |
| 1 |
-# This file describes the standard way to build Docker, using a docker container on Windows |
|
| 1 |
+# This file describes the standard way to build Docker, using a docker container on Windows |
|
| 2 | 2 |
# Server 2016 |
| 3 | 3 |
# |
| 4 | 4 |
# Usage: |
| 5 | 5 |
# |
| 6 | 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 |
|
| 7 |
+# # a directory containing the sources you are validating. For example from |
|
| 8 | 8 |
# # c:\go\src\github.com\docker\docker |
| 9 | 9 |
# |
| 10 | 10 |
# docker build -t docker -f Dockerfile.windows . |
| ... | ... |
@@ -21,7 +21,7 @@ |
| 21 | 21 |
# |
| 22 | 22 |
# The posix utilities from GIT aren't usable interactively as at January 2016. This |
| 23 | 23 |
# 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!!! |
|
| 24 |
+# See the example at the top of this file. Do NOT use -it in that docker run!!! |
|
| 25 | 25 |
# |
| 26 | 26 |
# Don't try to use a volume for passing the source through. The posix utilities will |
| 27 | 27 |
# balk at reparse points. Again, see the example at the top of this file on how use a volume |
| ... | ... |
@@ -36,7 +36,6 @@ FROM windowsservercore |
| 36 | 36 |
# - FROM_DOCKERFILE is used for detection of building within a container. |
| 37 | 37 |
ENV GO_VERSION=1.5.3 \ |
| 38 | 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 |
- RSRC_COMMIT=ba14da1f827188454a4591717fff29999010887f \ |
|
| 40 | 39 |
GOPATH=C:/go;C:/go/src/github.com/docker/docker/vendor \ |
| 41 | 40 |
FROM_DOCKERFILE=1 |
| 42 | 41 |
|
| ... | ... |
@@ -52,7 +51,7 @@ RUN \ |
| 52 | 52 |
$wc = New-Object net.webclient; $wc.Downloadfile($source, $target) \ |
| 53 | 53 |
} \ |
| 54 | 54 |
\ |
| 55 |
- Write-Host INFO: Downloading git...; \ |
|
| 55 |
+ Write-Host INFO: Downloading git...; \ |
|
| 56 | 56 |
Download-File %GIT_LOCATION% gitsetup.exe; \ |
| 57 | 57 |
\ |
| 58 | 58 |
Write-Host INFO: Downloading go...; \ |
| ... | ... |
@@ -83,12 +82,8 @@ RUN \ |
| 83 | 83 |
Remove-Item go.msi; \ |
| 84 | 84 |
Remove-Item gitsetup.exe; \ |
| 85 | 85 |
\ |
| 86 |
- Write-Host INFO: Cloning and installing RSRC; \ |
|
| 87 |
- c:\git\bin\git.exe clone https://github.com/akavel/rsrc.git c:\go\src\github.com\akavel\rsrc; \ |
|
| 88 |
- cd \go\src\github.com\akavel\rsrc; c:\git\bin\git.exe checkout -q %RSRC_COMMIT%; c:\go\bin\go.exe install -v; \ |
|
| 89 |
- \ |
|
| 90 | 86 |
Write-Host INFO: Completed |
| 91 |
- |
|
| 87 |
+ |
|
| 92 | 88 |
# Prepare for building |
| 93 | 89 |
COPY . /go/src/github.com/docker/docker |
| 94 | 90 |
|
| ... | ... |
@@ -20,44 +20,40 @@ const ( |
| 20 | 20 |
DVEOF |
| 21 | 21 |
|
| 22 | 22 |
# Compile the Windows resources into the sources |
| 23 |
-mkdir -p autogen/winresources |
|
| 24 |
-cat > autogen/winresources/resources.go <<WREOF |
|
| 25 |
-// Package winresources is auto-generated at build-time |
|
| 26 |
-// AUTOGENERATED FILE; see $BASH_SOURCE |
|
| 27 |
-package winresources |
|
| 28 |
- |
|
| 29 |
-/* |
|
| 30 |
- |
|
| 31 |
-This package is for embedding a manifest file and an icon into docker.exe. |
|
| 32 |
-The benefit of this is that a manifest file does not need to be alongside |
|
| 33 |
-the .exe, and there is an icon when docker runs, or viewed through Windows |
|
| 34 |
-explorer. |
|
| 35 |
- |
|
| 36 |
-When make binary is run, the Dockerfile prepares the build environment by: |
|
| 37 |
- |
|
| 38 |
- - Cloning github.com/akavel/rsrc |
|
| 39 |
- |
|
| 40 |
- - Go-installing the rsrc executable |
|
| 41 |
- |
|
| 42 |
-make.sh invokes hack/make/.go-autogen to: |
|
| 43 |
- |
|
| 44 |
- - Run rsrc to create a binary file (autogen/winresources/rsrc.syso) that |
|
| 45 |
- contains the manifest and icon. This file is automatically picked up by |
|
| 46 |
- 'go build', so no post-processing steps are required. The sources for |
|
| 47 |
- rsrc.syso are under hack/make/.resources-windows. |
|
| 48 |
- |
|
| 49 |
-*/ |
|
| 50 |
-WREOF |
|
| 51 |
-if [ "$(go env GOOS)" = 'windows' ]; then |
|
| 52 |
- rsrc \ |
|
| 53 |
- -manifest hack/make/.resources-windows/docker.exe.manifest \ |
|
| 54 |
- -ico hack/make/.resources-windows/docker.ico \ |
|
| 55 |
- -arch "amd64" \ |
|
| 56 |
- -o autogen/winresources/rsrc_amd64.syso > /dev/null |
|
| 57 |
- |
|
| 58 |
- rsrc \ |
|
| 59 |
- -manifest hack/make/.resources-windows/docker.exe.manifest \ |
|
| 60 |
- -ico hack/make/.resources-windows/docker.ico \ |
|
| 61 |
- -arch "386" \ |
|
| 62 |
- -o autogen/winresources/rsrc_386.syso > /dev/null |
|
| 23 |
+if [ "$(go env GOOS)" = "windows" ]; then |
|
| 24 |
+ mkdir -p autogen/winresources/tmp autogen/winresources/docker autogen/winresources/dockerd |
|
| 25 |
+ cp hack/make/.resources-windows/resources.go autogen/winresources/docker/ |
|
| 26 |
+ cp hack/make/.resources-windows/resources.go autogen/winresources/dockerd/ |
|
| 27 |
+ |
|
| 28 |
+ if [ "$(go env GOHOSTOS)" == "windows" ]; then |
|
| 29 |
+ WINDRES=windres |
|
| 30 |
+ else |
|
| 31 |
+ # Cross compiling |
|
| 32 |
+ WINDRES=x86_64-w64-mingw32-windres |
|
| 33 |
+ fi |
|
| 34 |
+ |
|
| 35 |
+ # Generate a Windows file version of the form major,minor,patch,build (with any part optional) |
|
| 36 |
+ VERSION_QUAD=$(echo -n $VERSION | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,) |
|
| 37 |
+ |
|
| 38 |
+ # Pass version and commit information into the resource compiler |
|
| 39 |
+ defs= |
|
| 40 |
+ [ ! -z $VERSION ] && defs="$defs -D DOCKER_VERSION=\"$VERSION\"" |
|
| 41 |
+ [ ! -z $VERSION_QUAD ] && defs="$defs -D DOCKER_VERSION_QUAD=$VERSION_QUAD" |
|
| 42 |
+ [ ! -z $GITCOMMIT ] && defs="$defs -D DOCKER_COMMIT=\"$GITCOMMIT\"" |
|
| 43 |
+ |
|
| 44 |
+ function makeres {
|
|
| 45 |
+ $WINDRES \ |
|
| 46 |
+ -i hack/make/.resources-windows/$1 \ |
|
| 47 |
+ -o $3 \ |
|
| 48 |
+ -F $2 \ |
|
| 49 |
+ --use-temp-file \ |
|
| 50 |
+ -I autogen/winresources/tmp \ |
|
| 51 |
+ $defs |
|
| 52 |
+ } |
|
| 53 |
+ |
|
| 54 |
+ makeres docker.rc pe-x86-64 autogen/winresources/docker/rsrc_amd64.syso |
|
| 55 |
+ makeres docker.rc pe-i386 autogen/winresources/docker/rsrc_386.syso |
|
| 56 |
+ makeres dockerd.rc pe-x86-64 autogen/winresources/dockerd/rsrc_amd64.syso |
|
| 57 |
+ |
|
| 58 |
+ rm -r autogen/winresources/tmp |
|
| 63 | 59 |
fi |
| 64 | 60 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,38 @@ |
| 0 |
+// Application icon |
|
| 1 |
+1 ICON "docker.ico" |
|
| 2 |
+ |
|
| 3 |
+// Windows executable manifest |
|
| 4 |
+1 24 /* RT_MANIFEST */ "docker.exe.manifest" |
|
| 5 |
+ |
|
| 6 |
+// Version information |
|
| 7 |
+1 VERSIONINFO |
|
| 8 |
+ |
|
| 9 |
+#ifdef DOCKER_VERSION_QUAD |
|
| 10 |
+FILEVERSION DOCKER_VERSION_QUAD |
|
| 11 |
+PRODUCTVERSION DOCKER_VERSION_QUAD |
|
| 12 |
+#endif |
|
| 13 |
+ |
|
| 14 |
+BEGIN |
|
| 15 |
+ BLOCK "StringFileInfo" |
|
| 16 |
+ BEGIN |
|
| 17 |
+ BLOCK "000004B0" |
|
| 18 |
+ BEGIN |
|
| 19 |
+ VALUE "ProductName", DOCKER_NAME |
|
| 20 |
+ |
|
| 21 |
+#ifdef DOCKER_VERSION |
|
| 22 |
+ VALUE "FileVersion", DOCKER_VERSION |
|
| 23 |
+ VALUE "ProductVersion", DOCKER_VERSION |
|
| 24 |
+#endif |
|
| 25 |
+ |
|
| 26 |
+#ifdef DOCKER_COMMIT |
|
| 27 |
+ VALUE "OriginalFileName", DOCKER_COMMIT |
|
| 28 |
+#endif |
|
| 29 |
+ |
|
| 30 |
+ END |
|
| 31 |
+ END |
|
| 32 |
+ |
|
| 33 |
+ BLOCK "VarFileInfo" |
|
| 34 |
+ BEGIN |
|
| 35 |
+ VALUE "Translation", 0x0000, 0x04B0 |
|
| 36 |
+ END |
|
| 37 |
+END |
| 0 | 3 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,18 @@ |
| 0 |
+/* |
|
| 1 |
+ |
|
| 2 |
+Package winresources is used to embed Windows resources into docker.exe. |
|
| 3 |
+These resources are used to provide |
|
| 4 |
+ |
|
| 5 |
+ * Version information |
|
| 6 |
+ * An icon |
|
| 7 |
+ * A Windows manifest declaring Windows version support |
|
| 8 |
+ |
|
| 9 |
+The resource object files are generated in hack/make/.go-autogen from |
|
| 10 |
+source files in hack/make/.resources-windows. This occurs automatically |
|
| 11 |
+when you run hack/make.sh. |
|
| 12 |
+ |
|
| 13 |
+These object files are picked up automatically by go build when this package |
|
| 14 |
+is included. |
|
| 15 |
+ |
|
| 16 |
+*/ |
|
| 17 |
+package winresources |