diff --git a/.travis.yml b/.travis.yml index 8207786204..4cdcc838c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,4 +12,8 @@ branches: install: true script: - - make build \ No newline at end of file + - make build + +after_success: + - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD + - make docker-publish \ No newline at end of file diff --git a/Makefile b/Makefile index 5a8fc794e7..97300df06b 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,9 @@ MAIN ?=$(PACKAGE) LD_FLAGS="-s -w -X $(PACKAGE)/pkg/version.BuildVersion=$(GIT_VERSION) -X $(PACKAGE)/pkg/version.BuildHash=$(GIT_HASH) -X $(PACKAGE)/pkg/version.BuildTime=$(TIMESTAMP)" -REPO=registry-v2.nirmata.io/nirmata/kyverno +# default docker hub +REGISTRY=index.docker.io +REPO=$(REGISTRY)/nirmata/kyverno IMAGE_TAG=$(GIT_VERSION) GOOS ?= $(shell go env GOOS) @@ -36,13 +38,21 @@ cli: cli-dirs cli-dirs: @mkdir -p _output/cli -image: - docker build -t $(REPO):$(IMAGE_TAG) . - docker tag $(REPO):$(IMAGE_TAG) $(REPO):latest - -push: - docker push $(REPO):$(IMAGE_TAG) - docker push $(REPO):latest - clean: go clean + +# docker image build targets +# user must be logged in the $(REGISTRY) to push images +.PHONY: docker-build docker-tag-repo docker-push + +docker-publish: docker-build docker-tag-repo docker-push + +docker-build: + @docker build -t $(REPO):$(IMAGE_TAG) . + +docker-tag-repo: + @docker tag $(REPO):$(IMAGE_TAG) $(REPO):latest + +docker-push: + @docker push $(REPO):$(IMAGE_TAG) + @docker push $(REPO):latest \ No newline at end of file