From a3692fb72ae17af140a147135aede3cfec960def Mon Sep 17 00:00:00 2001 From: Ondra Machacek Date: Wed, 2 Oct 2024 15:39:33 +0200 Subject: [PATCH] Add CI to build&push containers Signed-off-by: Ondra Machacek --- .tekton/agent-pull-request.yaml | 2 +- .tekton/agent-push.yaml | 2 +- .tekton/collector-pull-request.yaml | 2 +- .tekton/collector-push.yaml | 2 +- .../migration-planner-api-pull-request.yaml | 2 +- .tekton/migration-planner-api-push.yaml | 2 +- Dockerfile.agent => Containerfile.agent | 0 Dockerfile.planner-api => Containerfile.api | 0 ...rfile.collector => Containerfile.collector | 0 Makefile | 27 +++++++++++++++---- 10 files changed, 28 insertions(+), 11 deletions(-) rename Dockerfile.agent => Containerfile.agent (100%) rename Dockerfile.planner-api => Containerfile.api (100%) rename Dockerfile.collector => Containerfile.collector (100%) diff --git a/.tekton/agent-pull-request.yaml b/.tekton/agent-pull-request.yaml index dbf5b59..dd70f82 100644 --- a/.tekton/agent-pull-request.yaml +++ b/.tekton/agent-pull-request.yaml @@ -27,7 +27,7 @@ spec: - name: image-expires-after value: 5d - name: dockerfile - value: Dockerfile.agent + value: Containerfile.agent pipelineSpec: description: | This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization. diff --git a/.tekton/agent-push.yaml b/.tekton/agent-push.yaml index 7f4675e..8ccfbc5 100644 --- a/.tekton/agent-push.yaml +++ b/.tekton/agent-push.yaml @@ -24,7 +24,7 @@ spec: - name: output-image value: quay.io/redhat-user-workloads/omachace-tenant/migration-planner/agent:{{revision}} - name: dockerfile - value: Dockerfile.agent + value: Containerfile.agent pipelineSpec: description: | This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization. diff --git a/.tekton/collector-pull-request.yaml b/.tekton/collector-pull-request.yaml index 82cc407..cb2ae21 100644 --- a/.tekton/collector-pull-request.yaml +++ b/.tekton/collector-pull-request.yaml @@ -27,7 +27,7 @@ spec: - name: image-expires-after value: 5d - name: dockerfile - value: Dockerfile.collector + value: Containerfile.collector pipelineSpec: description: | This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization. diff --git a/.tekton/collector-push.yaml b/.tekton/collector-push.yaml index c4ee4cb..d3a2b63 100644 --- a/.tekton/collector-push.yaml +++ b/.tekton/collector-push.yaml @@ -24,7 +24,7 @@ spec: - name: output-image value: quay.io/redhat-user-workloads/omachace-tenant/migration-planner/collector:{{revision}} - name: dockerfile - value: Dockerfile.collector + value: Containerfile.collector pipelineSpec: description: | This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization. diff --git a/.tekton/migration-planner-api-pull-request.yaml b/.tekton/migration-planner-api-pull-request.yaml index 8d04aff..b096f82 100644 --- a/.tekton/migration-planner-api-pull-request.yaml +++ b/.tekton/migration-planner-api-pull-request.yaml @@ -27,7 +27,7 @@ spec: - name: image-expires-after value: 5d - name: dockerfile - value: Dockerfile.planner-api + value: Containerfile.api pipelineSpec: description: | This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization. diff --git a/.tekton/migration-planner-api-push.yaml b/.tekton/migration-planner-api-push.yaml index 7281307..beaf86d 100644 --- a/.tekton/migration-planner-api-push.yaml +++ b/.tekton/migration-planner-api-push.yaml @@ -24,7 +24,7 @@ spec: - name: output-image value: quay.io/redhat-user-workloads/omachace-tenant/migration-planner/migration-planner-api:{{revision}} - name: dockerfile - value: Dockerfile.planner-api + value: Containerfile.api pipelineSpec: description: | This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization. diff --git a/Dockerfile.agent b/Containerfile.agent similarity index 100% rename from Dockerfile.agent rename to Containerfile.agent diff --git a/Dockerfile.planner-api b/Containerfile.api similarity index 100% rename from Dockerfile.planner-api rename to Containerfile.api diff --git a/Dockerfile.collector b/Containerfile.collector similarity index 100% rename from Dockerfile.collector rename to Containerfile.collector diff --git a/Makefile b/Makefile index 4ce194d..b3f4e91 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,10 @@ ROOT_DIR := $(or ${ROOT_DIR},$(shell dirname $(realpath $(firstword $(MAKEFILE_L GO_FILES := $(shell find ./ -name ".go" -not -path "./bin" -not -path "./packaging/*") GO_CACHE := -v $${HOME}/go/migration-planner-go-cache:/opt/app-root/src/go:Z -v $${HOME}/go/migration-planner-go-cache/.cache:/opt/app-root/src/.cache:Z TIMEOUT ?= 30m - VERBOSE ?= false +MIGRATION_PLANNER_AGENT_IMAGE ?= quay.io/kubev2v/migration-planner-agent +MIGRATION_PLANNER_COLLECTOR_IMAGE ?= quay.io/kubev2v/migration-planner-collector +MIGRATION_PLANNER_API_IMAGE ?= quay.io/kubev2v/migration-planner-api SOURCE_GIT_TAG ?=$(shell git describe --always --long --tags --abbrev=7 --match 'v[0-9]*' || echo 'v0.0.0-unknown-$(SOURCE_GIT_COMMIT)') SOURCE_GIT_TREE_STATE ?=$(shell ( ( [ ! -d ".git/" ] || git diff --quiet ) && echo 'clean' ) || echo 'dirty') @@ -60,22 +62,37 @@ build-api: bin # rebuild container only on source changes +bin/.migration-planner-agent-container: bin Containerfile.agent go.mod go.sum $(GO_FILES) + mkdir -p $${HOME}/go/migration-planner-go-cache/.cache + podman build -f Containerfile.agent $(GO_CACHE) -t $(MIGRATION_PLANNER_AGENT_IMAGE):latest + touch bin/.migration-planner-agent-container + +bin/.migration-planner-collector-container: bin Containerfile.collector go.mod go.sum $(GO_FILES) + mkdir -p $${HOME}/go/migration-planner-go-cache/.cache + podman build -f Containerfile.collector $(GO_CACHE) -t $(MIGRATION_PLANNER_COLLECTOR_IMAGE):latest + touch bin/.migration-planner-collector-container + bin/.migration-planner-api-container: bin Containerfile.api go.mod go.sum $(GO_FILES) mkdir -p $${HOME}/go/migration-planner-go-cache/.cache - podman build -f Containerfile.api $(GO_CACHE) -t migration-planner-api:latest + podman build -f Containerfile.api $(GO_CACHE) -t $(MIGRATION_PLANNER_API_IMAGE):latest touch bin/.migration-planner-api-container migration-planner-api-container: bin/.migration-planner-api-container +migration-planner-collector-container: bin/.migration-planner-collector-container +migration-planner-agent-container: bin/.migration-planner-agent-container - -build-containers: migration-planner-api-container +build-containers: migration-planner-api-container migration-planner-agent-container migration-planner-collector-container .PHONY: build-containers +push-containers: build-containers + podman push $(MIGRATION_PLANNER_API_IMAGE):latest + podman push $(MIGRATION_PLANNER_COLLECTOR_IMAGE):latest + podman push $(MIGRATION_PLANNER_AGENT_IMAGE):latest + bin: mkdir -p bin - clean: - rm -f -r bin