From 1cbc74a6dbb37ce98287faa3bed6e0f37fad11f6 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Tue, 14 Mar 2023 23:08:25 -0400 Subject: [PATCH] Add makefile for build and publication automation --- Makefile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3314d7e --- /dev/null +++ b/Makefile @@ -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