forked from troian/golang-cross
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (59 loc) · 2.67 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
IMAGE_NAME := oslokommune/golang-cross
GHCR_IMAGE_NAME ?= ghcr.io/$(IMAGE_NAME)
GO_VERSION ?= 1.17.2
TAG_VERSION := v$(GO_VERSION)
GORELEASER_VERSION := 0.184.0
GORELEASER_SHA := 0972c17d94f2a95aafbef0c9f6d01ea774abfb8d37b85778e8cb4885efc24511
OSX_SDK := MacOSX11.1.sdk
OSX_SDK_SUM := 0a9b0bae4623960483d882fb8b7c8fca66e8863ac69d9066bafe0a3d12b67293
OSX_VERSION_MIN := 10.13
OSX_CROSS_COMMIT := 035cc170338b7b252e3f13b0e3ccbf4411bffc41
DEBIAN_FRONTEND := noninteractive
TINI_VERSION ?= v0.19.0
GORELEASER_TAG ?= $(shell git describe --tags --abbrev=0)
SUBIMAGES = linux-amd64
PUSHIMAGES = base \
$(SUBIMAGES)
subimages: $(patsubst %, golang-cross-%,$(SUBIMAGES))
.PHONY: gen-changelog
gen-changelog:
@echo "generating changelog to changelog"
./scripts/genchangelog.sh "$(GORELEASER_TAG)" changelog.md
.PHONY: golang-cross-base
golang-cross-base:
@echo "building $(IMAGE_NAME):$(TAG_VERSION)-$(@:golang-cross-%=%)"
docker build -t $(IMAGE_NAME):$(TAG_VERSION)-$(@:golang-cross-%=%) \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg GORELEASER_VERSION=$(GORELEASER_VERSION) \
--build-arg GORELEASER_SHA=$(GORELEASER_SHA) \
--build-arg TINI_VERSION=$(TINI_VERSION) \
-f Dockerfile.$(@:golang-cross-%=%) .
docker tag $(IMAGE_NAME):$(TAG_VERSION)-$(@:golang-cross-%=%) $(GHCR_IMAGE_NAME):$(TAG_VERSION)-$(@:golang-cross-%=%)
.PHONY: golang-cross-%
golang-cross-%: golang-cross-base
@echo "building $(IMAGE_NAME):$(TAG_VERSION)-$(@:golang-cross-%=%)"
docker build -t $(IMAGE_NAME):$(TAG_VERSION)-$(@:golang-cross-%=%) \
--build-arg GO_VERSION=$(GO_VERSION) \
-f Dockerfile.$(@:golang-cross-%=%) .
docker tag $(IMAGE_NAME):$(TAG_VERSION)-$(@:golang-cross-%=%) $(GHCR_IMAGE_NAME):$(TAG_VERSION)-$(@:golang-cross-%=%)
.PHONY: golang-cross
golang-cross: golang-cross-base
@echo "building $(IMAGE_NAME):$(TAG_VERSION)"
docker build -t $(IMAGE_NAME):$(TAG_VERSION) \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg OSX_SDK=$(OSX_SDK) \
--build-arg OSX_SDK_SUM=$(OSX_SDK_SUM) \
--build-arg OSX_VERSION_MIN=$(OSX_VERSION_MIN) \
--build-arg OSX_CROSS_COMMIT=$(OSX_CROSS_COMMIT) \
--build-arg DEBIAN_FRONTEND=$(DEBIAN_FRONTEND) \
-f Dockerfile.full .
docker tag $(IMAGE_NAME):$(TAG_VERSION) $(GHCR_IMAGE_NAME):$(TAG_VERSION)
docker tag $(IMAGE_NAME):$(TAG_VERSION) $(GHCR_IMAGE_NAME):latest
.PHONY: docker-push-%
docker-push-%:
docker push $(GHCR_IMAGE_NAME):$(TAG_VERSION)-$(@:docker-push-%=%)
docker push $(GHCR_IMAGE_NAME):$(TAG_VERSION)-$(@:docker-push-%=%)
.PHONY: docker-push
docker-push: $(patsubst %, docker-push-%,$(PUSHIMAGES))
docker push $(GHCR_IMAGE_NAME):$(TAG_VERSION)
docker push $(GHCR_IMAGE_NAME):latest