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 := builder
66
77# Enable vendor/ directory support.
88export GO15VENDOREXPERIMENT =1
99
1010# SemVer with build information is defined in the SemVer 2 spec, but Docker
1111# doesn't allow +, so we use -.
12- VERSION := 0.0.1-$(shell date "+% Y% m% d% H% M% S")
12+ # VERSION := 0.0.1-$(shell date "+%Y%m%d%H%M%S")
1313
14+ VERSION := 2.0.0
15+ BINARY_DEST_DIR := rootfs/usr/bin
1416# Common flags passed into Go's linker.
1517LDFLAGS := "-s -X main.version=${VERSION}"
16-
18+ BINARIES := extract-domain extract-types extract-version generate-buildhook get-app-config get-app-values publish-release-controller yaml2json-procfile
19+ STANDALONE := extract-types generate-buildhook yaml2json-procfile
1720# Docker Root FS
1821BINDIR := ./rootfs
1922
2023# Legacy support for DEV_REGISTRY, plus new support for DEIS_REGISTRY.
21- DEV_REGISTRY ?= $( eval docker-machine ip deis) :5000
24+ DEV_REGISTRY ?= $$DEV_REGISTRY
2225DEIS_REGISTY ?= ${DEV_REGISTRY}
2326
2427# 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+ RCBP := manifests/deis-bp${SHORT_NAME}-rc.yaml
29+ SVCBP := manifests/deis-bp${SHORT_NAME}-service.yaml
30+ # IMAGEBP := ${DEV_REGISTRY}/deis/bp${SHORT_NAME}:${VERSION}
31+ IMAGEBP := deis/bp${SHORT_NAME}:${VERSION}
32+
33+ RCDF := manifests/deis-df${SHORT_NAME}-rc.yaml
34+ SVCDF := manifests/deis-df${SHORT_NAME}-service.yaml
35+ IMAGEDF := ${DEV_REGISTRY}/deis/df${SHORT_NAME}:${VERSION}
2836
2937all :
3038 @echo " Use a Makefile to control top-level building of the project."
3341# the Docker environment. Other alternatives are cross-compiling, doing
3442# the build as a `docker build`.
3543build :
44+ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a -installsuffix cgo -ldflags ' -s' -o $(BINARY_DEST_DIR ) /builder cli/builder.go || exit 1
3645 mkdir -p ${BINDIR} /bin
3746 docker run --rm -v ${PWD} :/app -w /app golang:1.5.1 make docker-compile
3847
39- build-bpb :
40- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a -installsuffix cgo -ldflags ' -s' -o $(BINARY_DEST_DIR ) /builder cli/builder.go || exit 1
41- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a -installsuffix cgo -ldflags ' -s' -o $(BINARY_DEST_DIR ) /fetcher fetcher/fetcher.go || exit 1
42- @$(call check-static-binary,$(BINARY_DEST_DIR ) /builder)
48+ docker-build-bpb :
49+ cp -r bpbuilder/etcd pkg/
50+ cp bpbuilder/kubectl rootfs/bin/
51+ cp bpbuilder/entrypoint.sh rootfs/
52+ cp bpbuilder/deis-slugbuilder.yaml rootfs/etc/
53+ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags ' -s' -o $(BINARY_DEST_DIR ) /bpbuilder boot.go || exit 1
54+ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags ' -s' -o $(BINARY_DEST_DIR ) /fetcher bpbuilder/fetcher/fetcher.go || exit 1
55+ @$(call check-static-binary,$(BINARY_DEST_DIR ) /bpbuilder)
4356 @$(call check-static-binary,$(BINARY_DEST_DIR ) /fetcher)
4457 for i in $( BINARIES) ; do \
45- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a -installsuffix cgo -ldflags ' -s' -o $(BINARY_DEST_DIR ) /$$ i src/$$ i.go || exit 1; \
58+ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags ' -s' -o $(BINARY_DEST_DIR ) /$$ i pkg/ src/$$ i.go || exit 1; \
4659 done
60+ @echo " Past go compiling"
4761 @for i in $(BINARIES ) ; do \
4862 $(call check-static-binary,$(BINARY_DEST_DIR ) /$$i) ; \
4963 done
50- docker build -t $(IMAGE ) rootfs
64+ docker build -t $(IMAGEBP ) rootfs
65+ perl -pi -e " s|image: [a-z0-9.:]+\/deis\/bp${SHORT_NAME} :[0-9a-z-.]+|image: ${IMAGEBP} |g" ${RCBP}
66+ rm -rf pkg/etcd
67+ rm rootfs/entrypoint.sh
5168# For cases where build is run inside of a container.
52- docker-compile :
53- go build -o ${BINDIR} /bin/boot -a -installsuffix cgo -ldflags ${LDFLAGS} boot.go
5469
55- # For cases where we're building from local
56- # We also alter the RC file to set the image name.
57- docker-build :
58- docker build --rm -t ${IMAGE} rootfs
59- perl -pi -e " s|[a-z0-9.:]+\/deis\/${SHORT_NAME} :[0-9a-z-.]+|${IMAGE} |g" ${RC}
70+ docker-build-dfb :
71+ cp -r dfbuilder/etcd pkg/
72+ cp bpbuilder/entrypoint.sh rootfs/
73+ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a -installsuffix cgo -ldflags ' -s' -o $(BINARY_DEST_DIR ) /dfbuilder boot.go || exit 1
74+ @$(call check-static-binary,$(BINARY_DEST_DIR ) /dfbuilder)
75+ for i in $( BINARIES) ; do \
76+ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a -installsuffix cgo -ldflags ' -s' -o $(BINARY_DEST_DIR ) /$$ i pkg/src/$$ i.go || exit 1; \
77+ done
78+ @for i in $(BINARIES ) ; do \
79+ $(call check-static-binary,$(BINARY_DEST_DIR ) /$$i) ; \
80+ done
81+ docker build -t $(IMAGEDF ) rootfs
82+ perl -pi -e " s|image: [a-z0-9.:]+\/deis\/df${SHORT_NAME} :[0-9a-z-.]+|image: ${IMAGEDF} |g" ${RCDF}
83+ rm -rf pkg/etcd
84+ rm rootfs/entrypoint.sh
85+
6086
6187# Push to a registry that Kubernetes can access.
62- docker-push :
63- docker push ${IMAGE }
88+ docker-push-bp :
89+ docker push ${IMAGEBP }
6490
6591# Deploy is a Kubernetes-oriented target
6692deploy : kube-service kube-rc
@@ -78,3 +104,12 @@ kube-clean:
78104 kubectl delete rc deis-example
79105
80106.PHONY : all build docker-compile kube-up kube-down deploy
107+
108+ define check-static-binary
109+ if file $(1 ) | egrep -q "(statically linked|Mach-O)"; then \
110+ echo ""; \
111+ else \
112+ echo "The binary file $(1 ) is not statically linked. Build canceled"; \
113+ exit 1; \
114+ fi
115+ endef
0 commit comments