This repository has been archived by the owner on Jan 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
/
istio-cni-docker.mk
84 lines (66 loc) · 3.58 KB
/
istio-cni-docker.mk
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
## Copyright 2018 Istio Authors
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
.PHONY: docker docker.save
# Docker target will build the go binaries and package the docker for local testing.
# It does not upload to a registry.
docker: build docker.all
$(ISTIO_DOCKER) $(ISTIO_DOCKER_TAR):
mkdir -p $@
.SECONDEXPANSION: #allow $@ to be used in dependency list
# directives to copy files to docker scratch directory
# tell make which files are copied from go/out
DOCKER_FILES_FROM_ISTIO_OUT:=istio-cni istio-cni-repair
$(foreach FILE,$(DOCKER_FILES_FROM_ISTIO_OUT), \
$(eval $(ISTIO_DOCKER)/$(FILE): $(ISTIO_OUT)/$(FILE) | $(ISTIO_DOCKER); cp $$< $$(@D)))
# tell make which files are copied from the source tree
DOCKER_FILES_FROM_SOURCE:=tools/packaging/common/istio-iptables.sh
$(foreach FILE,$(DOCKER_FILES_FROM_SOURCE), \
$(eval $(ISTIO_DOCKER)/$(notdir $(FILE)): $(FILE) | $(ISTIO_DOCKER); cp $(FILE) $$(@D)))
docker.install-cni: $(ISTIO_OUT)/istio-cni $(ISTIO_OUT)/istio-cni-repair \
tools/packaging/common/istio-iptables.sh \
deployments/kubernetes/install/scripts/install-cni.sh \
deployments/kubernetes/install/scripts/istio-cni.conf.default \
deployments/kubernetes/Dockerfile.install-cni \
deployments/kubernetes/install/scripts/filter.jq
mkdir -p $(ISTIO_DOCKER)/install-cni
cp $^ $(ISTIO_DOCKER)/install-cni
time docker build -t $(HUB)/install-cni:$(TAG) \
-f $(ISTIO_DOCKER)/install-cni/Dockerfile.install-cni \
$(ISTIO_DOCKER)/install-cni
DOCKER_TARGETS:=docker.install-cni
# create a DOCKER_PUSH_TARGETS that's each of DOCKER_TARGETS with a push. prefix
DOCKER_PUSH_TARGETS:=
$(foreach TGT,$(DOCKER_TARGETS),$(eval DOCKER_PUSH_TARGETS+=push.$(TGT)))
# for each docker.XXX target create a push.docker.XXX target that pushes
# the local docker image to another hub
# a possible optimization is to use tag.$(TGT) as a dependency to do the tag for us
$(foreach TGT,$(DOCKER_TARGETS),$(eval push.$(TGT): | $(TGT) ; \
time (docker push $(HUB)/$(subst docker.,,$(TGT)):$(TAG))))
# create a DOCKER_PUSH_TARGETS that's each of DOCKER_TARGETS with a push. prefix
DOCKER_PUSH_TARGETS:=
$(foreach TGT,$(DOCKER_TARGETS),$(eval DOCKER_PUSH_TARGETS+=push.$(TGT)))
# Will build and push docker images.
docker.push: $(DOCKER_PUSH_TARGETS)
# This target will package all docker images used in test and release, without re-building
# go binaries. It is intended for CI/CD systems where the build is done in separate job.
docker.all: $(DOCKER_TARGETS)
# create a DOCKER_TAR_TARGETS that's each of DOCKER_TARGETS with a tar. prefix
DOCKER_TAR_TARGETS:=
$(foreach TGT,$(DOCKER_TARGETS),$(eval tar.$(TGT): $(TGT) | $(ISTIO_DOCKER_TAR) ; \
time (docker save -o ${ISTIO_DOCKER_TAR}/$(subst docker.,,$(TGT)).tar $(HUB)/$(subst docker.,,$(TGT)):$(TAG) && \
gzip ${ISTIO_DOCKER_TAR}/$(subst docker.,,$(TGT)).tar)))
# create a DOCKER_TAR_TARGETS that's each of DOCKER_TARGETS with a tar. prefix DOCKER_TAR_TARGETS:=
$(foreach TGT,$(DOCKER_TARGETS),$(eval DOCKER_TAR_TARGETS+=tar.$(TGT)))
# this target saves a tar.gz of each docker image to ${ISTIO_OUT}/docker/
docker.save: $(DOCKER_TAR_TARGETS)