init infras

This commit is contained in:
zty98751
2022-11-01 14:34:57 +08:00
parent b57a8e141c
commit 1d9c2dec62
71 changed files with 14636 additions and 0 deletions

17
docker/Dockerfile.higress Normal file
View File

@@ -0,0 +1,17 @@
# BASE_DISTRIBUTION is used to switch between the old base distribution and distroless base images
ARG BASE_DISTRIBUTION=debug
# Version is the base image version from the TLD Makefile
ARG BASE_VERSION=latest
ARG HUB
# The following section is used as base image if BASE_DISTRIBUTION=debug
FROM ${HUB}/base:${BASE_VERSION}
ARG TARGETARCH
COPY ${TARGETARCH:-amd64}/higress /usr/local/bin/higress
USER 1337:1337
ENTRYPOINT ["/usr/local/bin/higress"]

60
docker/docker-copy.sh Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
INPUTS=("${@}")
TARGET_ARCH=${TARGET_ARCH:-amd64}
DOCKER_WORKING_DIR=${INPUTS[${#INPUTS[@]}-1]}
FILES=("${INPUTS[@]:0:${#INPUTS[@]}-1}")
set -eu;
function may_copy_into_arch_named_sub_dir() {
FILE=${1}
COPY_ARCH_RELATED=${COPY_ARCH_RELATED:-1}
FILE_INFO=$(file "${FILE}" || true)
# when file is an `ELF 64-bit LSB`,
# will put an arch named sub dir
# like
# arm64/
# amd64/
if [[ ${FILE_INFO} == *"ELF 64-bit LSB"* ]]; then
chmod 755 "${FILE}"
case ${FILE_INFO} in
*x86-64*)
mkdir -p "${DOCKER_WORKING_DIR}/amd64/" && cp -rp "${FILE}" "${DOCKER_WORKING_DIR}/amd64/"
;;
*aarch64*)
mkdir -p "${DOCKER_WORKING_DIR}/arm64/" && cp -rp "${FILE}" "${DOCKER_WORKING_DIR}/arm64/"
;;
*)
cp -rp "${FILE}" "${DOCKER_WORKING_DIR}"
;;
esac
if [[ ${COPY_ARCH_RELATED} == 1 ]]; then
# if other arch files exists, should copy too.
for ARCH in "amd64" "arm64"; do
# like file `out/linux_amd64/pilot-discovery`
# should check `out/linux_arm64/pilot-discovery` exists then do copy
FILE_ARCH_RELATED=${FILE/linux_${TARGET_ARCH}/linux_${ARCH}}
if [[ ${FILE_ARCH_RELATED} != "${FILE}" && -f ${FILE_ARCH_RELATED} ]]; then
COPY_ARCH_RELATED=0 may_copy_into_arch_named_sub_dir "${FILE_ARCH_RELATED}"
fi
done
fi
else
cp -rp "${FILE}" "${DOCKER_WORKING_DIR}"
fi
}
for FILE in "${FILES[@]}"; do
may_copy_into_arch_named_sub_dir "${FILE}"
done
ls "${DOCKER_WORKING_DIR}";

17
docker/docker.mk Normal file
View File

@@ -0,0 +1,17 @@
docker.higress: BUILD_ARGS=--build-arg BASE_VERSION=${BASE_VERSION} --build-arg HUB=${HUB}
docker.higress: $(OUT_LINUX)/higress
docker.higress: docker/Dockerfile.higress
$(HIGRESS_DOCKER_RULE)
# DOCKER_BUILD_VARIANTS ?=debug distroless
# Base images have two different forms:
# * "debug", suffixed as -debug. This is a ubuntu based image with a bunch of debug tools
# * "distroless", suffixed as -distroless. This is distroless image - no shell. proxyv2 uses a custom one with iptables added
# * "default", no suffix. This is currently "debug"
DOCKER_BUILD_VARIANTS ?= default
DOCKER_ALL_VARIANTS ?= debug distroless
# If INCLUDE_UNTAGGED_DEFAULT is set, then building the "DEFAULT_DISTRIBUTION" variant will publish both <tag>-<variant> and <tag>
# 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
HIGRESS_DOCKER_RULE ?= $(foreach VARIANT,$(DOCKER_BUILD_VARIANTS), time (mkdir -p $(HIGRESS_DOCKER_BUILD_TOP)/$@ && TARGET_ARCH=$(TARGET_ARCH) ./docker/docker-copy.sh $^ $(HIGRESS_DOCKER_BUILD_TOP)/$@ && cd $(HIGRESS_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 $@) . ); )