From 47bb36f27fe937c4ca1b42f9ffbb95021f890b1b Mon Sep 17 00:00:00 2001 From: Karl Isenberg Date: Wed, 18 May 2016 17:26:49 -0700 Subject: [PATCH] Add cross-compiling - Update to Golang 1.6.2 - Use gox for xcompile --- .gitignore | 1 + Makefile | 8 ++++++++ README.md | 9 +++++++-- builder/Dockerfile | 5 +++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 7bd633a..bdd7d75 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ # Build Artifacts /probe +/pkg diff --git a/Makefile b/Makefile index a9e603c..ab8f7f0 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,10 @@ build: @echo "--> Building probe" @godep go build -o probe +build-cross: + @echo "--> Building probe" + gox -osarch="darwin/amd64" -osarch="linux/amd64" -output "pkg/{{.OS}}_{{.Arch}}/{{.Dir}}" + test_banner: @echo "--> Testing probe" @@ -62,3 +66,7 @@ builder: build-docker: @echo "--> Building probe (in karlkfi/probe-builder:${BUILDER_VERSION})" @docker run -v "$(shell pwd):/go/src/github.com/karlkfi/probe" karlkfi/probe-builder:${BUILDER_VERSION} + +build-docker-cross: + @echo "--> Building probe (in karlkfi/probe-builder:${BUILDER_VERSION}) for all platforms" + @docker run -v "$(shell pwd):/go/src/github.com/karlkfi/probe" karlkfi/probe-builder:${BUILDER_VERSION} make restoredeps test build-cross \ No newline at end of file diff --git a/README.md b/README.md index adb8492..6a12fe7 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,12 @@ Build the linux binary in docker (Requires [Docker](https://docs.docker.com/inst make build-docker ``` +Build the Linux and Mac binaries in docker (Requires [Docker](https://docs.docker.com/installation/)): + +``` +make build-docker-cross +``` + Build the docker builder (Requires [Docker](https://docs.docker.com/installation/)): ``` @@ -141,8 +147,7 @@ make builder ### TODO 1. Add SSL certificate validation options (currently ignores cert validity). -2. Upload cross-platform pre-compiled binaries -3. Add configurable DNS caching +2. Add configurable DNS caching ### License diff --git a/builder/Dockerfile b/builder/Dockerfile index 6033c6d..1e86b57 100644 --- a/builder/Dockerfile +++ b/builder/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.4.2-wheezy +FROM golang:1.6.2-wheezy MAINTAINER Karl Isenberg RUN echo "deb-src http://httpredir.debian.org/debian wheezy main" >> /etc/apt/sources.list && \ @@ -10,7 +10,8 @@ RUN echo "deb-src http://httpredir.debian.org/debian wheezy main" >> /etc/apt/so apt-get -y clean RUN go get github.com/tools/godep -RUN go get golang.org/x/tools/cmd/vet +RUN go get github.com/mitchellh/gox +ENV GO15VENDOREXPERIMENT 0 VOLUME ${GOPATH}/src/github.com/karlkfi/probe