Merge pull request #15 from adamreese/feat/docker-build

feat(Makefile): add docker build tooling
pull/613/head
Adam Reese 9 years ago
commit fdede38769

2
.gitignore vendored

@ -1,4 +1,6 @@
.coverage/ .coverage/
bin/ bin/
rootfs/helm
rootfs/tiller
vendor/ vendor/
_proto/*.pb.go _proto/*.pb.go

@ -1,22 +1,50 @@
GO ?= go DOCKER_REGISTRY :=
IMAGE_PREFIX ?= helm
SHORT_NAME ?= tiller
# go option
GO ?= go
GOARCH ?= $(shell go env GOARCH)
GOOS ?= $(shell go env GOOS)
PKG := $(shell glide novendor) PKG := $(shell glide novendor)
TAGS := TAGS :=
TESTS := . TESTS := .
TESTFLAGS := TESTFLAGS :=
LDFLAGS := LDFLAGS :=
GOFLAGS :=
BINDIR := ./bin
BINARIES := helm tiller
BINARIES := helm tiller include versioning.mk
.PHONY: all .PHONY: all
all: build all: build
.PHONY: build .PHONY: build
build: GOFLAGS += -v -a -installsuffix cgo
build: build:
@for i in $(BINARIES); do \ @for i in $(BINARIES); do \
$(GO) build -o ./bin/$$i -v $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$$i || exit 1; \ CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build -o $(BINDIR)/$$i $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$$i || exit 1; \
done done
.PHONY: check-docker
check-docker:
@if [ -z $$(which docker) ]; then \
echo "Missing \`docker\` client which is required for development"; \
exit 2; \
fi
.PHONY: docker-binary
docker-binary: GOOS = linux
docker-binary: GOARCH = amd64
docker-binary: BINDIR = ./rootfs
docker-binary: build
.PHONY: docker-build
docker-build: check-docker docker-binary
docker build --rm -t ${IMAGE} rootfs
docker tag -f ${IMAGE} ${MUTABLE_IMAGE}
.PHONY: test .PHONY: test
test: TESTFLAGS += -race -v test: TESTFLAGS += -race -v
test: test-style test: test-style
@ -32,7 +60,7 @@ test-style:
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf ./bin @rm -rf $(BINDIR)
.PHONY: coverage .PHONY: coverage
coverage: coverage:

@ -0,0 +1,8 @@
FROM alpine:3.3
COPY . /
EXPOSE 44134
CMD ["/tiller"]

@ -0,0 +1,27 @@
# RootFS
This directory stores all files that should be copied to the rootfs of a
Docker container. The files should be stored according to the correct
directory structure of the destination container. For example:
```
rootfs/bin -> /bin
rootfs/usr/local/share -> /usr/local/share
```
## Dockerfile
A Dockerfile in the rootfs is used to build the image. Where possible,
compilation should not be done in this Dockerfile, since we are
interested in deploying the smallest possible images.
Example:
```Dockerfile
FROM alpine:3.2
COPY . /
ENTRYPOINT ["/usr/local/bin/boot"]
```

@ -0,0 +1,22 @@
MUTABLE_VERSION ?= canary
VERSION ?= git-$(shell git rev-parse --short HEAD)
IMAGE := ${DOCKER_REGISTRY}${IMAGE_PREFIX}/${SHORT_NAME}:${VERSION}
MUTABLE_IMAGE := ${DOCKER_REGISTRY}${IMAGE_PREFIX}/${SHORT_NAME}:${MUTABLE_VERSION}
info:
@echo "Build tag: ${VERSION}"
@echo "Registry: ${DOCKER_REGISTRY}"
@echo "Immutable tag: ${IMAGE}"
@echo "Mutable tag: ${MUTABLE_IMAGE}"
.PHONY: docker-push
docker-push: docker-mutable-push docker-immutable-push
.PHONY: docker-immutable-push
docker-immutable-push:
docker push ${IMAGE}
.PHONY: docker-mutable-push
docker-mutable-push:
docker push ${MUTABLE_IMAGE}
Loading…
Cancel
Save