File tree 2 files changed +69
-2
lines changed
2 files changed +69
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,16 @@ all: build
18
18
-include $(CONFIG )
19
19
-include $(CONFIG ) -token
20
20
21
- DOCKER_REPO ?= k8s-publishing-bot
21
+ GIT_TAG ?= $(shell git describe --tags --always --dirty)
22
+
23
+ # Image variables
24
+ IMG_REGISTRY ?= gcr.io/k8s-staging-publishing-bot
25
+ IMG_NAME = publishing-bot
26
+
27
+ IMG_VERSION ?= v0.0.0-1
28
+
29
+ # TODO(image): Consider renaming this variable
30
+ DOCKER_REPO ?= $(IMG_REGISTRY ) /$(IMG_NAME )
22
31
NAMESPACE ?=
23
32
TOKEN ?=
24
33
KUBECTL ?= kubectl
@@ -44,12 +53,21 @@ build:
44
53
.PHONY : build
45
54
46
55
build-image : build
47
- docker build -t $(DOCKER_REPO ) .
56
+ docker build \
57
+ -t $(DOCKER_REPO ) :$(GIT_TAG ) \
58
+ -t $(DOCKER_REPO ) :$(IMG_VERSION ) \
59
+ -t $(DOCKER_REPO ) :latest \
60
+ .
48
61
.PHONY : build-image
49
62
50
63
push-image :
64
+ docker push $(DOCKER_REPO ) :$(GIT_TAG )
65
+ docker push $(DOCKER_REPO ) :$(IMG_VERSION )
51
66
docker push $(DOCKER_REPO ) :latest
52
67
68
+ build-and-push-image : build-image push-image
69
+ .PHONY : build-and-push-image
70
+
53
71
clean :
54
72
rm -rf _output
55
73
.PHONY : clean
Original file line number Diff line number Diff line change
1
+ # Google Cloud Build configuration: https://cloud.google.com/cloud-build/docs/build-config
2
+ # Image building process: https://git.k8s.io/test-infra/config/jobs/image-pushing/README.md
3
+
4
+ # this must be specified in seconds. If omitted, defaults to 600s (10 mins)
5
+ timeout : 1200s
6
+
7
+ options :
8
+ substitution_option : ALLOW_LOOSE
9
+ # TODO(image): Consider a smaller machine type
10
+ machineType : N1_HIGHCPU_32
11
+
12
+ steps :
13
+ - name : ' gcr.io/k8s-staging-releng/k8s-ci-builder:latest-default'
14
+ entrypoint : make
15
+ env :
16
+ - GIT_TAG=$_GIT_TAG
17
+ - PULL_BASE_REF=$_PULL_BASE_REF
18
+ - IMG_REGISTRY=gcr.io/$PROJECT_ID
19
+ - IMG_VERSION=$_IMG_VERSION
20
+ args :
21
+ - build-and-push-image
22
+
23
+ # TODO(image): Consider adding a container structure test
24
+ # - name: 'gcr.io/gcp-runtimes/container-structure-test'
25
+ # id: structure-test
26
+ # args:
27
+ # - test
28
+ # - --image=gcr.io/$PROJECT_ID/publishing-bot:$_GIT_TAG
29
+ # - --config=container-structure.yaml
30
+
31
+ substitutions :
32
+ # _GIT_TAG will be filled with a git-based tag for the image, of the form
33
+ # vYYYYMMDD-hash, and can be used as a substitution
34
+ _GIT_TAG : ' 12345'
35
+ _PULL_BASE_REF : ' dev'
36
+ _IMG_REGISTRY : ' null-registry'
37
+ _IMG_VERSION : ' v0.0.0-1'
38
+
39
+ tags :
40
+ - ' publishing-bot'
41
+ - ${_GIT_TAG}
42
+ - ${_PULL_BASE_REF}
43
+ - ${_IMG_REGISTRY}
44
+ - ${_IMG_VERSION}
45
+
46
+ images :
47
+ - ' gcr.io/$PROJECT_ID/publishing-bot:$_GIT_TAG'
48
+ - ' gcr.io/$PROJECT_ID/publishing-bot:$_IMG_VERSION'
49
+ - ' gcr.io/$PROJECT_ID/publishing-bot:latest'
You can’t perform that action at this time.
0 commit comments