forked from discobean/route53-sidecar
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
54 lines (43 loc) · 1.79 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
# VERSION is the version we should download and use.
VERSION:=$(shell git rev-parse --short HEAD)
# DOCKER is the docker image repo we need to push to.
DOCKER_REPO:=defangio
DOCKER_USER:=defangio
DOCKER_IMAGE_NAME:=$(DOCKER_REPO)/route53-sidecar
DOCKER_IMAGE_ARM64:=$(DOCKER_IMAGE_NAME):arm64-$(VERSION)
DOCKER_IMAGE_AMD64:=$(DOCKER_IMAGE_NAME):amd64-$(VERSION)
BUILD_FLAGS:=-ldflags "-s -w -X main.version=$(VERSION)" -trimpath
.PHONY: help
help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/:.*##/:/'
.PHONY: ensure
ensure: ## Run go get -u
go get -t -u ./...
.PHONY: build
build: ensure ## Build a local binary
go build $(BUILD_FLAGS) -o route53-sidecar
.PHONY: build-amd64
build-amd64: ensure
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o route53-sidecar
.PHONY: build-arm64
build-arm64: ensure
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(BUILD_FLAGS) -o route53-sidecar
.PHONY: docker-amd64
docker-amd64: build-amd64
docker build --platform linux/amd64 -t route53-sidecar -t $(DOCKER_IMAGE_AMD64) .
.PHONY: docker-arm64
docker-arm64: build-arm64
docker build --platform linux/arm64 -t route53-sidecar -t $(DOCKER_IMAGE_ARM64) .
.PHONY: docker
docker: docker-amd64 docker-arm64 ## Build all docker images and manifest
.PHONY: push
push: docker login ## Push all docker images
docker push $(DOCKER_IMAGE_AMD64)
docker push $(DOCKER_IMAGE_ARM64)
docker manifest create --amend $(DOCKER_IMAGE_NAME):$(VERSION) $(DOCKER_IMAGE_AMD64) $(DOCKER_IMAGE_ARM64)
docker manifest create --amend $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_AMD64) $(DOCKER_IMAGE_ARM64)
docker manifest push --purge $(DOCKER_IMAGE_NAME):$(VERSION)
docker manifest push --purge $(DOCKER_IMAGE_NAME):latest
.PHONY: login
login: ## Login to docker
@docker login -u $(DOCKER_USER)