This repository has been archived by the owner on Jan 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathMakefile
44 lines (37 loc) · 1.75 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
ALPINE_VERSION := 3.19.1
CONTAINER_ORGANIZATION := connectical
CONTAINER_IMAGE := taskd
CONTAINER_ARCHITECTURES := linux/amd64,linux/arm/v7,linux/arm64
TAGS := -t quay.io/$(CONTAINER_ORGANIZATION)/$(CONTAINER_IMAGE):master
TAGS += -t ghcr.io/$(CONTAINER_ORGANIZATION)/$(CONTAINER_IMAGE):master
ifdef CIRCLE_TAG
TAGS := -t quay.io/$(CONTAINER_ORGANIZATION)/$(CONTAINER_IMAGE):latest
TAGS += -t ghcr.io/$(CONTAINER_ORGANIZATION)/$(CONTAINER_IMAGE):latest
TAGS += -t quay.io/$(CONTAINER_ORGANIZATION)/$(CONTAINER_IMAGE):${CIRCLE_TAG}
TAGS += -t ghcr.io/$(CONTAINER_ORGANIZATION)/$(CONTAINER_IMAGE):${CIRCLE_TAG}
endif
all: container-build
check-quay-env:
ifndef QUAY_USERNAME
$(error QUAY_USERNAME is undefined)
endif
ifndef QUAY_PASSWORD
$(error QUAY_PASSWORD is undefined)
endif
check-github-registry-env:
ifndef GITHUB_REGISTRY_USERNAME
$(error GITHUB_REGISTRY_USERNAME is undefined)
endif
ifndef GITHUB_REGISTRY_PASSWORD
$(error GITHUB_REGISTRY_PASSWORD is undefined)
endif
container-build:
docker build -t $(CONTAINER_ORGANIZATION)/$(CONTAINER_IMAGE) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) .
container-buildx:
docker buildx build -t $(CONTAINER_ORGANIZATION)/$(CONTAINER_IMAGE) --platform $(CONTAINER_ARCHITECTURES) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) .
container-buildx-push: check-quay-env check-github-registry-env
echo "${QUAY_PASSWORD}" | docker login -u "${QUAY_USERNAME}" --password-stdin quay.io
echo "${GITHUB_REGISTRY_PASSWORD}" | docker login -u "${GITHUB_REGISTRY_USERNAME}" --password-stdin ghcr.io
docker buildx build $(TAGS) --platform $(CONTAINER_ARCHITECTURES) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) --push .
.PHONY: all check-quay-env check-github-registry-env container-build container-buildx container-buildx-push
# vim:ft=make