22# Some uses for short name:
33# - Docker image name
44# - Kubernetes service, rc, pod, secret, volume names
5- SHORT_NAME := example
5+ SHORT_NAME := pkg
66
77# Enable vendor/ directory support.
88export GO15VENDOREXPERIMENT =1
@@ -14,55 +14,14 @@ VERSION := 0.0.1-$(shell date "+%Y%m%d%H%M%S")
1414# Common flags passed into Go's linker.
1515LDFLAGS := "-s -X main.version=${VERSION}"
1616
17- # Docker Root FS
18- BINDIR := ./rootfs
17+ all : build test
1918
20- # Legacy support for DEV_REGISTRY, plus new support for DEIS_REGISTRY.
21- DEV_REGISTRY ?= $(eval docker-machine ip deis) :5000
22- DEIS_REGISTY ?= ${DEV_REGISTRY}
23-
24- # Kubernetes-specific information for RC, Service, and Image.
25- RC := manifests/deis-${SHORT_NAME}-rc.yaml
26- SVC := manifests/deis-${SHORT_NAME}-service.yaml
27- IMAGE := ${DEIS_REGISTRY}/deis/${SHORT_NAME}:${VERSION}
28-
29- all :
30- @echo " Use a Makefile to control top-level building of the project."
31-
32- # This illustrates a two-stage Docker build. docker-compile runs inside of
33- # the Docker environment. Other alternatives are cross-compiling, doing
34- # the build as a `docker build`.
19+ # This builds .a files, which will be placed in $GOPATH/pkg
3520build :
36- mkdir -p ${BINDIR} /bin
37- docker run --rm -v ${PWD} :/app -w /app golang:1.5.1 make docker-compile
38-
39- # For cases where build is run inside of a container.
40- docker-compile :
41- go build -o ${BINDIR} /bin/boot -a -installsuffix cgo -ldflags ${LDFLAGS} boot.go
42-
43- # For cases where we're building from local
44- # We also alter the RC file to set the image name.
45- docker-build :
46- docker build --rm -t ${IMAGE} rootfs
47- perl -pi -e " s|[a-z0-9.:]+\/deis\/${SHORT_NAME} :[0-9a-z-.]+|${IMAGE} |g" ${RC}
48-
49- # Push to a registry that Kubernetes can access.
50- docker-push :
51- docker push ${IMAGE}
52-
53- # Deploy is a Kubernetes-oriented target
54- deploy : kube-service kube-rc
55-
56- # Some things, like services, have to be deployed before pods. This is an
57- # example target. Others could perhaps include kube-secret, kube-volume, etc.
58- kube-service :
59- kubectl create -f ${SVC}
21+ go build ./...
6022
61- # When possible, we deploy with RCs.
62- kube-rc :
63- kubectl create -f ${RC}
23+ test :
24+ go test $(shell glide nv)
6425
65- kube-clean :
66- kubectl delete rc deis-example
6726
68- .PHONY : all build docker-compile kube-up kube-down deploy
27+ .PHONY : all build test
0 commit comments