Add project's Makefile, improve the Dockerfile.

Add targets to build operator and create docker images.
  Add scm-source.json to the Dockerfile.
This commit is contained in:
Oleksii Kliukin 2017-01-27 11:59:49 +01:00 committed by Murat Kabilov
parent 4f615be718
commit 8e15b846c9
2 changed files with 46 additions and 2 deletions

View File

@ -1,5 +1,8 @@
FROM alpine
ADD postgres-operator /usr/local/bin
MAINTAINER Team ACID @ Zalando <team-acid@zalando.de>
CMD ["/usr/local/bin/postgres-operator"]
ADD build/linux/postgres-operator /postgres-operator
ADD scm-source.json /
ENTRYPOINT ["/postres-operator"]

41
Makefile Normal file
View File

@ -0,0 +1,41 @@
.PHONY: clean local linux macos docker push scm-source.json
BINARY ?= postgres-operator
BUILD_FLAGS ?= -i
DOCKERFILE = Dockerfile
IMAGE ?= pierone.example.com/acid/$(BINARY)
TAG ?= $(VERSION)
GITHEAD = $(shell git rev-parse --short HEAD)
GITURL = $(shell git config --get remote.origin.url)
GITSTATUS = $(shell git status --porcelain || echo "no changes")
SOURCES = cmd/main.go
VERSION ?= $(shell git describe --tags --always --dirty)
IMAGE ?= pierone.example.com/acid/$(BINARY)
default: local
clean:
rm -rf build
local: build/${BINARY}
linux: build/linux/${BINARY}
macos: build/macos/${BINARY}
build/${BINARY}: ${SOURCES}
go build -o $@ $(BUILD_FLAGS) $^
build/linux/${BINARY}: ${SOURCES}
GOOS=linux GOARCH=amd64 go build -o $@ ${BUILD_FLAGS} $^
build/macos/${BINARY}: ${SOURCES}
GOOS=darwin GOARCH=amd64 go build -o $@ ${BUILD_FLAGS} $^
docker: ${DOCKERFILE} scm-source.json linux
docker build --rm -t "$(IMAGE):$(TAG)" -f $< .
push:
docker push "$(IMAGE):$(TAG)"
scm-source.json: .git
echo '{\n "url": "$(GITURL)",\n "revision": "$(GITHEAD)",\n "author": "$(USER)",\n "status": "$(GITSTATUS)"\n}' > scm-source.json