support multi arch image (#483)

This commit is contained in:
澄潭
2023-08-14 20:41:09 +08:00
committed by GitHub
parent ec229e69ac
commit 8048436604
5 changed files with 191 additions and 20 deletions

View File

@@ -0,0 +1,91 @@
diff -Naur istio/pilot/docker/Dockerfile.pilot istio-new/pilot/docker/Dockerfile.pilot
--- istio/pilot/docker/Dockerfile.pilot 2023-08-11 18:01:44.000000000 +0800
+++ istio-new/pilot/docker/Dockerfile.pilot 2023-08-11 17:50:02.000000000 +0800
@@ -6,8 +6,10 @@
ARG HUB
+ARG TARGETARCH
+
# The following section is used as base image if BASE_DISTRIBUTION=debug
-FROM ${HUB:-gcr.io/istio-release}/base:${BASE_VERSION} as debug
+FROM ${HUB:-gcr.io/istio-release}/base:${BASE_VERSION}-${TARGETARCH} as debug
# The following section is used as base image if BASE_DISTRIBUTION=distroless
# FROM gcr.io/istio-release/distroless:${BASE_VERSION} as distroless
@@ -16,7 +18,6 @@
# hadolint ignore=DL3006
FROM ${BASE_DISTRIBUTION:-debug}
-ARG TARGETARCH
COPY ${TARGETARCH:-amd64}/pilot-discovery /usr/local/bin/pilot-discovery
# Copy templates for bootstrap generation.
diff -Naur istio/pilot/docker/Dockerfile.proxyv2 istio-new/pilot/docker/Dockerfile.proxyv2
--- istio/pilot/docker/Dockerfile.proxyv2 2023-08-11 18:01:43.000000000 +0800
+++ istio-new/pilot/docker/Dockerfile.proxyv2 2023-08-11 17:57:08.000000000 +0800
@@ -6,8 +6,10 @@
ARG HUB
+ARG TARGETARCH
+
# The following section is used as base image if BASE_DISTRIBUTION=debug
-FROM ${HUB:-gcr.io/istio-release}/base:${BASE_VERSION} as debug
+FROM ${HUB:-gcr.io/istio-release}/base:${BASE_VERSION}-${TARGETARCH} as debug
# The following section is used as base image if BASE_DISTRIBUTION=distroless
# This image is a custom built debian11 distroless image with multiarchitecture support.
@@ -25,13 +27,13 @@
ARG proxy_version
ARG istio_version
ARG SIDECAR=envoy
+ARG TARGETARCH
# Copy Envoy bootstrap templates used by pilot-agent
COPY envoy_bootstrap.json /var/lib/istio/envoy/envoy_bootstrap_tmpl.json
COPY gcp_envoy_bootstrap.json /var/lib/istio/envoy/gcp_envoy_bootstrap_tmpl.json
# Install Envoy.
-ARG TARGETARCH
COPY ${TARGETARCH:-amd64}/${SIDECAR} /usr/local/bin/${SIDECAR}
# Environment variable indicating the exact proxy sha - for debugging or version-specific configs
@@ -39,7 +41,6 @@
# Environment variable indicating the exact build, for debugging
ENV ISTIO_META_ISTIO_VERSION $istio_version
-ARG TARGETARCH
COPY ${TARGETARCH:-amd64}/pilot-agent /usr/local/bin/pilot-agent
# COPY stats-filter.wasm /etc/istio/extensions/stats-filter.wasm
diff -Naur istio/tools/istio-docker.mk istio-new/tools/istio-docker.mk
--- istio/tools/istio-docker.mk 2023-08-11 18:01:44.000000000 +0800
+++ istio-new/tools/istio-docker.mk 2023-08-11 17:50:02.000000000 +0800
@@ -85,7 +85,7 @@
# Default proxy image.
docker.proxyv2: BUILD_PRE=&& chmod 644 envoy_bootstrap.json gcp_envoy_bootstrap.json
-docker.proxyv2: BUILD_ARGS=--build-arg proxy_version=istio-proxy:${PROXY_REPO_SHA} --build-arg istio_version=${VERSION} --build-arg BASE_VERSION=${BASE_VERSION} --build-arg SIDECAR=${SIDECAR} --build-arg HUB=${HUB}
+docker.proxyv2: BUILD_ARGS=--build-arg proxy_version=istio-proxy:${PROXY_REPO_SHA} --build-arg istio_version=${VERSION} --build-arg BASE_VERSION=${BASE_VERSION} --build-arg SIDECAR=${SIDECAR} --build-arg HUB=${HUB} --build-arg TARGETARCH=${TARGET_ARCH}
docker.proxyv2: ${ISTIO_ENVOY_BOOTSTRAP_CONFIG_DIR}/envoy_bootstrap.json
docker.proxyv2: ${ISTIO_ENVOY_BOOTSTRAP_CONFIG_DIR}/gcp_envoy_bootstrap.json
docker.proxyv2: $(ISTIO_ENVOY_LINUX_RELEASE_DIR)/${SIDECAR}
@@ -98,7 +98,7 @@
$(DOCKER_RULE)
docker.pilot: BUILD_PRE=&& chmod 644 envoy_bootstrap.json gcp_envoy_bootstrap.json
-docker.pilot: BUILD_ARGS=--build-arg BASE_VERSION=${BASE_VERSION} --build-arg HUB=${HUB}
+docker.pilot: BUILD_ARGS=--build-arg BASE_VERSION=${BASE_VERSION} --build-arg HUB=${HUB} --build-arg TARGETARCH=${TARGET_ARCH}
docker.pilot: ${ISTIO_ENVOY_BOOTSTRAP_CONFIG_DIR}/envoy_bootstrap.json
docker.pilot: ${ISTIO_ENVOY_BOOTSTRAP_CONFIG_DIR}/gcp_envoy_bootstrap.json
docker.pilot: ${ISTIO_ENVOY_BOOTSTRAP_CONFIG_DIR}/higress-pilot-start.sh
@@ -324,7 +324,7 @@
# This can be done with DOCKER_BUILD_VARIANTS="default debug" as well, but at the expense of building twice vs building once and tagging twice
INCLUDE_UNTAGGED_DEFAULT ?= false
DEFAULT_DISTRIBUTION=debug
-DOCKER_RULE ?= $(foreach VARIANT,$(DOCKER_BUILD_VARIANTS), time (mkdir -p $(DOCKER_BUILD_TOP)/$@ && TARGET_ARCH=$(TARGET_ARCH) ./tools/docker-copy.sh $^ $(DOCKER_BUILD_TOP)/$@ && cd $(DOCKER_BUILD_TOP)/$@ $(BUILD_PRE) && docker build $(BUILD_ARGS) --build-arg BASE_DISTRIBUTION=$(call normalize-tag,$(VARIANT)) -t $(HUB)/$(subst docker.,,$@):$(TAG)$(call variant-tag,$(VARIANT)) -f Dockerfile$(suffix $@) . ); )
+DOCKER_RULE ?= $(foreach VARIANT,$(DOCKER_BUILD_VARIANTS), time (mkdir -p $(DOCKER_BUILD_TOP)/$@ && TARGET_ARCH=$(TARGET_ARCH) ./tools/docker-copy.sh $^ $(DOCKER_BUILD_TOP)/$@ && cd $(DOCKER_BUILD_TOP)/$@ $(BUILD_PRE) && docker build $(BUILD_ARGS) --build-arg BASE_DISTRIBUTION=$(call normalize-tag,$(VARIANT)) -t $(HUB)/$(subst docker.,,$@):$(TAG)$(call variant-tag,$(VARIANT))-$(TARGET_ARCH) -f Dockerfile$(suffix $@) . ); )
RENAME_TEMPLATE ?= mkdir -p $(DOCKER_BUILD_TOP)/$@ && cp $(ECHO_DOCKER)/$(VM_OS_DOCKERFILE_TEMPLATE) $(DOCKER_BUILD_TOP)/$@/Dockerfile$(suffix $@)
# This target will package all docker images used in test and release, without re-building