Skip to content

Commit

Permalink
Add CI to build&push containers
Browse files Browse the repository at this point in the history
Signed-off-by: Ondra Machacek <[email protected]>
  • Loading branch information
machacekondra committed Oct 2, 2024
1 parent 30eaef1 commit a3692fb
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .tekton/agent-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion .tekton/agent-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion .tekton/collector-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion .tekton/collector-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion .tekton/migration-planner-api-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion .tekton/migration-planner-api-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 22 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit a3692fb

Please sign in to comment.