Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Docker build management components (#940)
Browse files Browse the repository at this point in the history
Add make target to build container images

This change make targets to build and publish docker images of
components that live in this repo.

It also includes a `kbld-config.yml` file and a script to replace image
name with the correct name after bulding the image, to be used by
scripts that build packages.

Signed-off-by: Rajath Agasthya <ragasthya@vmware.com>
  • Loading branch information
rajathagasthya authored Oct 26, 2021
1 parent dda9042 commit 89947b7
Show file tree
Hide file tree
Showing 8 changed files with 1,484 additions and 44 deletions.
36 changes: 0 additions & 36 deletions Dockerfile

This file was deleted.

37 changes: 31 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ endif
DOCKER_DIR := /app
SWAGGER=docker run --rm -v ${PWD}:${DOCKER_DIR} quay.io/goswagger/swagger:v0.21.0

# OCI registry for hosting tanzu framework components (containers and packages)
OCI_REGISTRY ?= projects.registry.vmware.com/tanzu_framework

# Add supported OS-ARCHITECTURE combinations here
ENVS := linux-amd64 windows-amd64 darwin-amd64
Expand All @@ -85,6 +87,7 @@ XDG_CACHE_HOME := ${HOME}/.cache

export XDG_DATA_HOME
export XDG_CACHE_HOME
export OCI_REGISTRY

## --------------------------------------
## API/controller building and generation
Expand Down Expand Up @@ -124,12 +127,6 @@ generate: controller-gen ## Generate code via controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt",year=$(shell date +%Y) paths="./..."
$(MAKE) fmt

docker-build: test ## Build the docker image
docker build . -t ${IMG} --build-arg LD_FLAGS="$(LD_FLAGS)"

docker-push: ## Push the docker image
docker push ${IMG}

controller-gen: ## Download controller-gen
ifeq (, $(shell which controller-gen))
@{ \
Expand Down Expand Up @@ -484,3 +481,31 @@ e2e-tkgctl-vc67: $(GINKGO) generate-embedproviders ## Run ginkgo tkgctl E2E test
.PHONY: e2e-tkgpackageclient-docker
e2e-tkgpackageclient-docker: $(GINKGO) generate-embedproviders ## Run ginkgo tkgpackageclient E2E tests
$(GINKGO) -v -trace -nodes=$(GINKGO_NODES) --noColor=$(GINKGO_NOCOLOR) $(GINKGO_ARGS) -tags embedproviders pkg/v1/tkg/test/tkgpackageclient

## --------------------------------------
## Docker build
## --------------------------------------

# These are the components in this repo that need to have a docker image built.
# This variable refers to directory paths that contain a Makefile with `docker-build`, `docker-publish` and
# `kbld-image-replace` targets that can build and push a docker image for that component.
COMPONENTS := pkg/v1/sdk/features

.PHONY: docker-build
docker-build: TARGET=docker-build
docker-build: $(COMPONENTS)

.PHONY: docker-publish
docker-publish: TARGET=docker-publish
docker-publish: $(COMPONENTS)

.PHONY: kbld-image-replace
kbld-image-replace: TARGET=kbld-image-replace
kbld-image-replace: $(COMPONENTS)

.PHONY: $(COMPONENTS)
$(COMPONENTS):
$(MAKE) -C $@ $(TARGET) IMG_VERSION_OVERRIDE=$(BUILD_VERSION)

.PHONY: docker-all
docker-all: docker-build docker-publish kbld-image-replace
29 changes: 29 additions & 0 deletions hack/packages/kbld-image-replace/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2021 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

.DEFAULT_GOAL:=help

help: ## Display this help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[0-9A-Za-z_-]+:.*?##/ { printf " \033[36m%-45s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

lint: ## Run Go code linting
ifeq ($(origin GOLANGCI_LINT),undefined)
@echo "Error! GOLANGCI_LINT env var not set"
else
$(GOLANGCI_LINT) run -v --timeout=5m
endif

get-deps: ## Get all dependencies
go mod download

test: ## Run unit testing suite
echo "N/A: No unit tests for hack/packages"

e2e-test: ## Run e2e testing suite
echo "N/A: No e2e tests for hack/packages"

build: ## Build the executable
go build -o kbld-image-replace main.go

run: ## Run the kbld-image-replace program to add a newImage path to an existing image in kbld-config.yml.
go run main.go $(IMAGE) $(NEW_IMAGE)
8 changes: 8 additions & 0 deletions hack/packages/kbld-image-replace/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/vmware-tanzu/tanzu-framework/hack/packages

go 1.16

require (
github.com/k14s/kbld v0.31.0
sigs.k8s.io/yaml v1.3.0
)
Loading

0 comments on commit 89947b7

Please sign in to comment.