Add makefile for build and publication automation

This commit is contained in:
Ethan Paul 2023-03-14 23:08:25 -04:00
parent 95143f4284
commit 1cbc74a6db
Signed by: enpaul
GPG Key ID: DAF443CA3A2FA6FA
1 changed files with 22 additions and 0 deletions

22
Makefile Normal file
View File

@ -0,0 +1,22 @@
IMAGE_NAME = borgbackup
IMAGE_REPOSITORY ?= vcs.enp.one/skylab
VERSION ?= 1.2.3
OCI_CMD = $(shell which podman || which docker)
ifeq ($(OCI_CMD),)
$(error "No supported container build tool found (one of: podman, docker)")
endif
image: ## Build docker container
$(info Using $(OCI_CMD) for container interface)
@ $(OCI_CMD) build . --file Containerfile --tag $(IMAGE_NAME):$(VERSION) --build-arg borg_version=$(VERSION)
publish: image ## Build docker container and publish to the docker registry
@ $(OCI_CMD) tag $(IMAGE_NAME):$(VERSION) $(IMAGE_REPOSITORY)/$(IMAGE_NAME):$(VERSION)
@ $(OCI_CMD) push $(IMAGE_REPOSITORY)/$(IMAGE_NAME):$(VERSION)
latest: publish ## Build docker container and publish to the docker registry as the latest version
@ $(OCI_CMD) tag $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):latest
@ $(OCI_CMD) tag $(IMAGE_REPOSITORY)/$(IMAGE_NAME):$(VERSION) $(IMAGE_REPOSITORY)/$(IMAGE_NAME):latest
@ $(OCI_CMD) push $(IMAGE_REPOSITORY)/$(IMAGE_NAME):latest