support linux and windows bin files.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-03-27 20:20:57 +08:00
parent 9c8c0e08df
commit 96c04cb7a1
3 changed files with 41 additions and 0 deletions

1
.gitignore vendored
View File

@ -26,3 +26,4 @@ _testmain.go
gin-bin
key.pem
config.yaml
bin/*

26
Makefile Normal file
View File

@ -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/*

14
docker/Dockerfile.build Normal file
View File

@ -0,0 +1,14 @@
FROM golang:1.6
MAINTAINER Bo-Yi Wu <appleboy.tw@gmail.com>
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