Commit Graph

17 Commits

Author SHA1 Message Date
CrazyMax 6f799c1a1c
dockerfile: llvm needed on debian for cross comp
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-07-28 22:49:07 +02:00
CrazyMax 87b085c8cd
missing DWARF symbol table
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-07-25 11:27:09 +02:00
Sebastiaan van Stijn 8fd92f1866
scripts/build: make sure build-time is in UTC
Before this:

    SOURCE_DATE_EPOCH=1606660000 DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    ...
    + go build -o build/docker-darwin-amd64 -tags ' osusergo pkcs11' -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T15:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.2-590-g090dd58dc"' -buildmode=pie github.com/docker/cli/cmd/docker
    ...

    make -f docker.Makefile shell
    SOURCE_DATE_EPOCH=1606660000 make binary
    ...
    + go build -o build/docker-linux-amd64 -tags  -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T14:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.0-dev"' github.com/docker/cli/cmd/docker
    ...

Notice that `version.BuildTime` is `2020-11-29T15:26:40Z` outside the container,
and `2020-11-29T14:26:40Z` inside.

After this:

    SOURCE_DATE_EPOCH=1606660000 DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    ...
    + go build -o build/docker-darwin-amd64 -tags ' osusergo pkcs11' -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T14:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.2-590-g090dd58dc.m"' -buildmode=pie github.com/docker/cli/cmd/docker
    ...

    make -f docker.Makefile shell
    SOURCE_DATE_EPOCH=1606660000 make binary
    ...
    + go build -o build/docker-linux-amd64 -tags  -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T14:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.0-dev"' github.com/docker/cli/cmd/docker
    ...

Notice that `version.BuildTime` is `2020-11-29T14:26:40Z` both outside and inside
the container.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-06 11:30:55 +02:00
Sebastiaan van Stijn 72ed7bd3e9
scripts/build: fix date formatting on macOS
This was introduced in 9d40c7464e, which added
support for `SOURCE_DATE_EPOCH` to override the build-time.

macOS uses the BSD flavor of `date`, which does not support the `--date` option
to set a custom time.

Before this:

    DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    ./scripts/build/binary
    date: illegal option -- -
    usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]

After this:

    DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    ./scripts/build/binary
    Building static docker-darwin-amd64
    + go build -o build/docker-darwin-amd64 -tags ' osusergo pkcs11' -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=a4b6fe16a" -X "github.com/docker/cli/cli/version.BuildTime=2022-04-06T10:57:25Z" -X "github.com/docker/cli/cli/version.Version=20.10.2-589-ga4b6fe16a.m"' -buildmode=pie github.com/docker/cli/cmd/docker
    ...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-06 11:30:19 +02:00
Sebastiaan van Stijn 391e6ad944
use GO_LDFLAGS instead of LDFLAGS to prevent inheriting unrelated options
When building on Fedora 36, the build failed. I suspect this is because the
rpm tools also set LDFLAGS, but with options that cannot be used;

    GO_LINKMODE=dynamic
    + ./scripts/build/binary
      /go/src/github.com/docker/cli ~/rpmbuild/BUILD/src
      Building dynamic docker-linux-arm64
      + go build -o build/docker-linux-arm64 -tags ' pkcs11' -ldflags '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -Wl,-dT,/root/rpmbuild/BUILD/src/.package_note-docker-ce-cli-0.0.0.20220330082637.68cad50-0.fc36.aarch64.ld -w -X "github.com/docker/cli/cli/version.GitCommit=68cad50" -X "github.com/docker/cli/cli/version.BuildTime=2022-03-30T20:05:36Z" -X "github.com/docker/cli/cli/version.Version=0.0.0-20220330082637-68cad50" -X "github.com/docker/cli/cli/version.PlatformName=Docker Engine - Community"' -buildmode=pie github.com/docker/cli/cmd/docker
    # github.com/docker/cli/cmd/docker
    flag provided but not defined: -Wl,-z,relro
    usage: link [options] main.o

This patch changes the variable we use to `GO_LDFLAGS`, taking a similar approach
as containerd, and various other projects using this name: https://grep.app/search?q=GO_LDFLAGS

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-31 10:30:56 +02:00
Sebastiaan van Stijn e20572d047
scripts/build: make sure osusergo is set for static with CGO enabled
Our previous CI probably did not cross-compile for s390x and ppc64le,
and therefore did not get these errors; the scripts/build/.variables
file sets CGO_ENABLED=1 for amd64|arm64|arm|s390x architectures if
it's not set;
87b8e57868/scripts/build/.variables (L34-L46)

When compiling statically with CGO enabled, we must have osusergo
enabled as well, so set it accordingly, to prevent;

    #53 [linux/amd64 build 2/2] RUN --mount=type=bind,target=.,ro     --mount=type=cache,target=/root/.cache     --mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk     --mount=type=tmpfs,target=cli/winresources     xx-go --wrap &&     TARGET=/out ./scripts/build/binary &&     xx-verify $([ "static" = "static" ] && echo "--static") /out/docker
    #53 953.6 # github.com/docker/cli/cmd/docker
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000022.o: in function `New':
    #53 953.6 /go/src/github.com/docker/cli/vendor/github.com/miekg/pkcs11/pkcs11.go:75: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000018.o: in function `mygetgrouplist':
    #53 953.6 /usr/local/go/src/os/user/getgrouplist_unix.go:18: warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000017.o: in function `mygetgrgid_r':
    #53 953.6 /usr/local/go/src/os/user/cgo_lookup_unix.go:40: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000017.o: in function `mygetgrnam_r':
    #53 953.6 /usr/local/go/src/os/user/cgo_lookup_unix.go:45: warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000017.o: in function `mygetpwnam_r':
    #53 953.6 /usr/local/go/src/os/user/cgo_lookup_unix.go:35: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000017.o: in function `mygetpwuid_r':
    #53 953.6 /usr/local/go/src/os/user/cgo_lookup_unix.go:30: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    #53 953.6 /usr/bin/s390x-linux-gnu-ld: /tmp/go-link-2402600021/000004.o: in function `_cgo_3c1cec0c9a4e_C2func_getaddrinfo':
    #53 953.6 /tmp/go-build/cgo-gcc-prolog:58: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-26 15:49:05 +01:00
CrazyMax 62ea2bf1aa
GitHub Actions e2e tests
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-11-17 17:18:25 +01:00
Brian Goff 43dc024002
Merge pull request #2855 from Foxboron/morten/reprobuilds 2021-07-23 09:41:51 -07:00
Tonis Tiigi 26b633d37b set default version from git
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-04-06 00:21:10 -07:00
Tonis Tiigi 6423da8dcd dockerfile based binary building
Using cross compilation toolchains that work from any platform
Adds darwin/arm64 support and bake targets. Static and dynamic
binary targets are available, both with glibc and musl.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-04-06 00:20:21 -07:00
Morten Linderud 9d40c7464e
scripts/build/.variables: Support SOURCE_DATE_EPOCH
Repeated builds of docker is currently unreproducible as the embedded
time does not support SOURCE_DATE_EPOCH. This patch ensures we check for
the defined variable before utilizing current date.

This has been fixed previously with manpages as well

2d7091aaeb

Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-11-29 16:07:46 +01:00
Sebastiaan van Stijn ef37a8a57c
Fix "make build" (non-containerized) on macOS
macOS doesn't ship with the GNU version of `date`, which
causes the command to fail if the `--rfc-3339 ns` format option
is used.

Given that we don't need the build-time with nanosecond precision,
this patch changes the format used, so that the CLI binary can be
built on the host (outside of a container);

Before this change, `make binary` would fail:

    DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    WARNING: binary creates a Linux executable. Use cross for macOS or Windows.
    ./scripts/build/binary
    make: *** [binary] Error 1

With this change, the binary can be built on the host:

    DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    WARNING: binary creates a Linux executable. Use cross for macOS or Windows.
    ./scripts/build/binary
    Building statically linked build/docker-darwin-amd64

While the previous version formatted (and parsed) the date with nanoseconds precision,
that level of precision is not actually used;

```go
func reformatDate(buildTime string) string {
	t, errTime := time.Parse(time.RFC3339Nano, buildTime)
	if errTime == nil {
		return t.Format(time.ANSIC)
	}
	return buildTime
}
```

Both the old, and new input will yield the same output:

```go
fmt.Println(reformatDate("2019-12-31T13:41:44.846741804+00:00"))
// Tue Dec 31 13:41:44 2019

fmt.Println(reformatDate("2019-12-31T13:41:44Z"))
// Tue Dec 31 13:41:44 2019
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-12-31 15:06:11 +01:00
Brian Goff 15130e3043 Support GOARM and windows .exe in binary target
This just makes it easier to build a targeted binary for the
goos/goach/goarm version.

This of course will not work for all cases but is nice to get things
going.
Specifically cross-compiling pkcs for yubikey support requires some
extra work whichis not tackled here.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2019-05-06 10:43:18 -07:00
Ian Campbell 20c19830a9 Move versioning variables to a separate package.
This helps to avoid circular includes, by separating the pure data out from the
actual functionality in the cli subpackage, allowing other code which is
imported to access the data.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-01-29 11:26:40 +00:00
Tibor Vass 5f4c5f8bb6 Add platform and its components to docker version output
The Server section of version output is now composed of an Engine
component and potentially more, based on what the /version endpoint
returns.

Signed-off-by: Tibor Vass <tibor@docker.com>
2017-12-07 02:04:10 +01:00
Daniel Nephin b7b7d784d8 Remove gox, add support for s390x
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-30 16:01:21 -04:00
Daniel Nephin a787cbc93b Support building a dynbinary
Cleanup dynbinary and binary builds

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-12 13:34:06 -04:00