Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1512 from imikushin/build-on-machine
Browse files Browse the repository at this point in the history
Add support for building Docker Machine binaries remotely (without bind mount)
  • Loading branch information
nathanleclaire committed Aug 20, 2015
2 parents 52dc573 + 3c1caa5 commit c02b1c4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ run:

If you have any questions we're in #docker-machine on Freenode.

## Remote Build

You can use Machine to build Machine:

$ GOOS=darwin GOARCH=amd64 make remote

The difference is this works even if you don't have local docker daemon, but
instead a docker host that you [set up using Machine](https://github.com/docker/machine).

## Unit Tests

To run the unit tests for the whole project, using the following script:
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

default: build

remote: build-remote

test:
script/test

Expand All @@ -16,6 +18,9 @@ validate: validate-dco validate-gofmt test
build: clean
script/build

build-remote: clean
script/build-remote

clean:
rm -f docker-machine_*
rm -rf Godeps/_workspace/pkg
38 changes: 38 additions & 0 deletions script/build-remote
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -e

BUILD_IMAGE_NAME="docker-machine-build"
GOOS=${GOOS:-"darwin linux windows"}
GOARCH=${GOARCH:-"386 amd64 arm"}

docker build -t ${BUILD_IMAGE_NAME} .

BUILD_CONTAINER=$(docker run -d \
${BUILD_IMAGE_NAME} \
gox \
-os "$GOOS" \
-arch "$GOARCH" \
-output="docker-machine_{{.OS}}-{{.Arch}}" \
-ldflags="-w -X github.com/docker/machine/version.GitCommit `git rev-parse --short HEAD`")
cleanup_container() {
docker rm -v ${BUILD_CONTAINER}
}
trap cleanup_container EXIT

docker logs -f ${BUILD_CONTAINER} &
BUILD_STATUS=$(docker wait ${BUILD_CONTAINER})
if [[ ${BUILD_STATUS} != 0 ]]; then exit ${BUILD_STATUS}; fi

BUILT_IMAGE=$(docker commit ${BUILD_CONTAINER})
cleanup_image() {
cleanup_container
docker rmi ${BUILT_IMAGE}
}
trap cleanup_image EXIT

echo "Copying built binaries:"
for f in $(docker run --rm ${BUILT_IMAGE} sh -c 'echo docker-machine_*'); do
echo " "${f}
docker cp ${BUILD_CONTAINER}:/go/src/github.com/docker/machine/${f} ./
done
echo Done

0 comments on commit c02b1c4

Please sign in to comment.