use go-winres for cross to create Windows resources
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
61404de7df
commit
fd2143e0b0
20 changed files with 163 additions and 143 deletions
|
@ -2,5 +2,6 @@
|
|||
.go-pkg-cache
|
||||
.gopath
|
||||
bundles
|
||||
cli/winresources/**/winres.json
|
||||
cli/winresources/**/*.syso
|
||||
vendor/pkg
|
||||
|
||||
|
|
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
|
@ -74,7 +74,6 @@ jobs:
|
|||
run: |
|
||||
platform=${{ matrix.platform }}
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
mkdir -p autogen
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -15,6 +15,8 @@ test.main
|
|||
.go-pkg-cache/
|
||||
autogen/
|
||||
bundles/
|
||||
cli/winresources/**/winres.json
|
||||
cli/winresources/**/*.syso
|
||||
cmd/dockerd/dockerd
|
||||
contrib/builder/rpm/*/changelog
|
||||
vendor/pkg/
|
||||
|
|
31
Dockerfile
31
Dockerfile
|
@ -161,6 +161,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
|
|||
GOBIN=/build/ GO111MODULE=on go install "github.com/pelletier/go-toml/cmd/tomll@${GOTOML_VERSION}" \
|
||||
&& /build/tomll --help
|
||||
|
||||
FROM base AS gowinres
|
||||
# GOWINRES_VERSION defines go-winres tool version
|
||||
ARG GOWINRES_VERSION=v0.2.3
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
GOBIN=/build/ GO111MODULE=on go install "github.com/tc-hib/go-winres@${GOWINRES_VERSION}" \
|
||||
&& /build/go-winres --help
|
||||
|
||||
FROM dev-base AS containerd
|
||||
ARG DEBIAN_FRONTEND
|
||||
RUN --mount=type=cache,sharing=locked,id=moby-containerd-aptlib,target=/var/lib/apt \
|
||||
|
@ -301,6 +309,7 @@ COPY --from=dockercli /build/ /usr/local/cli
|
|||
COPY --from=frozen-images /build/ /docker-frozen-images
|
||||
COPY --from=swagger /build/ /usr/local/bin/
|
||||
COPY --from=tomll /build/ /usr/local/bin/
|
||||
COPY --from=gowinres /build/ /usr/local/bin/
|
||||
COPY --from=tini /build/ /usr/local/bin/
|
||||
COPY --from=registry /build/ /usr/local/bin/
|
||||
COPY --from=criu /build/ /usr/local/bin/
|
||||
|
@ -346,6 +355,8 @@ ARG PRODUCT
|
|||
ENV PRODUCT=${PRODUCT}
|
||||
ARG DEFAULT_PRODUCT_LICENSE
|
||||
ENV DEFAULT_PRODUCT_LICENSE=${DEFAULT_PRODUCT_LICENSE}
|
||||
ARG PACKAGER_NAME
|
||||
ENV PACKAGER_NAME=${PACKAGER_NAME}
|
||||
ARG DOCKER_BUILDTAGS
|
||||
ENV DOCKER_BUILDTAGS="${DOCKER_BUILDTAGS}"
|
||||
ENV PREFIX=/build
|
||||
|
@ -357,23 +368,29 @@ COPY --from=runc /build/ /usr/local/bin/
|
|||
COPY --from=containerd /build/ /usr/local/bin/
|
||||
COPY --from=rootlesskit /build/ /usr/local/bin/
|
||||
COPY --from=vpnkit /build/ /usr/local/bin/
|
||||
COPY --from=gowinres /build/ /usr/local/bin/
|
||||
WORKDIR /go/src/github.com/docker/docker
|
||||
|
||||
FROM binary-base AS build-binary
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=bind,target=/go/src/github.com/docker/docker \
|
||||
RUN --mount=type=cache,target=/root/.cache \
|
||||
--mount=type=bind,target=.,ro \
|
||||
--mount=type=tmpfs,target=cli/winresources/dockerd \
|
||||
--mount=type=tmpfs,target=cli/winresources/docker-proxy \
|
||||
hack/make.sh binary
|
||||
|
||||
FROM binary-base AS build-dynbinary
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=bind,target=/go/src/github.com/docker/docker \
|
||||
RUN --mount=type=cache,target=/root/.cache \
|
||||
--mount=type=bind,target=.,ro \
|
||||
--mount=type=tmpfs,target=cli/winresources/dockerd \
|
||||
--mount=type=tmpfs,target=cli/winresources/docker-proxy \
|
||||
hack/make.sh dynbinary
|
||||
|
||||
FROM binary-base AS build-cross
|
||||
ARG DOCKER_CROSSPLATFORMS
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=bind,target=/go/src/github.com/docker/docker \
|
||||
--mount=type=tmpfs,target=/go/src/github.com/docker/docker/autogen \
|
||||
RUN --mount=type=cache,target=/root/.cache \
|
||||
--mount=type=bind,target=.,ro \
|
||||
--mount=type=tmpfs,target=cli/winresources/dockerd \
|
||||
--mount=type=tmpfs,target=cli/winresources/docker-proxy \
|
||||
hack/make.sh cross
|
||||
|
||||
FROM scratch AS binary
|
||||
|
|
5
Makefile
5
Makefile
|
@ -85,7 +85,8 @@ DOCKER_ENVS := \
|
|||
-e VERSION \
|
||||
-e PLATFORM \
|
||||
-e DEFAULT_PRODUCT_LICENSE \
|
||||
-e PRODUCT
|
||||
-e PRODUCT \
|
||||
-e PACKAGER_NAME
|
||||
# note: we _cannot_ add "-e DOCKER_BUILDTAGS" here because even if it's unset in the shell, that would shadow the "ENV DOCKER_BUILDTAGS" set in our Dockerfile, which is very important for our official builds
|
||||
|
||||
# to allow `make BIND_DIR=. shell` or `make BIND_DIR= test`
|
||||
|
@ -158,7 +159,7 @@ ifdef DOCKER_CROSSPLATFORMS
|
|||
BUILD_CROSS = --build-arg CROSS=true
|
||||
endif
|
||||
|
||||
VERSION_AUTOGEN_ARGS = --build-arg VERSION --build-arg DOCKER_GITCOMMIT --build-arg PRODUCT --build-arg PLATFORM --build-arg DEFAULT_PRODUCT_LICENSE
|
||||
VERSION_AUTOGEN_ARGS = --build-arg VERSION --build-arg DOCKER_GITCOMMIT --build-arg PRODUCT --build-arg PLATFORM --build-arg DEFAULT_PRODUCT_LICENSE --build-arg PACKAGER_NAME
|
||||
|
||||
default: binary
|
||||
|
||||
|
|
0
cli/winresources/README.md
Normal file
0
cli/winresources/README.md
Normal file
12
cli/winresources/docker-proxy/winresources.go
Normal file
12
cli/winresources/docker-proxy/winresources.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Package winresources is used to embed Windows resources into docker-proxy.exe.
|
||||
//
|
||||
// These resources are used to provide:
|
||||
// * Version information
|
||||
// * An icon
|
||||
// * A Windows manifest declaring Windows version support
|
||||
// * Events message table
|
||||
//
|
||||
// The resource object files are generated when building with go-winres
|
||||
// in hack/make/.go-autogen and are located in cli/winresources.
|
||||
// This occurs automatically when you cross build against Windows OS.
|
||||
package winresources
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
12
cli/winresources/dockerd/winresources.go
Normal file
12
cli/winresources/dockerd/winresources.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Package winresources is used to embed Windows resources into dockerd.exe.
|
||||
//
|
||||
// These resources are used to provide:
|
||||
// * Version information
|
||||
// * An icon
|
||||
// * A Windows manifest declaring Windows version support
|
||||
// * Events message table
|
||||
//
|
||||
// The resource object files are generated when building with go-winres
|
||||
// in hack/make/.go-autogen and are located in cli/winresources.
|
||||
// This occurs automatically when you cross build against Windows OS.
|
||||
package winresources
|
BIN
cli/winresources/event_messages.bin
Normal file
BIN
cli/winresources/event_messages.bin
Normal file
Binary file not shown.
5
cmd/docker-proxy/genwinres_windows.go
Normal file
5
cmd/docker-proxy/genwinres_windows.go
Normal file
|
@ -0,0 +1,5 @@
|
|||
//go:generate go-winres make --arch=386,amd64,arm,arm64 --in=../../cli/winresources/docker-proxy/winres.json --out=../../cli/winresources/docker-proxy/resource
|
||||
|
||||
package main
|
||||
|
||||
import _ "github.com/docker/docker/cli/winresources/docker-proxy"
|
5
cmd/dockerd/genwinres_windows.go
Normal file
5
cmd/dockerd/genwinres_windows.go
Normal file
|
@ -0,0 +1,5 @@
|
|||
//go:generate go-winres make --arch=386,amd64,arm,arm64 --in=../../cli/winresources/dockerd/winres.json --out=../../cli/winresources/dockerd/resource
|
||||
|
||||
package main
|
||||
|
||||
import _ "github.com/docker/docker/cli/winresources/dockerd"
|
|
@ -7,9 +7,3 @@ module github.com/docker/docker
|
|||
|
||||
go 1.17
|
||||
EOF
|
||||
|
||||
cat > "${ROOTDIR}/hack/make/.resources-windows/go.mod" << EOF
|
||||
module github.com/docker/docker/autogen/winresources/dockerd
|
||||
|
||||
go 1.17
|
||||
EOF
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
rm -rf autogen/*
|
||||
|
||||
source hack/dockerfile/install/runc.installer
|
||||
source hack/dockerfile/install/tini.installer
|
||||
source hack/dockerfile/install/containerd.installer
|
||||
|
@ -18,45 +16,12 @@ LDFLAGS="${LDFLAGS} \
|
|||
|
||||
# Compile the Windows resources into the sources
|
||||
if [ "$(go env GOOS)" = "windows" ]; then
|
||||
mkdir -p autogen/winresources/tmp autogen/winresources/dockerd
|
||||
cp hack/make/.resources-windows/resources.go autogen/winresources/dockerd/
|
||||
|
||||
if [ "$(go env GOHOSTOS)" == "windows" ]; then
|
||||
WINDRES=windres
|
||||
WINDMC=windmc
|
||||
if [ ! -x "$(command -v go-winres)" ]; then
|
||||
>&2 echo "go-winres not found, skipping manifesting binary"
|
||||
else
|
||||
# Cross compiling
|
||||
WINDRES=x86_64-w64-mingw32-windres
|
||||
WINDMC=x86_64-w64-mingw32-windmc
|
||||
(
|
||||
. hack/make/.mkwinres
|
||||
go generate -v "${GO_PACKAGE}"
|
||||
)
|
||||
fi
|
||||
|
||||
# Generate a Windows file version of the form major,minor,patch,build (with any part optional)
|
||||
if [ ! -v VERSION_QUAD ]; then
|
||||
VERSION_QUAD=$(echo -n $VERSION | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,)
|
||||
fi
|
||||
|
||||
# Pass version and commit information into the resource compiler
|
||||
defs=
|
||||
[ ! -z $VERSION ] && defs="$defs -D DOCKER_VERSION=\"$VERSION\""
|
||||
[ ! -z $VERSION_QUAD ] && defs="$defs -D DOCKER_VERSION_QUAD=$VERSION_QUAD"
|
||||
[ ! -z $GITCOMMIT ] && defs="$defs -D DOCKER_COMMIT=\"$GITCOMMIT\""
|
||||
|
||||
function makeres {
|
||||
${WINDRES} \
|
||||
-i hack/make/.resources-windows/$1 \
|
||||
-o $3 \
|
||||
-F $2 \
|
||||
--use-temp-file \
|
||||
-I autogen/winresources/tmp \
|
||||
$defs
|
||||
}
|
||||
|
||||
${WINDMC} \
|
||||
hack/make/.resources-windows/event_messages.mc \
|
||||
-h autogen/winresources/tmp \
|
||||
-r autogen/winresources/tmp
|
||||
|
||||
makeres dockerd.rc pe-x86-64 autogen/winresources/dockerd/rsrc_amd64.syso
|
||||
|
||||
rm -r autogen/winresources/tmp
|
||||
fi
|
||||
|
|
85
hack/make/.mkwinres
Normal file
85
hack/make/.mkwinres
Normal file
|
@ -0,0 +1,85 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
quadVersionNum() {
|
||||
num=$(echo "${1:-0}" | cut -d. -f"$2")
|
||||
if [ "$num" != "0" ]; then
|
||||
echo "${num#0}"
|
||||
else
|
||||
echo "$num"
|
||||
fi
|
||||
}
|
||||
|
||||
# Create version quad for Windows of the form major.minor.patch.build
|
||||
VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | sed -re 's/\.$//' | sed -re 's/^[0-9]+$/\0\.0/' | sed -re 's/^[0-9]+\.[0-9]+$/\0\.0/' | sed -re 's/^[0-9]+\.[0-9]+\.[0-9]+$/\0\.0/')
|
||||
|
||||
# Generate winres.json to be able to create a syso file which contains
|
||||
# Microsoft Windows Version Information and an icon using go-winres.
|
||||
# https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo-block
|
||||
# https://github.com/tc-hib/go-winres#json-format
|
||||
cat > "./cli/winresources/${BINARY_SHORT_NAME}/winres.json" << EOL
|
||||
{
|
||||
"RT_GROUP_ICON": {
|
||||
"#1": {
|
||||
"0409": "../../winresources/docker.ico"
|
||||
}
|
||||
},
|
||||
"RT_MANIFEST": {
|
||||
"#1": {
|
||||
"0409": {
|
||||
"identity": {},
|
||||
"description": "Docker Engine",
|
||||
"minimum-os": "vista",
|
||||
"execution-level": "",
|
||||
"ui-access": false,
|
||||
"auto-elevate": false,
|
||||
"dpi-awareness": "unaware",
|
||||
"disable-theming": false,
|
||||
"disable-window-filtering": false,
|
||||
"high-resolution-scrolling-aware": false,
|
||||
"ultra-high-resolution-scrolling-aware": false,
|
||||
"long-path-aware": false,
|
||||
"printer-driver-isolation": false,
|
||||
"gdi-scaling": false,
|
||||
"segment-heap": false,
|
||||
"use-common-controls-v6": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"RT_MESSAGETABLE": {
|
||||
"#1": {
|
||||
"0409": "../../winresources/event_messages.bin"
|
||||
}
|
||||
},
|
||||
"RT_VERSION": {
|
||||
"#1": {
|
||||
"0409": {
|
||||
"fixed": {
|
||||
"file_version": "$(quadVersionNum "$VERSION_QUAD" 1).$(quadVersionNum "$VERSION_QUAD" 2).$(quadVersionNum "$VERSION_QUAD" 3).$(quadVersionNum "$VERSION_QUAD" 4)",
|
||||
"product_version": "$(quadVersionNum "$VERSION_QUAD" 1).$(quadVersionNum "$VERSION_QUAD" 2).$(quadVersionNum "$VERSION_QUAD" 3).$(quadVersionNum "$VERSION_QUAD" 4)",
|
||||
"type": "Unknown"
|
||||
},
|
||||
"info": {
|
||||
"0000": {
|
||||
"CompanyName": "${PACKAGER_NAME}",
|
||||
"FileVersion": "${VERSION}",
|
||||
"LegalCopyright": "Copyright © 2015-$(date +'%Y') Docker Inc.",
|
||||
"OriginalFileName": "$(basename "${BINARY_FULLNAME}")",
|
||||
"ProductName": "${PRODUCT}",
|
||||
"ProductVersion": "${VERSION}",
|
||||
"SpecialBuild": "${GITCOMMIT}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOL
|
||||
(
|
||||
set -x
|
||||
cat "./cli/winresources/${BINARY_SHORT_NAME}/winres.json"
|
||||
)
|
||||
|
||||
# Create winresources package stub if removed while using tmpfs in Dockerfile
|
||||
if [ ! -f "./cli/winresources/${BINARY_SHORT_NAME}/winresources.go" ]; then
|
||||
echo "package winresources" > "./cli/winresources/${BINARY_SHORT_NAME}/winresources.go"
|
||||
fi
|
|
@ -1,38 +0,0 @@
|
|||
// Application icon
|
||||
1 ICON "dockerd.ico"
|
||||
|
||||
// Windows executable manifest
|
||||
1 24 /* RT_MANIFEST */ "dockerd.exe.manifest"
|
||||
|
||||
// Version information
|
||||
1 VERSIONINFO
|
||||
|
||||
#ifdef DOCKER_VERSION_QUAD
|
||||
FILEVERSION DOCKER_VERSION_QUAD
|
||||
PRODUCTVERSION DOCKER_VERSION_QUAD
|
||||
#endif
|
||||
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "000004B0"
|
||||
BEGIN
|
||||
VALUE "ProductName", DOCKER_NAME
|
||||
|
||||
#ifdef DOCKER_VERSION
|
||||
VALUE "FileVersion", DOCKER_VERSION
|
||||
VALUE "ProductVersion", DOCKER_VERSION
|
||||
#endif
|
||||
|
||||
#ifdef DOCKER_COMMIT
|
||||
VALUE "OriginalFileName", DOCKER_COMMIT
|
||||
#endif
|
||||
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0000, 0x04B0
|
||||
END
|
||||
END
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<description>Docker</description>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!-- Windows Vista -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
|
@ -1,4 +0,0 @@
|
|||
#define DOCKER_NAME "Docker Engine"
|
||||
|
||||
#include "common.rc"
|
||||
#include "event_messages.rc"
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
|
||||
Package winresources is used to embed Windows resources into dockerd.exe.
|
||||
These resources are used to provide
|
||||
|
||||
* Version information
|
||||
* An icon
|
||||
* A Windows manifest declaring Windows version support
|
||||
|
||||
The resource object files are generated in hack/make/.go-autogen from
|
||||
source files in hack/make/.resources-windows. This occurs automatically
|
||||
when you run hack/make.sh.
|
||||
|
||||
These object files are picked up automatically by go build when this package
|
||||
is included.
|
||||
|
||||
*/
|
||||
package winresources
|
Loading…
Reference in a new issue