refact(build): make the docker images configurable

and Also trim leading v from image tag.

Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
Pawan 2020-05-07 16:37:30 +05:30 committed by Kiran Mova
parent dd059a2f43
commit a8a490e9cb
3 changed files with 115 additions and 22 deletions

View file

@ -1,3 +1,17 @@
# Copyright 2019-2020 The OpenEBS Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# list only csi source code directories
PACKAGES = $(shell go list ./... | grep -v 'vendor\|pkg/generated')
@ -18,27 +32,69 @@ EXTERNAL_TOOLS=\
github.com/onsi/ginkgo/ginkgo \
github.com/onsi/gomega/...
# The images can be pushed to any docker/image registeries
# like docker hub, quay. The registries are specified in
# the `build/push` script.
#
# The images of a project or company can then be grouped
# or hosted under a unique organization key like `openebs`
#
# Each component (container) will be pushed to a unique
# repository under an organization.
# Putting all this together, an unique uri for a given
# image comprises of:
# <registry url>/<image org>/<image repo>:<image-tag>
#
# IMAGE_ORG can be used to customize the organization
# under which images should be pushed.
# By default the organization name is `openebs`.
ifeq (${IMAGE_ORG}, )
IMAGE_ORG="openebs"
export IMAGE_ORG
endif
# Specify the date of build
DBUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Specify the docker arg for repository url
ifeq (${DBUILD_REPO_URL}, )
DBUILD_REPO_URL="https://github.com/openebs/zfs-localpv"
export DBUILD_REPO_URL
endif
# Specify the docker arg for website url
ifeq (${DBUILD_SITE_URL}, )
DBUILD_SITE_URL="https://openebs.io"
export DBUILD_SITE_URL
endif
ifeq (${IMAGE_TAG}, )
IMAGE_TAG = ci
export IMAGE_TAG
endif
ifeq (${TRAVIS_TAG}, )
BASE_TAG = ci
export BASE_TAG
else
BASE_TAG = ${TRAVIS_TAG}
export BASE_TAG
# Determine the arch/os
ifeq (${XC_OS}, )
XC_OS:=$(shell go env GOOS)
endif
export XC_OS
ifeq (${XC_ARCH}, )
XC_ARCH:=$(shell go env GOARCH)
endif
export XC_ARCH
ARCH:=${XC_OS}_${XC_ARCH}
export ARCH
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}
# Specify the name for the binary
CSI_DRIVER=zfs-driver
# Specify the date o build
BUILD_DATE = $(shell date +'%Y%m%d%H%M%S')
.PHONY: all
all: test zfs-driver-image
all: test manifests zfs-driver-image
.PHONY: clean
clean:
@ -155,7 +211,7 @@ zfs-driver-image: zfs-driver
@echo "+ Generating ${CSI_DRIVER} image"
@echo "--------------------------------"
@cp bin/${CSI_DRIVER}/${CSI_DRIVER} buildscripts/${CSI_DRIVER}/
cd buildscripts/${CSI_DRIVER} && sudo docker build -t openebs/${CSI_DRIVER}:${IMAGE_TAG} --build-arg BUILD_DATE=${BUILD_DATE} . && sudo docker tag openebs/${CSI_DRIVER}:${IMAGE_TAG} quay.io/openebs/${CSI_DRIVER}:${IMAGE_TAG}
cd buildscripts/${CSI_DRIVER} && sudo docker build -t ${IMAGE_ORG}/${CSI_DRIVER}:${IMAGE_TAG} ${DBUILD_ARGS} . && sudo docker tag ${IMAGE_ORG}/${CSI_DRIVER}:${IMAGE_TAG} quay.io/${IMAGE_ORG}/${CSI_DRIVER}:${IMAGE_TAG}
@rm buildscripts/${CSI_DRIVER}/${CSI_DRIVER}
.PHONY: ci
@ -164,5 +220,5 @@ ci:
$(PWD)/ci/ci-test.sh
# Push images
deploy-images:
@DIMAGE="openebs/zfs-driver" ./buildscripts/push
@DIMAGE="${IMAGE_ORG}/zfs-driver" ./buildscripts/push