Revert the make file for helm make.

This PS reverts the makefile for making helm chart. Also docker
build makefile is moved to Dockerfiles folder.

Change-Id: I866cd23a4c5b4407ab33ffd220a9ba886c5b9f63
Signed-off-by: Sreejith Punnapuzha <Sreejith.Punnapuzha@outlook.com>
This commit is contained in:
Sreejith Punnapuzha 2019-10-01 14:35:07 -05:00
parent 813f350ac9
commit ac02689568
2 changed files with 139 additions and 77 deletions

103
Dockerfiles/Makefile Normal file
View File

@ -0,0 +1,103 @@
# Copyright 2019 AT&T Intellectual Property. All other 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
#
# https://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.
# It's necessary to set this because some environments don't link sh -> bash.
SHELL := /bin/bash
# APP INFO
DOCKER_REGISTRY ?= quay.io
IMAGE_PREFIX ?= airshipit
IMAGE_NAME ?=
IMAGE_TAG ?= latest
PROXY ?= http://proxy.foo.com:8000
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
USE_PROXY ?= false
PUSH_IMAGE ?= false
# use this variable for image labels added in internal build process
LABEL ?= org.airshipit.build=community
COMMIT ?= $(shell git rev-parse HEAD)
DISTRO_SUFFIX ?= $(DISTRO)
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}-${DISTRO_SUFFIX}
BASE_IMAGE ?=
# VERSION INFO
GIT_COMMIT = ${COMMIT}
GIT_SHA = $(shell git rev-parse --short HEAD)
GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
ifdef VERSION
DOCKER_VERSION = $(VERSION)
endif
ifeq "$(DISTRO_SUFFIX)" ""
# We expect that container is named 'porthole-xxxxx', and
# subdirectory is named 'xxxxx'; so we cut 'porthole-' from
# directory names here below and in next statement
DOCKERFILE = "$(subst porthole-,,$(IMAGE_NAME))/Dockerfile"
else
DOCKERFILE = "$(subst porthole-,,$(IMAGE_NAME))/Dockerfile.$(DISTRO_SUFFIX)"
endif
info:
@echo "Version: ${VERSION}"
@echo "Git Tag: ${GIT_TAG}"
@echo "Git Commit: ${GIT_COMMIT}"
@echo "Git Tree State: ${GIT_DIRTY}"
@echo "Docker Version: ${DOCKER_VERSION}"
@echo "Registry: ${DOCKER_REGISTRY}"
all:
@echo "And what is there's nothing in there? You die, and there's" \
"nothing beyond that. Nothing. Nothing remains. Someone might" \
"remember you for a little while after but not for long.">&2; exit 2
check-docker:
@if [ -z $$(which docker) ]; then \
echo "Missing \`docker\` client which is required for development"; \
exit 2; \
fi
_BASE_IMAGE_ARG := $(if $(BASE_IMAGE),--build-arg FROM="${BASE_IMAGE}" ,)
build-image-$(IMAGE_NAME): check-docker
ifeq "$(IMAGE_NAME)" ""
@echo "Missing \`IMAGE_NAME\` variable." >&2; exit 2
endif
ifeq ($(USE_PROXY), true)
docker build --network host -t $(IMAGE) --label $(LABEL) \
--label "org.opencontainers.image.revision=$(COMMIT)" \
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
-f $(DOCKERFILE) \
$(_BASE_IMAGE_ARG) \
--build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \
--build-arg HTTP_PROXY=$(PROXY) \
--build-arg HTTPS_PROXY=$(PROXY) \
--build-arg no_proxy=$(NO_PROXY) \
--build-arg NO_PROXY=$(NO_PROXY) .
else
docker build --network host -t $(IMAGE) --label $(LABEL) \
--label "org.opencontainers.image.revision=$(COMMIT)" \
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
-f $(DOCKERFILE) \
$(_BASE_IMAGE_ARG) .
endif
ifeq ($(PUSH_IMAGE), true)
docker push $(IMAGE)
endif
.PHONY: all build-image-$(IMAGE_NAME) build-image-% check-docker info

113
Makefile
View File

@ -15,89 +15,48 @@
# It's necessary to set this because some environments don't link sh -> bash.
SHELL := /bin/bash
# APP INFO
DOCKER_REGISTRY ?= quay.io
IMAGE_PREFIX ?= airshipit
IMAGE_NAME ?=
IMAGE_TAG ?= latest
PROXY ?= http://proxy.foo.com:8000
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
USE_PROXY ?= false
PUSH_IMAGE ?= false
# use this variable for image labels added in internal build process
LABEL ?= org.airshipit.build=community
COMMIT ?= $(shell git rev-parse HEAD)
DISTRO_SUFFIX ?= $(DISTRO)
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}-${DISTRO_SUFFIX}
BASE_IMAGE ?=
HELM := helm
TASK := build
# VERSION INFO
GIT_COMMIT = ${COMMIT}
GIT_SHA = $(shell git rev-parse --short HEAD)
GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
EXCLUDES := helm-toolkit docs tools logs tmp Dockerfiles zuul.d
CHARTS := helm-toolkit $(filter-out $(EXCLUDES), $(patsubst %/.,%,$(wildcard */.)))
ifdef VERSION
DOCKER_VERSION = $(VERSION)
endif
.PHONY: $(EXCLUDES) $(CHARTS)
ifeq "$(DISTRO_SUFFIX)" ""
# We expect that container is named 'porthole-xxxxx', and
# subdirectory is named 'xxxxx'; so we cut 'porthole-' from
# directory names here below and in next statement
DOCKERFILE = "Dockerfiles/$(subst porthole-,,$(IMAGE_NAME))/Dockerfile"
else
DOCKERFILE = "Dockerfiles/$(subst porthole-,,$(IMAGE_NAME))/Dockerfile.$(DISTRO_SUFFIX)"
endif
all: $(CHARTS)
info:
@echo "Version: ${VERSION}"
@echo "Git Tag: ${GIT_TAG}"
@echo "Git Commit: ${GIT_COMMIT}"
@echo "Git Tree State: ${GIT_DIRTY}"
@echo "Docker Version: ${DOCKER_VERSION}"
@echo "Registry: ${DOCKER_REGISTRY}"
$(CHARTS):
@echo
@echo "===== Processing [$@] chart ====="
@make $(TASK)-$@
all:
@echo "And what is there's nothing in there? You die, and there's" \
"nothing beyond that. Nothing. Nothing remains. Someone might" \
"remember you for a little while after but not for long.">&2; exit 2
init-%:
if [ -f $*/Makefile ]; then make -C $*; fi
if [ -f $*/requirements.yaml ]; then helm dep up $*; fi
check-docker:
@if [ -z $$(which docker) ]; then \
echo "Missing \`docker\` client which is required for development"; \
exit 2; \
fi
lint-%: init-%
if [ -d $* ]; then $(HELM) lint $*; fi
_BASE_IMAGE_ARG := $(if $(BASE_IMAGE),--build-arg FROM="${BASE_IMAGE}" ,)
build-%: lint-%
if [ -d $* ]; then $(HELM) package $*; fi
build-image-$(IMAGE_NAME): check-docker
ifeq "$(IMAGE_NAME)" ""
@echo "Missing \`IMAGE_NAME\` variable." >&2; exit 2
endif
ifeq ($(USE_PROXY), true)
docker build --network host -t $(IMAGE) --label $(LABEL) \
--label "org.opencontainers.image.revision=$(COMMIT)" \
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
-f $(DOCKERFILE) \
$(_BASE_IMAGE_ARG) \
--build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \
--build-arg HTTP_PROXY=$(PROXY) \
--build-arg HTTPS_PROXY=$(PROXY) \
--build-arg no_proxy=$(NO_PROXY) \
--build-arg NO_PROXY=$(NO_PROXY) .
else
docker build --network host -t $(IMAGE) --label $(LABEL) \
--label "org.opencontainers.image.revision=$(COMMIT)" \
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
-f $(DOCKERFILE) \
$(_BASE_IMAGE_ARG) .
endif
ifeq ($(PUSH_IMAGE), true)
docker push $(IMAGE)
endif
clean:
@echo "Removed .b64, _partials.tpl, and _globals.tpl files"
rm -f helm-toolkit/secrets/*.b64
rm -f */templates/_partials.tpl
rm -f */templates/_globals.tpl
rm -f *tgz */charts/*tgz
rm -f */requirements.lock
-rm -rf */charts */tmpcharts
.PHONY: all build-image-$(IMAGE_NAME) build-image-% check-docker info
pull-all-images:
@./tools/pull-images.sh
pull-images:
@./tools/pull-images.sh $(filter-out $@,$(MAKECMDGOALS))
dev-deploy:
@./tools/gate/devel/start.sh $(filter-out $@,$(MAKECMDGOALS))
%:
@: