-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Congrool <[email protected]>
- Loading branch information
Showing
10 changed files
with
118 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 1 addition & 7 deletions
8
.../dockerfiles/Dockerfile.yurt-node-servant → hack/dockerfiles/Dockerfile.node-servant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
# multi-arch image building for yurt-node-servant | ||
|
||
FROM --platform=${BUILDPLATFORM} golang:1.17.1 as builder | ||
ADD . /build | ||
ARG TARGETOS TARGETARCH GIT_VERSION GOPROXY MIRROR_REPO | ||
WORKDIR /build/ | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GIT_VERSION=${GIT_VERSION} make build WHAT=cmd/yurt-node-servant | ||
|
||
FROM --platform=${TARGETPLATFORM} alpine:3.14 | ||
ARG TARGETOS TARGETARCH MIRROR_REPO | ||
RUN if [ ! -z "${MIRROR_REPO+x}" ]; then sed -i "s/dl-cdn.alpinelinux.org/${MIRROR_REPO}/g" /etc/apk/repositories; fi && \ | ||
apk add ca-certificates bash libc6-compat && update-ca-certificates && rm /var/cache/apk/* | ||
COPY --from=builder /build/_output/local/bin/${TARGETOS}/${TARGETARCH}/yurt-node-servant /usr/local/bin/node-servant | ||
COPY ./_output/local/bin/${TARGETOS}/${TARGETARCH}/yurt-node-servant /usr/local/bin/node-servant | ||
COPY hack/lib/node-servant-entry.sh /usr/local/bin/entry.sh | ||
RUN chmod +x /usr/local/bin/entry.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
# multi-arch image building for yurt-controller-manager | ||
|
||
FROM --platform=${BUILDPLATFORM} golang:1.17.1 as builder | ||
ADD . /build | ||
ARG TARGETOS TARGETARCH GIT_VERSION GOPROXY MIRROR_REPO | ||
WORKDIR /build/ | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GIT_VERSION=${GIT_VERSION} make build WHAT=cmd/yurt-controller-manager | ||
|
||
FROM --platform=${TARGETPLATFORM} alpine:3.14 | ||
ARG TARGETOS TARGETARCH MIRROR_REPO | ||
RUN if [ ! -z "${MIRROR_REPO+x}" ]; then sed -i "s/dl-cdn.alpinelinux.org/${MIRROR_REPO}/g" /etc/apk/repositories; fi && \ | ||
apk add ca-certificates bash libc6-compat && update-ca-certificates && rm /var/cache/apk/* | ||
COPY --from=builder /build/_output/local/bin/${TARGETOS}/${TARGETARCH}/yurt-controller-manager /usr/local/bin/yurt-controller-manager | ||
COPY ./_output/local/bin/${TARGETOS}/${TARGETARCH}/yurt-controller-manager /usr/local/bin/yurt-controller-manager | ||
ENTRYPOINT ["/usr/local/bin/yurt-controller-manager"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
# multi-arch image building for yurt-tunnel-agent | ||
|
||
FROM --platform=${BUILDPLATFORM} golang:1.17.1 as builder | ||
ADD . /build | ||
ARG TARGETOS TARGETARCH GIT_VERSION GOPROXY MIRROR_REPO | ||
WORKDIR /build/ | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GIT_VERSION=${GIT_VERSION} make build WHAT=cmd/yurt-tunnel-agent | ||
|
||
FROM --platform=${TARGETPLATFORM} alpine:3.14 | ||
ARG TARGETOS TARGETARCH MIRROR_REPO | ||
RUN if [ ! -z "${MIRROR_REPO+x}" ]; then sed -i "s/dl-cdn.alpinelinux.org/${MIRROR_REPO}/g" /etc/apk/repositories; fi && \ | ||
apk add ca-certificates bash libc6-compat && update-ca-certificates && rm /var/cache/apk/* | ||
COPY --from=builder /build/_output/local/bin/${TARGETOS}/${TARGETARCH}/yurt-tunnel-agent /usr/local/bin/yurt-tunnel-agent | ||
COPY ./_output/local/bin/${TARGETOS}/${TARGETARCH}/yurt-tunnel-agent /usr/local/bin/yurt-tunnel-agent | ||
ENTRYPOINT ["/usr/local/bin/yurt-tunnel-agent"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
# multi-arch image building for yurt-tunnel-server | ||
|
||
FROM --platform=${BUILDPLATFORM} golang:1.17.1 as builder | ||
ADD . /build | ||
ARG TARGETOS TARGETARCH GIT_VERSION GOPROXY MIRROR_REPO | ||
WORKDIR /build/ | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GIT_VERSION=${GIT_VERSION} make build WHAT=cmd/yurt-tunnel-server | ||
|
||
FROM --platform=${TARGETPLATFORM} alpine:3.14 | ||
ARG TARGETOS TARGETARCH MIRROR_REPO | ||
RUN if [ ! -z "${MIRROR_REPO+x}" ]; then sed -i "s/dl-cdn.alpinelinux.org/${MIRROR_REPO}/g" /etc/apk/repositories; fi && \ | ||
apk add ca-certificates bash libc6-compat iptables ip6tables conntrack-tools && update-ca-certificates && rm /var/cache/apk/* | ||
COPY --from=builder /build/_output/local/bin/${TARGETOS}/${TARGETARCH}/yurt-tunnel-server /usr/local/bin/yurt-tunnel-server | ||
COPY ./_output/local/bin/${TARGETOS}/${TARGETARCH}/yurt-tunnel-server /usr/local/bin/yurt-tunnel-server | ||
ENTRYPOINT ["/usr/local/bin/yurt-tunnel-server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
# multi-arch image building for yurthub | ||
|
||
FROM --platform=${BUILDPLATFORM} golang:1.17.1 as builder | ||
ADD . /build | ||
ARG TARGETOS TARGETARCH GIT_VERSION GOPROXY MIRROR_REPO | ||
WORKDIR /build/ | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GIT_VERSION=${GIT_VERSION} make build WHAT=cmd/yurthub | ||
|
||
FROM --platform=${TARGETPLATFORM} alpine:3.14 | ||
ARG TARGETOS TARGETARCH MIRROR_REPO | ||
RUN if [ ! -z "${MIRROR_REPO+x}" ]; then sed -i "s/dl-cdn.alpinelinux.org/${MIRROR_REPO}/g" /etc/apk/repositories; fi && \ | ||
apk add ca-certificates bash libc6-compat iptables ip6tables && update-ca-certificates && rm /var/cache/apk/* | ||
COPY --from=builder /build/_output/local/bin/${TARGETOS}/${TARGETARCH}/yurthub /usr/local/bin/yurthub | ||
COPY ./_output/local/bin/${TARGETOS}/${TARGETARCH}/yurthub /usr/local/bin/yurthub | ||
ENTRYPOINT ["/usr/local/bin/yurthub"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2023 The OpenYurt 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. | ||
|
||
set -x | ||
set -e | ||
|
||
YURT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" | ||
source "${YURT_ROOT}/hack/lib/init.sh" | ||
source "${YURT_ROOT}/hack/lib/build.sh" | ||
|
||
readonly IMAGE_TARGETS=( | ||
yurt-controller-manager | ||
yurt-tunnel-agent | ||
yurt-tunnel-server | ||
yurt-node-servant | ||
yurthub | ||
) | ||
|
||
http_proxy=${http_proxy:-} | ||
https_proxy=${https_proxy:-} | ||
targets=${@:-${IMAGE_TARGETS[@]}} | ||
REGION=${REGION:-} | ||
IMAGE_REPO=${IMAGE_REPO:-"openyurt"} | ||
IMAGE_TAG=${IMAGE_TAG:-$(get_image_tag)} | ||
DOCKER_BUILD_ARGS="" | ||
BUILD_BASE_IMAGE="golang:1.17.1" | ||
BUILD_GOPROXY=$(go env GOPROXY) | ||
GOPROXY_CN="https://goproxy.cn" | ||
APKREPO_MIRROR_CN="mirrors.aliyun.com" | ||
|
||
if [ "${REGION}" == "cn" ]; then | ||
BUILD_GOPROXY=${GOPROXY_CN} | ||
DOCKER_BUILD_ARGS="${DOCKER_BUILD_ARGS} --build-arg MIRROR_REPO=${APKREPO_MIRROR_CN}" | ||
fi | ||
|
||
if [[ ! -z ${http_proxy} ]]; then | ||
DOCKER_BUILD_ARGS="${DOCKER_BUILD_ARGS} --build-arg http_proxy=${http_proxy}" | ||
fi | ||
|
||
if [[ ! -z ${https_proxy} ]]; then | ||
DOCKER_BUILD_ARGS="${DOCKER_BUILD_ARGS} --build-arg https_proxy=${https_proxy}" | ||
fi | ||
|
||
if [[ ! -z ${TARGET_PLATFORMS} ]]; then | ||
IFS="/" read -r TARGETOS TARGETARCH <<< "${TARGET_PLATFORMS}" | ||
else | ||
echo "TARGET_PLATFORMS should be specified" | ||
exit -1 | ||
fi | ||
|
||
# build binaries within docker container | ||
docker run \ | ||
--rm --name openyurt-build \ | ||
--mount type=bind,dst=/build/,src=${YURT_ROOT} \ | ||
--workdir=/build/ \ | ||
--env GOPROXY=${BUILD_GOPROXY} \ | ||
--env GOOS=${TARGETOS} \ | ||
--env GOARCH=${TARGETARCH} \ | ||
${BUILD_BASE_IMAGE} \ | ||
./hack/make-rules/build.sh ${targets[@]} | ||
|
||
# build images | ||
for image in ${targets[@]}; do | ||
# The image name and binary name of node-servant | ||
# are not same. So we have to this translation. | ||
if [[ ${image} == "yurt-node-servant" ]]; then | ||
image="node-servant" | ||
fi | ||
|
||
docker buildx build \ | ||
--no-cache \ | ||
--load ${DOCKER_BUILD_ARGS} \ | ||
--platform ${TARGET_PLATFORMS} \ | ||
--file ${YURT_ROOT}/hack/dockerfiles/Dockerfile.${image} \ | ||
--tag ${IMAGE_REPO}/${image}:${IMAGE_TAG} \ | ||
${YURT_ROOT} | ||
done |