From 96c04cb7a152052933209ec2fec2e1a18450b2ba Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sun, 27 Mar 2016 20:20:57 +0800 Subject: [PATCH] support linux and windows bin files. Signed-off-by: Bo-Yi Wu --- .gitignore | 1 + Makefile | 26 ++++++++++++++++++++++++++ docker/Dockerfile.build | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 Makefile create mode 100644 docker/Dockerfile.build diff --git a/.gitignore b/.gitignore index f460ba3..e6a2667 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ _testmain.go gin-bin key.pem config.yaml +bin/* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7258142 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +.PHONY: all + +VERSION=0.0.1 + +DEPS := $(wildcard *.go) +BUILD_IMAGE := "gopush-build" + +all: build + +build: clean + for GOOS in darwin linux windows; do \ + for GOARCH in 386 amd64; do \ + GOOS=$$GOOS GOARCH=$$GOARCH go build -ldflags="-w" -o bin/$$GOOS/$$GOARCH/gopush gopush.go; \ + done \ + done + +docker_build: clean + tar -zcvf build.tar.gz gopush.go gopush + docker build -t $(BUILD_IMAGE) -f docker/Dockerfile.build . + docker run $(BUILD_IMAGE) > bin.tar.gz + -rm -rf build.tar.gz + tar -zxvf bin.tar.gz + -rm -rf bin.tar.gz + +clean: + rm -rf build.tar.gz bin.tar.gz bin/* diff --git a/docker/Dockerfile.build b/docker/Dockerfile.build new file mode 100644 index 0000000..e57e8ec --- /dev/null +++ b/docker/Dockerfile.build @@ -0,0 +1,14 @@ +FROM golang:1.6 + +MAINTAINER Bo-Yi Wu + +RUN mkdir -p /tmp/build +Add build.tar.gz /tmp/build/ +WORKDIR /tmp/build +RUN go get -d +RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w" -o bin/linux/amd64/gopush gopush.go +RUN GOOS=darwin GOARCH=amd64 go build -ldflags="-w" -o bin/darwin/amd64/gopush gopush.go +RUN GOOS=windows GOARCH=386 go build -ldflags="-w" -o bin/windows/i386/gopush.exe gopush.go +RUN GOOS=windows GOARCH=amd64 go build -ldflags="-w" -o bin/windows/amd64/gopush.exe gopush.go + +CMD tar -czf - bin