mirror of https://github.com/docker/cli.git
osx cross
Fix CI build Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
84a77889c3
commit
a408fb0a61
16
circle.yml
16
circle.yml
|
@ -15,26 +15,34 @@ jobs:
|
||||||
name: "Lint"
|
name: "Lint"
|
||||||
command: |
|
command: |
|
||||||
if [ "$CIRCLE_NODE_INDEX" != "0" ]; then exit; fi
|
if [ "$CIRCLE_NODE_INDEX" != "0" ]; then exit; fi
|
||||||
docker build -f dockerfiles/Dockerfile.lint --tag cli-linter .
|
dockerfile=dockerfiles/Dockerfile.lint
|
||||||
|
echo "COPY . ." >> $dockerfile
|
||||||
|
docker build -f $dockerfile --tag cli-linter .
|
||||||
docker run cli-linter
|
docker run cli-linter
|
||||||
- run:
|
- run:
|
||||||
name: "Cross"
|
name: "Cross"
|
||||||
command: |
|
command: |
|
||||||
if [ "$CIRCLE_NODE_INDEX" != "1" ]; then exit; fi
|
if [ "$CIRCLE_NODE_INDEX" != "1" ]; then exit; fi
|
||||||
docker build -f dockerfiles/Dockerfile.ci --tag cli-builder .
|
dockerfile=dockerfiles/Dockerfile.cross
|
||||||
|
echo "COPY . ." >> $dockerfile
|
||||||
|
docker build -f $dockerfile --tag cli-builder .
|
||||||
docker run --name cross cli-builder make cross
|
docker run --name cross cli-builder make cross
|
||||||
docker cp cross:/go/src/github.com/docker/cli/build /work/build
|
docker cp cross:/go/src/github.com/docker/cli/build /work/build
|
||||||
- run:
|
- run:
|
||||||
name: "Unit Test"
|
name: "Unit Test"
|
||||||
command: |
|
command: |
|
||||||
if [ "$CIRCLE_NODE_INDEX" != "2" ]; then exit; fi
|
if [ "$CIRCLE_NODE_INDEX" != "2" ]; then exit; fi
|
||||||
docker build -f dockerfiles/Dockerfile.ci --tag cli-builder .
|
dockerfile=dockerfiles/Dockerfile.dev
|
||||||
|
echo "COPY . ." >> $dockerfile
|
||||||
|
docker build -f $dockerfile --tag cli-builder .
|
||||||
docker run cli-builder make test
|
docker run cli-builder make test
|
||||||
- run:
|
- run:
|
||||||
name: "Validate Vendor and Code Generation"
|
name: "Validate Vendor and Code Generation"
|
||||||
command: |
|
command: |
|
||||||
if [ "$CIRCLE_NODE_INDEX" != "3" ]; then exit; fi
|
if [ "$CIRCLE_NODE_INDEX" != "3" ]; then exit; fi
|
||||||
docker build -f dockerfiles/Dockerfile.ci --tag cli-builder .
|
dockerfile=dockerfiles/Dockerfile.dev
|
||||||
|
echo "COPY . ." >> $dockerfile
|
||||||
|
docker build -f $dockerfile --tag cli-builder .
|
||||||
docker run cli-builder make -B vendor compose-jsonschema
|
docker run cli-builder make -B vendor compose-jsonschema
|
||||||
|
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
|
|
|
@ -12,7 +12,7 @@ MOUNTS = -v `pwd`:/go/src/github.com/docker/cli
|
||||||
# build docker image (dockerfiles/Dockerfile.build)
|
# build docker image (dockerfiles/Dockerfile.build)
|
||||||
.PHONY: build_docker_image
|
.PHONY: build_docker_image
|
||||||
build_docker_image:
|
build_docker_image:
|
||||||
@docker build -q -t $(DEV_DOCKER_IMAGE_NAME) -f ./dockerfiles/Dockerfile.build .
|
@docker build -q -t $(DEV_DOCKER_IMAGE_NAME) -f ./dockerfiles/Dockerfile.dev .
|
||||||
|
|
||||||
# build docker image having the linting tools (dockerfiles/Dockerfile.lint)
|
# build docker image having the linting tools (dockerfiles/Dockerfile.lint)
|
||||||
.PHONY: build_linter_image
|
.PHONY: build_linter_image
|
||||||
|
@ -25,10 +25,11 @@ build_cross_image:
|
||||||
|
|
||||||
|
|
||||||
# build executable using a container
|
# build executable using a container
|
||||||
.PHONY: build
|
binary: build_docker_image
|
||||||
build: build_docker_image
|
|
||||||
@echo "WARNING: this will drop a Linux executable on your host (not a macOS or Windows one)"
|
@echo "WARNING: this will drop a Linux executable on your host (not a macOS or Windows one)"
|
||||||
@docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make build
|
@docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make binary
|
||||||
|
|
||||||
|
build: binary
|
||||||
|
|
||||||
# clean build artifacts using a container
|
# clean build artifacts using a container
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
@ -43,7 +44,7 @@ test: build_docker_image
|
||||||
# build the CLI for multiple architectures using a container
|
# build the CLI for multiple architectures using a container
|
||||||
.PHONY: cross
|
.PHONY: cross
|
||||||
cross: build_docker_image
|
cross: build_docker_image
|
||||||
@docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make cross
|
@docker run --rm $(MOUNTS) $(CROSS_IMAGE_NAME) make cross
|
||||||
|
|
||||||
# start container in interactive mode for in-container development
|
# start container in interactive mode for in-container development
|
||||||
.PHONY: dev
|
.PHONY: dev
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
#
|
|
||||||
# This Dockerfile makes the docker builder run the tests.
|
|
||||||
# It means that if this Dockerfile can be built successfully,
|
|
||||||
# the tests passed.
|
|
||||||
#
|
|
||||||
# From the repo root dir:
|
|
||||||
# $ docker build -f dockerfiles/Dockerfile.ci .
|
|
||||||
#
|
|
||||||
|
|
||||||
FROM golang:1.8-alpine
|
|
||||||
|
|
||||||
RUN apk add -U git make
|
|
||||||
|
|
||||||
RUN go get github.com/LK4D4/vndr && \
|
|
||||||
cp /go/bin/vndr /usr/bin && \
|
|
||||||
rm -rf /go/src/* /go/pkg/* /go/bin/*
|
|
||||||
|
|
||||||
RUN go get github.com/mitchellh/gox && \
|
|
||||||
cp /go/bin/gox /usr/bin && \
|
|
||||||
rm -rf /go/src/* /go/pkg/* /go/bin/*
|
|
||||||
|
|
||||||
RUN go get github.com/jteeuwen/go-bindata/go-bindata && \
|
|
||||||
cp /go/bin/go-bindata /usr/bin && \
|
|
||||||
rm -rf /go/src/* /go/pkg/* /go/bin/*
|
|
||||||
|
|
||||||
COPY . /go/src/github.com/docker/cli
|
|
||||||
|
|
||||||
ENV CGO_ENABLED=0
|
|
||||||
WORKDIR /go/src/github.com/docker/cli
|
|
|
@ -5,7 +5,7 @@ FROM golang:1.8.1
|
||||||
ARG APT_MIRROR=deb.debian.org
|
ARG APT_MIRROR=deb.debian.org
|
||||||
RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
|
RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update -qq && apt-get install -y -q \
|
||||||
libltdl-dev \
|
libltdl-dev \
|
||||||
gcc-mingw-w64 \
|
gcc-mingw-w64 \
|
||||||
parallel \
|
parallel \
|
||||||
|
@ -15,4 +15,8 @@ RUN go get github.com/mitchellh/gox && \
|
||||||
cp /go/bin/gox /usr/bin && \
|
cp /go/bin/gox /usr/bin && \
|
||||||
rm -rf /go/src/* /go/pkg/* /go/bin/*
|
rm -rf /go/src/* /go/pkg/* /go/bin/*
|
||||||
|
|
||||||
|
COPY dockerfiles/osx-cross.sh /tmp/
|
||||||
|
RUN /tmp/osx-cross.sh
|
||||||
|
ENV PATH /osxcross/target/bin:$PATH
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/docker/cli
|
WORKDIR /go/src/github.com/docker/cli
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
FROM golang:1.8-alpine
|
FROM golang:1.8-alpine
|
||||||
|
|
||||||
RUN apk add -U git make bash
|
RUN apk add -U git make bash coreutils
|
||||||
|
|
||||||
RUN go get github.com/LK4D4/vndr && \
|
RUN go get github.com/LK4D4/vndr && \
|
||||||
cp /go/bin/vndr /usr/bin && \
|
cp /go/bin/vndr /usr/bin && \
|
|
@ -7,6 +7,5 @@ RUN go get -u gopkg.in/alecthomas/gometalinter.v1 && \
|
||||||
gometalinter --install
|
gometalinter --install
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/docker/cli
|
WORKDIR /go/src/github.com/docker/cli
|
||||||
COPY . .
|
|
||||||
ENTRYPOINT ["/usr/local/bin/gometalinter"]
|
ENTRYPOINT ["/usr/local/bin/gometalinter"]
|
||||||
CMD ["--config=gometalinter.json", "./..."]
|
CMD ["--config=gometalinter.json", "./..."]
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Install dependencies required to cross compile osx, then cleanup
|
||||||
|
#
|
||||||
|
# TODO: this should be a separate build stage when CI supports it
|
||||||
|
|
||||||
|
|
||||||
|
set -eu -o pipefail
|
||||||
|
|
||||||
|
PKG_DEPS="patch xz-utils clang"
|
||||||
|
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y -q $PKG_DEPS
|
||||||
|
|
||||||
|
OSX_SDK=MacOSX10.11.sdk
|
||||||
|
OSX_CROSS_COMMIT=a9317c18a3a457ca0a657f08cc4d0d43c6cf8953
|
||||||
|
OSXCROSS_PATH="/osxcross"
|
||||||
|
|
||||||
|
echo "Cloning osxcross"
|
||||||
|
time git clone https://github.com/tpoechtrager/osxcross.git $OSXCROSS_PATH
|
||||||
|
cd $OSXCROSS_PATH
|
||||||
|
git checkout -q $OSX_CROSS_COMMIT
|
||||||
|
|
||||||
|
echo "Downloading OSX SDK"
|
||||||
|
time curl -sSL https://s3.dockerproject.org/darwin/v2/${OSX_SDK}.tar.xz \
|
||||||
|
-o "${OSXCROSS_PATH}/tarballs/${OSX_SDK}.tar.xz"
|
||||||
|
|
||||||
|
echo "Buidling osxcross"
|
||||||
|
UNATTENDED=yes OSX_VERSION_MIN=10.6 ${OSXCROSS_PATH}/build.sh > /dev/null
|
|
@ -6,4 +6,6 @@ export BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
SHELL=/bin/bash parallel ::: \
|
SHELL=/bin/bash parallel ::: \
|
||||||
"$BUILDDIR/linux-cross" \
|
"$BUILDDIR/linux-cross" \
|
||||||
"$BUILDDIR/windows"
|
"$BUILDDIR/windows" \
|
||||||
|
"$BUILDDIR/osx" \
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Build an osx binary from linux
|
||||||
|
#
|
||||||
|
|
||||||
|
set -eu -o pipefail
|
||||||
|
|
||||||
|
source ./scripts/build/.variables
|
||||||
|
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
export GOOS=darwin
|
||||||
|
export GOARCH=amd64
|
||||||
|
export CC=o64-clang
|
||||||
|
export LDFLAGS='-linkmode external -s'
|
||||||
|
export LDFLAGS_STATIC_DOCKER='-extld='${CC}
|
||||||
|
|
||||||
|
# Override TARGET
|
||||||
|
export TARGET="build/docker-$GOOS-$GOARCH"
|
||||||
|
|
||||||
|
go build -o "${TARGET}" -tags pkcs11 --ldflags "${LDFLAGS}" "${SOURCE}"
|
|
@ -13,7 +13,7 @@ export GOOS=windows
|
||||||
export GOARCH=amd64
|
export GOARCH=amd64
|
||||||
|
|
||||||
# Override TARGET
|
# Override TARGET
|
||||||
export TARGET="build/docker-windows-amd64"
|
export TARGET="build/docker-$GOOS-$GOARCH"
|
||||||
|
|
||||||
# TODO: -tags pkcs11
|
# TODO: -tags pkcs11
|
||||||
go build -o "${TARGET}" --ldflags "${LDFLAGS}" "${SOURCE}"
|
go build -o "${TARGET}" --ldflags "${LDFLAGS}" "${SOURCE}"
|
||||||
|
|
Loading…
Reference in New Issue