-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathMakefile
131 lines (101 loc) · 4.25 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
VERSION := $(shell git describe --tags --dirty=-modified --always)
REVISION := $(shell git rev-parse HEAD)
LDFLAGS_EXTRA ?= -s -w # default to building stripped executables
LDFLAGS := ${LDFLAGS_EXTRA} -X github.com/skupperproject/skupper/pkg/version.Version=${VERSION}
TESTFLAGS := -v -race -short
GOOS ?= linux
GOARCH ?= amd64
REGISTRY := quay.io/skupper
IMAGE_TAG := v2-dev
PLATFORMS ?= linux/amd64,linux/arm64
CONTAINERFILES := Dockerfile.cli Dockerfile.kube-adaptor Dockerfile.controller Dockerfile.network-observer
SHARED_IMAGE_LABELS = \
--label "org.opencontainers.image.created=$(shell TZ=GMT date --iso-8601=seconds)" \
--label "org.opencontainers.image.url=https://skupper.io/" \
--label "org.opencontainers.image.documentation=https://skupper.io/" \
--label "org.opencontainers.image.source=https://github.com/skupperproject/skupper" \
--label "org.opencontainers.image.version=${VERSION}" \
--label "org.opencontainers.image.revision=${REVISION}" \
--label "org.opencontainers.image.licenses=Apache-2.0"
DOCKER := docker
SKOPEO := skopeo
PODMAN := podman
all: build-cli build-kube-adaptor build-controller build-network-observer update-helm-crd
build-cli:
GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags="${LDFLAGS}" -o skupper ./cmd/skupper
build-controller:
GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags="${LDFLAGS}" -o controller ./cmd/controller
build-kube-adaptor:
GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags="${LDFLAGS}" -o kube-adaptor ./cmd/kube-adaptor
build-network-observer:
GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags="${LDFLAGS}" -o network-observer ./cmd/network-observer
build-doc-generator:
GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags="${LDFLAGS}" -o generate-doc ./internal/cmd/generate-doc
## native/default container image builds
docker-build: $(patsubst Dockerfile.%,docker-build-%,$(CONTAINERFILES))
docker-build-%: Dockerfile.%
${DOCKER} build $(SHARED_IMAGE_LABELS) -t "${REGISTRY}/$*:${IMAGE_TAG}" -f $< .
podman-build: $(patsubst Dockerfile.%,podman-build-%,$(CONTAINERFILES))
podman-build-%: Dockerfile.%
${PODMAN} build $(SHARED_IMAGE_LABELS) -t "${REGISTRY}/$*:${IMAGE_TAG}" -f $< .
## multi-platform container images built in docker buildkit builder and
# exported to oci archive format.
multiarch-oci: $(patsubst Dockerfile.%,multiarch-oci-%,$(CONTAINERFILES))
multiarch-oci-%: Dockerfile.% oci-archives
${DOCKER} buildx build \
"--output=type=oci,dest=$(shell pwd)/oci-archives/$*.tar" \
-t "${REGISTRY}/$*:${IMAGE_TAG}" \
$(SHARED_IMAGE_LABELS) \
--platform ${PLATFORMS} \
-f $< .
## push multiarch-oci images to a registry using skopeo
push-multiarch-oci: $(patsubst Dockerfile.%,push-multiarch-oci-%,$(CONTAINERFILES))
push-multiarch-oci-%: ./oci-archives/%.tar
${SKOPEO} copy --all \
oci-archive:$< \
"docker://${REGISTRY}/$*:${IMAGE_TAG}"
## Load images from oci-archive into local image storage
podman-load-oci:
for archive in ./oci-archives/*.tar; do ${PODMAN} load < "$$archive"; done
## Has unfortunate podman dependency; docker image load does not load OCI archives, while podman does.
docker-load-oci:
for archive in ./oci-archives/*.tar; do \
img=$$(${PODMAN} load -q < "$$archive" | awk -F": " '{print $$2}') \
&& ${PODMAN} image save "$$img" | ${DOCKER} load; \
done
## Print fully qualified image names by arch
describe-multiarch-oci:
@scripts/oci-index-archive-info.sh amd64 arm64
oci-archives:
mkdir -p oci-archives
format:
go fmt ./...
generate-client:
./scripts/update-codegen.sh
force-generate-client:
FORCE=true ./scripts/update-codegen.sh
vet:
go vet ./...
.PHONY: test
test:
go test ${TESTFLAGS} ./...
.PHONY: cover
cover:
go test ${TESTFLAGS} \
-cover \
-coverprofile cover.out \
./...
generate-manifest: build-cli
./skupper version -o json > manifest.json
generate-doc: build-doc-generator
./generate-doc ./doc/cli
update-helm-crd:
./scripts/update-helm-crds.sh
generate-skupper-deployment-cluster-scoped:
helm template ./charts/skupper-setup --include-crds --set scope=cluster > skupper-setup-cluster-scope.yaml
generate-skupper-deployment-namespace-scoped:
helm template ./charts/skupper-setup --include-crds --set scope=namespace > skupper-setup-namespace-scope.yaml
clean:
rm -rf skupper controller kube-adaptor \
network-observer generate-doc \
cover.out oci-archives