Skip to content

Commit 21f4bd7

Browse files
committed
Update cross-binary script
Add support for more arch too and remove the use of `gox`. Signed-off-by: Vincent Demeester <[email protected]>
1 parent a565564 commit 21f4bd7

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

Diff for: Dockerfile

+1-9
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,10 @@ RUN apt-get update && \
99
easy_install pip && pip install virtualenv
1010

1111
# Install build dependencies
12-
RUN go get github.com/mitchellh/gox && \
13-
go get github.com/aktau/github-release && \
12+
RUN go get github.com/aktau/github-release && \
1413
go get golang.org/x/tools/cmd/cover && \
1514
go get github.com/golang/lint/golint
1615

17-
# Compile Go for cross compilation
18-
ENV DOCKER_CROSSPLATFORMS \
19-
linux/386 linux/arm \
20-
darwin/amd64 darwin/386 \
21-
freebsd/amd64 freebsd/386 freebsd/arm \
22-
windows/amd64 windows/386
23-
2416
# Which docker version to test on and what default one to use
2517
ENV DOCKER_VERSIONS 1.9.1 1.10.3 1.11.0
2618
ENV DEFAULT_DOCKER_VERSION 1.10.3

Diff for: script/cross-binary

+23-8
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,38 @@
22
set -e
33

44
if [ -z "$1" ]; then
5-
OS_PLATFORM_ARG=(-os="darwin linux windows")
5+
# Remove windows platform because of
6+
# https://github.com/mailgun/log/issues/10
7+
OS_PLATFORM_ARG=(linux windows darwin freebsd)
68
else
79
OS_PLATFORM_ARG=($1)
810
fi
911

1012
if [ -z "$2" ]; then
11-
OS_ARCH_ARG=(-arch="386 amd64 arm")
13+
OS_ARCH_ARG=(386 amd64 arm)
1214
else
1315
OS_ARCH_ARG=($2)
1416
fi
1517

1618
# Get rid of existing binaries
17-
rm -f libcompose-cli*
19+
rm -f bundles/libcompose-cli*
1820

1921
# Build binaries
20-
gox "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" \
21-
-output="bundles/libcompose-cli_{{.OS}}-{{.Arch}}" \
22-
-ldflags="-w -X github.com/docker/libcompose/version.GITCOMMIT=`git rev-parse --short HEAD`" \
23-
./cli/main
24-
22+
for OS in ${OS_PLATFORM_ARG[@]}; do
23+
for ARCH in ${OS_ARCH_ARG[@]}; do
24+
OUTPUT_BIN="bundles/libcompose-cli_$OS-$ARCH"
25+
if test "$ARCH" = "arm"; then
26+
if test "$OS" = "windows" || test "$OS" = "darwin"; then
27+
# windows/arm and darwin/arm does not compile without cgo :-|
28+
continue
29+
fi
30+
fi
31+
if test "$OS" = "windows"; then
32+
OUTPUT_BIN="${OUTPUT_BIN}.exe"
33+
fi
34+
echo "Building binary for $OS/$ARCH..."
35+
GOARCH=$ARCH GOOS=$OS CGO_ENABLED=0 go build \
36+
-ldflags="-w -X github.com/docker/libcompose/version.GITCOMMIT=`git rev-parse --short HEAD`" \
37+
-o ${OUTPUT_BIN} ./cli/main
38+
done
39+
done

0 commit comments

Comments
 (0)