1+ # Copyright 2018-2020 The OpenEBS Authors. All rights reserved.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+
16+ # The images can be pushed to any docker/image registeries
17+ # like docker hub, quay. The registries are specified in
18+ # the `build/push` script.
19+ #
20+ # The images of a project or company can then be grouped
21+ # or hosted under a unique organization key like `openebs`
22+ #
23+ # Each component (container) will be pushed to a unique
24+ # repository under an organization.
25+ # Putting all this together, an unique uri for a given
26+ # image comprises of:
27+ # <registry url>/<image org>/<image repo>:<image-tag>
28+ #
29+ # IMAGE_ORG can be used to customize the organization
30+ # under which images should be pushed.
31+ # By default the organization name is `openebs`.
32+
133# Output registry and image names for operator image
234# Set env to override this value
3- ifeq (${REGISTRY}, )
4- REGISTRY: =openebs
35+ ifeq (${IMAGE_ORG}, )
36+ IMAGE_ORG: =openebs
37+ endif
38+ export IMAGE_ORG
39+
40+ # Determine the arch/os
41+ ifeq (${XC_OS}, )
42+ XC_OS: =$(shell go env GOOS)
543endif
6- export REGISTRY
44+ export XC_OS
45+
46+ ifeq (${XC_ARCH}, )
47+ XC_ARCH: =$(shell go env GOARCH)
48+ endif
49+ export XC_ARCH
50+
51+ ARCH: =${XC_OS}_${XC_ARCH}
52+ export ARCH
753
54+ # Specify the docker arg for repository url
55+ ifeq (${DBUILD_REPO_URL}, )
56+ DBUILD_REPO_URL ="https://github.com/openebs/jiva-csi"
57+ export DBUILD_REPO_URL
58+ endif
59+
60+ # Specify the docker arg for website url
61+ ifeq (${DBUILD_SITE_URL}, )
62+ DBUILD_SITE_URL ="https://openebs.io"
63+ export DBUILD_SITE_URL
64+ endif
65+
66+ DBUILD_DATE ?= $(shell date -u +'% Y-% m-% dT% H:% M:% SZ')
867# Output plugin name and its image name and tag
968PLUGIN_NAME =jiva-csi
1069PLUGIN_TAG =ci
1170
71+ export DBUILD_ARGS =--build-arg DBUILD_DATE=${DBUILD_DATE} --build-arg DBUILD_REPO_URL=${DBUILD_REPO_URL} --build-arg DBUILD_SITE_URL=${DBUILD_SITE_URL} --build-arg ARCH=${ARCH}
72+
1273# Tools required for different make targets or for development purposes
1374EXTERNAL_TOOLS =\
1475 golang.org/x/tools/cmd/cover \
@@ -40,20 +101,19 @@ endif
40101
41102PACKAGES = $(shell go list ./... | grep -v 'vendor')
42103
43- DATETIME ?= $(shell date +'% F_% T')
44104LDFLAGS ?= \
45105 -extldflags "-static" \
46106 -X github.com/openebs/jiva-csi/version/version.Version=${VERSION} \
47107 -X github.com/openebs/jiva-csi/version/version.Commit=${COMMIT} \
48- -X github.com/openebs/jiva-csi/version/version.DateTime=${DATETIME }
108+ -X github.com/openebs/jiva-csi/version/version.DateTime=${DBUILD_DATE }
49109
50110
51111.PHONY : help
52112help :
53113 @echo " Available commands:"
54114 @echo " build - build csi source code"
55115 @echo " image - build csi container image"
56- @echo " push - push csi to dockerhub registry (${REGISTRY } )"
116+ @echo " push - push csi to dockerhub registry (${IMAGE_ORG } )"
57117 @echo " "
58118 @make print-variables --no-print-directory
59119
@@ -66,7 +126,7 @@ print-variables:
66126 @echo " COMMIT: ${COMMIT} "
67127 @echo " Testing variables:"
68128 @echo " Produced Image: ${PLUGIN_NAME} :${PLUGIN_TAG} "
69- @echo " REGISTRY : ${REGISTRY } "
129+ @echo " IMAGE_ORG : ${IMAGE_ORG } "
70130
71131# Bootstrap the build by downloading additional tools
72132bootstrap :
@@ -103,24 +163,24 @@ build: deps test
103163 GOOS=linux go build -a -ldflags ' $(LDFLAGS)' -o ./build/bin/$(PLUGIN_NAME ) ./cmd/csi/main.go
104164
105165image : build
106- @echo " --> Build image $( REGISTRY ) /$( PLUGIN_NAME) :$( PLUGIN_TAG) ..."
107- docker build -f ./build/Dockerfile -t $(REGISTRY ) /$(PLUGIN_NAME ) :$(PLUGIN_TAG ) .
166+ @echo " --> Build image $( IMAGE_ORG ) /$( PLUGIN_NAME) :$( PLUGIN_TAG) ..."
167+ docker build -f ./build/Dockerfile -t $(IMAGE_ORG ) /$(PLUGIN_NAME ) :$(PLUGIN_TAG ) $( DBUILD_ARGS ) .
108168
109169push-image : image
110- @echo " --> Push image $( REGISTRY ) /$( PLUGIN_NAME) :$( PLUGIN_TAG) ..."
111- docker push $(REGISTRY ) /$(PLUGIN_NAME ) :$(PLUGIN_TAG )
170+ @echo " --> Push image $( IMAGE_ORG ) /$( PLUGIN_NAME) :$( PLUGIN_TAG) ..."
171+ docker push $(IMAGE_ORG ) /$(PLUGIN_NAME ) :$(PLUGIN_TAG )
112172
113173push :
114- @echo " --> Push image $( REGISTRY ) /$( PLUGIN_NAME) :$( PLUGIN_TAG) ..."
115- @DIMAGE=$(REGISTRY ) /$(PLUGIN_NAME ) ./build/push
174+ @echo " --> Push image $( IMAGE_ORG ) /$( PLUGIN_NAME) :$( PLUGIN_TAG) ..."
175+ @DIMAGE=$(IMAGE_ORG ) /$(PLUGIN_NAME ) ./build/push
116176
117177tag :
118- @echo " --> Tag image $( REGISTRY ) /$( PLUGIN_NAME) :$( PLUGIN_TAG) to $( REGISTRY ) /$( PLUGIN_NAME) :$( GIT_TAG) ..."
119- docker tag $(REGISTRY ) /$(PLUGIN_NAME ) :$(PLUGIN_TAG ) $(REGISTRY ) /$(PLUGIN_NAME ) :$(GIT_TAG )
178+ @echo " --> Tag image $( IMAGE_ORG ) /$( PLUGIN_NAME) :$( PLUGIN_TAG) to $( IMAGE_ORG ) /$( PLUGIN_NAME) :$( GIT_TAG) ..."
179+ docker tag $(IMAGE_ORG ) /$(PLUGIN_NAME ) :$(PLUGIN_TAG ) $(IMAGE_ORG ) /$(PLUGIN_NAME ) :$(GIT_TAG )
120180
121181push-tag : tag push
122- @echo " --> Push image $( REGISTRY ) /$( PLUGIN_NAME) :$( GIT_TAG) ..."
123- docker push $(REGISTRY ) /$(PLUGIN_NAME ) :$(GIT_TAG )
182+ @echo " --> Push image $( IMAGE_ORG ) /$( PLUGIN_NAME) :$( GIT_TAG) ..."
183+ docker push $(IMAGE_ORG ) /$(PLUGIN_NAME ) :$(GIT_TAG )
124184
125185clean :
126186 rm -rf ./build/bin/
0 commit comments