mirror of
https://github.com/docker/cli.git
synced 2026-01-13 18:22:35 +03:00
Support building a dynbinary
Cleanup dynbinary and binary builds Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
18
scripts/build/.variables
Executable file
18
scripts/build/.variables
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
|
||||
VERSION=${VERSION:-"unknown-version"}
|
||||
GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)}
|
||||
BUILDTIME=${BUILDTIME:-$(date --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')}
|
||||
|
||||
export LDFLAGS="\
|
||||
-w \
|
||||
-X github.com/docker/cli/cli.GitCommit=${GITCOMMIT} \
|
||||
-X github.com/docker/cli/cli.BuildTime=${BUILDTIME} \
|
||||
-X github.com/docker/cli/cli.Version=${VERSION} \
|
||||
${LDFLAGS:-} \
|
||||
"
|
||||
|
||||
export TARGET="build/docker-$(go env GOHOSTOS)-$(go env GOHOSTARCH)"
|
||||
export SOURCE="github.com/docker/cli/cmd/docker"
|
||||
@@ -1,5 +1,13 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Build a static binary for the host OS/ARCH
|
||||
#
|
||||
|
||||
source ./scripts/build/ldflags
|
||||
set -eu -o pipefail
|
||||
|
||||
go build -o ./build/docker --ldflags "${LDFLAGS}" github.com/docker/cli/cmd/docker
|
||||
source ./scripts/build/.variables
|
||||
|
||||
export CGO_ENABLED=0
|
||||
go build -o "${TARGET}" --ldflags "${LDFLAGS}" "${SOURCE}"
|
||||
|
||||
ln -sf "$(basename ${TARGET})" build/docker
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./scripts/build/ldflags
|
||||
set -eu -o pipefail
|
||||
|
||||
source ./scripts/build/.variables
|
||||
|
||||
# Wow, gox doesn't like extra spaces between these strings...
|
||||
CROSS_OSARCH="\
|
||||
windows/amd64"
|
||||
|
||||
#darwin/amd64 \
|
||||
#linux/amd64 \
|
||||
#linux/arm \
|
||||
|
||||
# Currently broken
|
||||
# linux/ppc64le \
|
||||
|
||||
gox -output build/docker-{{.OS}}-{{.Arch}} \
|
||||
-osarch="linux/arm linux/amd64 darwin/amd64 windows/amd64" \
|
||||
-osarch "${CROSS_OSARCH}" \
|
||||
--ldflags "${LDFLAGS}" \
|
||||
github.com/docker/cli/cmd/docker
|
||||
${SOURCE}
|
||||
|
||||
13
scripts/build/dynbinary
Executable file
13
scripts/build/dynbinary
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Build a dynamically linked binary for the host OS/ARCH
|
||||
#
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
source ./scripts/build/.variables
|
||||
|
||||
export CGO_ENABLED=1
|
||||
go build -o "${TARGET}" -tags pkcs11 --ldflags "${LDFLAGS}" "${SOURCE}"
|
||||
|
||||
ln -sf "$(basename ${TARGET})" build/docker
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
VERSION=${VERSION:-"unknown-version"}
|
||||
GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)}
|
||||
BUILDTIME=${BUILDTIME:-$(date --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')}
|
||||
|
||||
export LDFLAGS="-X github.com/docker/cli/cli.GitCommit=${GITCOMMIT} \
|
||||
-X github.com/docker/cli/cli.BuildTime=${BUILDTIME} \
|
||||
-X github.com/docker/cli/cli.Version=${VERSION} ${LDFLAGS}"
|
||||
Reference in New Issue
Block a user