mirror of https://github.com/docker/docs.git
Merge pull request #1686 from nathanleclaire/makefile
Prioritize using make in build, cleanup a few things in build script
This commit is contained in:
commit
627658242d
|
@ -10,17 +10,20 @@ Machine is a part of the [Docker](https://www.docker.com) project, and follows
|
||||||
the same rules and principles. If you're already familiar with the way
|
the same rules and principles. If you're already familiar with the way
|
||||||
Docker does things, you'll feel right at home.
|
Docker does things, you'll feel right at home.
|
||||||
|
|
||||||
Otherwise, go read
|
Otherwise, please read [Docker's contributions
|
||||||
[Docker's contributions guidelines](https://github.com/docker/docker/blob/master/CONTRIBUTING.md).
|
guidelines](https://github.com/docker/docker/blob/master/CONTRIBUTING.md).
|
||||||
|
|
||||||
|
# Building
|
||||||
|
|
||||||
The requirements to build Machine are:
|
The requirements to build Machine are:
|
||||||
|
|
||||||
1. A running instance of Docker
|
1. A running instance of Docker
|
||||||
2. The `bash` shell
|
2. The `bash` shell
|
||||||
|
3. [Make](https://www.gnu.org/software/make/)
|
||||||
|
|
||||||
To build, run:
|
To build, run:
|
||||||
|
|
||||||
$ script/build
|
$ make
|
||||||
|
|
||||||
From the Machine repository's root. Machine will run the build inside of a
|
From the Machine repository's root. Machine will run the build inside of a
|
||||||
Docker container and the compiled binaries will appear in the project directory
|
Docker container and the compiled binaries will appear in the project directory
|
||||||
|
@ -28,21 +31,14 @@ on the host.
|
||||||
|
|
||||||
By default, Machine will run a build which cross-compiles binaries for a variety
|
By default, Machine will run a build which cross-compiles binaries for a variety
|
||||||
of architectures and operating systems. If you know that you are only compiling
|
of architectures and operating systems. If you know that you are only compiling
|
||||||
for a particular architecture and/or operating system, you can speed up
|
for a particular architecture and/or operating system, you can speed up the
|
||||||
compilation by overriding the default argument that the build script passes
|
compile by setting the standard `GOOS` and/or `GOARCH` environment variables to
|
||||||
to [gox](https://github.com/mitchellh/gox). This is very useful if you want
|
deviate from the defaults.
|
||||||
to iterate quickly on a new feature, bug fix, etc.
|
|
||||||
|
|
||||||
For instance, if you only want to compile for use on OS X with the x86_64 arch,
|
For instance, if you only want to compile for use on OS X with the x86_64 arch,
|
||||||
run:
|
run:
|
||||||
|
|
||||||
$ script/build -osarch="darwin/amd64"
|
$ GOOS=darwin GOARCH=amd64 make
|
||||||
|
|
||||||
If you don't need to run the `docker build` to generate the image on each
|
|
||||||
compile, i.e. if you have built the image already, you can skip the image build
|
|
||||||
using the `SKIP_BUILD` environment variable, for instance:
|
|
||||||
|
|
||||||
$ SKIP_BUILD=1 script/build -osarch="darwin/amd64"
|
|
||||||
|
|
||||||
If you have any questions we're in #docker-machine on Freenode.
|
If you have any questions we're in #docker-machine on Freenode.
|
||||||
|
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -1,6 +1,6 @@
|
||||||
.PHONY: all test validate-dco validate-gofmt validate build
|
.PHONY: test validate-dco validate-gofmt
|
||||||
|
|
||||||
all: validate test build
|
default: build
|
||||||
|
|
||||||
test:
|
test:
|
||||||
script/test
|
script/test
|
||||||
|
@ -11,8 +11,11 @@ validate-dco:
|
||||||
validate-gofmt:
|
validate-gofmt:
|
||||||
script/validate-gofmt
|
script/validate-gofmt
|
||||||
|
|
||||||
validate: validate-dco validate-gofmt
|
validate: validate-dco validate-gofmt test
|
||||||
|
|
||||||
build:
|
build: clean
|
||||||
script/build
|
script/build
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f docker-machine_*
|
||||||
|
rm -rf Godeps/_workspace/pkg
|
||||||
|
|
34
script/build
34
script/build
|
@ -1,24 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
BUILD_IMAGE_NAME="docker-machine-build"
|
||||||
OS_PLATFORM_ARG=(-os="darwin linux windows")
|
GOOS=${GOOS:-"darwin linux windows"}
|
||||||
else
|
GOARCH=${GOARCH:-"386 amd64 arm"}
|
||||||
OS_PLATFORM_ARG=($1)
|
|
||||||
|
# Build image for compilation if not detected
|
||||||
|
if [[ $(docker images -q ${BUILD_IMAGE_NAME} | wc -l) -ne 1 ]]; then
|
||||||
|
docker build -t ${BUILD_IMAGE_NAME} .
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
docker run --rm \
|
||||||
OS_ARCH_ARG=(-arch="386 amd64 arm")
|
-v `pwd`:/go/src/github.com/docker/machine \
|
||||||
else
|
${BUILD_IMAGE_NAME} \
|
||||||
OS_ARCH_ARG=($2)
|
gox \
|
||||||
fi
|
-os "$GOOS" \
|
||||||
|
-arch "$GOARCH" \
|
||||||
# Build Docker image unless we opt out of it
|
-output="docker-machine_{{.OS}}-{{.Arch}}" \
|
||||||
if [[ -z "$SKIP_BUILD" ]]; then
|
-ldflags="-w -X github.com/docker/machine/version.GitCommit `git rev-parse --short HEAD`"
|
||||||
docker build -t docker-machine .
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get rid of existing binaries
|
|
||||||
rm -f docker-machine*
|
|
||||||
rm -rf Godeps/_workspace/pkg
|
|
||||||
docker run --rm -v `pwd`:/go/src/github.com/docker/machine docker-machine gox "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" -output="docker-machine_{{.OS}}-{{.Arch}}" -ldflags="-w -X github.com/docker/machine/version.GitCommit `git rev-parse --short HEAD`"
|
|
||||||
|
|
Loading…
Reference in New Issue