-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (50 loc) · 1.79 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/make -f
SHELL := /bin/bash
IMG_NAME := ocp_alpine-s6
IMG_REPO := nforceroh
IMG_NS := mail
IMG_REG := dockerio
DATE_VERSION := $(shell date +"v%Y%m%d%H%M" )
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
DOCKERCMD := podman
ifeq ($(BRANCH),dev)
VERSION := dev
else
VERSION := $(BRANCH)
endif
#oc get route default-route -n openshift-image-registry
#podman login -u sylvain -p $(oc whoami -t) default-route-openshift-image-registry.apps.ocp.nf.lab
.PHONY: all build push gitcommit gitpush create
all: build push
git: gitcommit gitpush
build:
@echo "Building $(IMG_NAME)image"
$(DOCKERCMD) build \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
--build-arg VCS_REF="$(VERSION)" \
--build-arg VERSION="$(VERSION)" \
--build-arg BASE_IMAGE="alpine:edge" \
--tag $(IMG_REPO)/$(IMG_NAME) .
gitcommit:
git push
gitpush:
@echo "Building $(IMG_NAME):$(VERSION) image"
git tag -a $(VERSION) -m "Update to $(VERSION)"
git push --tags
push:
@echo "Tagging and Pushing $(IMG_NAME):$(VERSION) image"
ifeq ($(VERSION), dev)
$(DOCKERCMD) tag $(IMG_REPO)/$(IMG_NAME) docker.io/$(IMG_REPO)/$(IMG_NAME):dev
$(DOCKERCMD) push docker.io/$(IMG_REPO)/$(IMG_NAME):dev
else
$(DOCKERCMD) tag $(IMG_REPO)/$(IMG_NAME) docker.io/$(IMG_REPO)/$(IMG_NAME):$(DATE_VERSION)
$(DOCKERCMD) tag $(IMG_REPO)/$(IMG_NAME) docker.io/$(IMG_REPO)/$(IMG_NAME):latest
# $(DOCKERCMD) tag $(IMG_REPO)/$(IMG_NAME) $(IMG_REG)/$(IMG_NS)/$(IMG_NAME):$(DATE_VERSION)
# $(DOCKERCMD) tag $(IMG_REPO)/$(IMG_NAME) $(IMG_REG)/$(IMG_NS)/$(IMG_NAME):latest
# $(DOCKERCMD) push $(IMG_REG)/$(IMG_NS)/$(IMG_NAME):$(DATE_VERSION)
# $(DOCKERCMD) push $(IMG_REG)/$(IMG_NS)/$(IMG_NAME):latest
$(DOCKERCMD) push docker.io/$(IMG_REPO)/$(IMG_NAME):$(DATE_VERSION)
$(DOCKERCMD) push docker.io/$(IMG_REPO)/$(IMG_NAME):latest
endif
end:
@echo "Done!"