-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (49 loc) · 1.54 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
PROJECT=gotoolbox
ORGANIZATION=gophergala
REGISTRY = registry.giantswarm.io
USERNAME := $(shell swarm user)
SOURCE := $(shell find . -name '*.go')
GOPATH := $(shell pwd)/.gobuild
PROJECT_PATH := $(GOPATH)/src/github.com/$(ORGANIZATION)
GOOS := linux
GOARCH := amd64
.PHONY=all clean deps $(PROJECT) swarm-up docker-build docker-push docker-pull
all: deps $(PROJECT)
clean:
rm -rf $(GOPATH) $(PROJECT)
deps: .gobuild
.gobuild:
mkdir -p $(PROJECT_PATH)
cd $(PROJECT_PATH) && ln -s ../../../.. $(PROJECT)
# Fetch private packages first (so `go get` skips them later)
# git clone git@github.com:gophergala/gotoolbox.git $(PROJECT_PATH)/gotoolbox
# Fetch public packages
GOPATH=$(GOPATH) go get -d github.com/codegangsta/controller
GOPATH=$(GOPATH) go get -d github.com/codegangsta/negroni
GOPATH=$(GOPATH) go get -d github.com/gorilla/mux
GOPATH=$(GOPATH) go get -d github.com/$(ORGANIZATION)/$(PROJECT)
$(PROJECT): $(SOURCE)
echo Building for $(GOOS)/$(GOARCH)
docker run \
--rm \
-it \
-v $(shell pwd):/usr/code \
-e GOPATH=/usr/code/.gobuild \
-e GOOS=$(GOOS) \
-e GOARCH=$(GOARCH) \
-w /usr/code \
golang:1.3.1-cross \
go build -a -o $(PROJECT)
fig-up: $(PROJECT)
fig build
fig up
docker-build: $(PROJECT)
docker build -t $(REGISTRY)/$(USERNAME)/$(PROJECT) .
docker-push: docker-build
docker push $(REGISTRY)/$(USERNAME)/$(PROJECT)
docker-pull:
docker pull $(REGISTRY)/$(USERNAME)/$(PROJECT)
swarm-delete:
swarm delete $(PROJECT)
swarm-up: docker-push
swarm up swarm.json --var=username=$(USERNAME)