forked from lukaskroepfl/monitoring-nginx-proxy-companion
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
77 lines (61 loc) · 2.16 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
.PHONY: .assert_colima_runs .assert_mybuilder_exists .assert_golang_exists .create_git_tag
DOCKERX_BUILDER ?= mybuilder
ARCH_TARGET ?= linux/amd64
IMAGE ?= registry.komm.link/base/docker/nginx-proxy-metrics
TAG ?= latest
NEXT_VERSION ?= 2023-6
GHCR_IMAGE ?= ghcr.io/pommes/nginx-proxy-metrics
GHCR_NEXT_VERSION ?= v1.1.0
# RUN TARGETS ##############
build_go: .assert_golang_exists
@echo "=== Building main"
go mod tidy
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./.build/main ./cmd
build_image_latest: build_go .assert_colima_runs .assert_mybuilder_exists
@echo "=== Building image: $(IMAGE):$(TAG) ($(ARCH_TARGET))"
export DOCKER_CLI_EXPERIMENTAL=enabled
@docker buildx version
docker buildx build --platform $(ARCH_TARGET) -t $(IMAGE):$(TAG) . --load
docker push ${IMAGE}:${TAG}
build_image_latest_ghcr:
export IMAGE=$(GHCR_IMAGE) && \
export TAG=latest && \
$(MAKE) build_image_latest
build_image_tag: .create_git_tag
$(MAKE) build_image_latest && \
export TAG=$(NEXT_VERSION) && \
$(MAKE) build_image_latest
release_ghcr:
export NEXT_VERSION=$(GHCR_NEXT_VERSION) && \
$(MAKE) .create_git_tag && \
git push origin $(GHCR_NEXT_VERSION)
# LIB TARGETS ##############
.create_git_tag:
@if git tag -a $(NEXT_VERSION) -m "tag: $(NEXT_VERSION)"; then \
echo "--- git tag '$(NEXT_VERSION)' not found. Creating tag ..."; \
else \
echo "Could not create git tag '$(NEXT_VERSION)'"; \
exit 1; \
fi
.assert_golang_exists:
@if which go 1>/dev/null 2>&1; then \
echo "--- go found."; \
else \
echo "!!! go not found. Intalling via homebrew..."; \
brew install golang; \
fi
.assert_colima_runs:
@if colima status 1>/dev/null 2>&1; then \
echo "--- colima is already running."; \
else \
echo "!!! colima is not running. Starting colima..."; \
colima start; \
fi
.assert_mybuilder_exists: .assert_colima_runs
@if docker buildx inspect ${DOCKERX_BUILDER} 1>/dev/null 2>&1; then \
echo "--- buildx builder '${DOCKERX_BUILDER}' found."; \
else \
echo "!!! buildx builder '${DOCKERX_BUILDER}' not found. Creating builder..."; \
docker buildx create --use --name ${DOCKERX_BUILDER}; \
docker buildx inspect ${DOCKERX_BUILDER} --bootstrap; \
fi