Skip to content
This repository was archived by the owner on May 28, 2021. It is now read-only.

Commit 2b5a21c

Browse files
owainlewisprydie
authored andcommitted
Simplify and improve the local developer experience for pushing images (#167)
1 parent 20ff3b1 commit 2b5a21c

File tree

1 file changed

+23
-32
lines changed

1 file changed

+23
-32
lines changed

Makefile

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,18 @@ ifdef WERCKER
1717
VERSION ?= ${WERCKER_GIT_COMMIT}
1818
TENANT := "oracle"
1919
else
20-
NEW_NAMESPACE ?= e2e-${USER}
21-
VERSION := ${USER}-$(shell date +%Y%m%d%H%M%S)
22-
TENANT := "spinnaker"
20+
VERSION ?= ${USER}-$(shell git describe --always --dirty)
21+
TENANT ?= "spinnaker"
2322
endif
2423

25-
ROOT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
2624
PKG := github.com/oracle/mysql-operator
27-
REGISTRY := iad.ocir.io/$(TENANT)
25+
REGISTRY := iad.ocir.io
2826
SRC_DIRS := cmd pkg test/examples
29-
REGISTRY_STRING := $(subst /,_,$(REGISTRY))
3027
CMD_DIRECTORIES := $(sort $(dir $(wildcard ./cmd/*/)))
3128
COMMANDS := $(CMD_DIRECTORIES:./cmd/%/=%)
32-
CONTAINER_FILES := $(addprefix .container-$(REGISTRY_STRING)-,$(addsuffix -$(VERSION),$(COMMANDS)))
33-
PUSH_FILES := $(addprefix .push-$(REGISTRY_STRING)-,$(addsuffix -$(VERSION),$(COMMANDS)))
3429

35-
ARCH := amd64
36-
OS := linux
30+
ARCH ?= amd64
31+
OS ?= linux
3732
UNAME_S := $(shell uname -s)
3833

3934
ifeq ($(UNAME_S),Darwin)
@@ -75,23 +70,26 @@ build: dist build-dirs Makefile
7570
ARCH=$(ARCH) OS=$(OS) VERSION=$(VERSION) PKG=$(PKG) ./hack/build.sh
7671
cp $(BINARIES) ./bin/$(OS)_$(ARCH)/
7772

78-
# Note: Only used for development, i.e. in CI the images are built using Wercker.
79-
.PHONY: containers
80-
containers: $(CONTAINER_FILES)
81-
.container-$(REGISTRY_STRING)-%-$(VERSION): build dist
82-
@echo Builing container: $*
83-
@docker login -u '$(DOCKER_REGISTRY_USERNAME)' -p '$(DOCKER_REGISTRY_PASSWORD)' $(REGISTRY)
84-
@docker build --build-arg=http_proxy --build-arg=https_proxy -t $(REGISTRY)/$*:$(VERSION) -f docker/$*/Dockerfile .
85-
@docker images -q $(REGISTRY)/$*:$(VERSION) > $@
73+
.PHONY: build-docker
74+
build-docker:
75+
@docker build \
76+
--build-arg=http_proxy \
77+
--build-arg=https_proxy \
78+
-t $(REGISTRY)/$(TENANT)/mysql-operator:$(VERSION) \
79+
-f docker/mysql-operator/Dockerfile .
80+
81+
@docker build \
82+
--build-arg=http_proxy \
83+
--build-arg=https_proxy \
84+
-t $(REGISTRY)/$(TENANT)/mysql-agent:$(VERSION) \
85+
-f docker/mysql-agent/Dockerfile .
8686

8787
# Note: Only used for development, i.e. in CI the images are pushed using Wercker.
8888
.PHONY: push
89-
push: $(PUSH_FILES)
90-
.push-$(REGISTRY_STRING)-%-$(VERSION): .container-$(REGISTRY_STRING)-%-$(VERSION)
91-
@echo Pushing container: $*
92-
@docker login -u '$(DOCKER_REGISTRY_USERNAME)' -p '$(DOCKER_REGISTRY_PASSWORD)' $(REGISTRY)
93-
@docker push $(REGISTRY)/$*:$(VERSION)
94-
@docker images -q $(REGISTRY)/$*:$(VERSION) > $@
89+
push: build build-docker
90+
@docker login iad.ocir.io -u $(DOCKER_REGISTRY_USERNAME) -p '$(DOCKER_REGISTRY_PASSWORD)'
91+
@docker push $(REGISTRY)/$(TENANT)/mysql-operator:$(VERSION)
92+
@docker push $(REGISTRY)/$(TENANT)/mysql-agent:$(VERSION)
9593

9694
.PHONY: version
9795
version:
@@ -102,14 +100,7 @@ lint:
102100
@find pkg cmd -name '*.go' | grep -v 'generated' | xargs -L 1 golint
103101

104102
.PHONY: clean
105-
clean: container-clean bin-clean
106-
107-
.PHONY: container-clean
108-
container-clean:
109-
rm -rf .container-* .push-* dist
110-
111-
.PHONY: bin-clean
112-
bin-clean:
103+
clean:
113104
rm -rf .go bin
114105

115106
.PHONY: run-dev

0 commit comments

Comments
 (0)