-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(dockerfiles/bases): support build multi-arch base image with…
… different dockerfiles (#355) Signed-off-by: wuhuizuo <wuhuizuo@126.com> --------- Signed-off-by: wuhuizuo <wuhuizuo@126.com>
- Loading branch information
Showing
49 changed files
with
272 additions
and
204 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
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,66 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
build() { | ||
dockerfile="${1:-Dockerfile}" | ||
|
||
case "${PLATFORMS}" in | ||
linux/amd64) | ||
echo "building for linux/amd64 platform..." | ||
docker build --tag=$IMAGE --platform=$PLATFORMS --target amd64 . -f "$dockerfile" | ||
if $PUSH_IMAGE; then | ||
docker push $IMAGE | ||
fi | ||
;; | ||
linux/arm64) | ||
echo "building for linux/arm64 platform..." | ||
docker build --tag=$IMAGE --platform=$PLATFORMS --target arm64 . -f "$dockerfile" | ||
if $PUSH_IMAGE; then | ||
docker push $IMAGE | ||
fi | ||
;; | ||
linux/arm64,linux/amd64 | linux/amd64,linux/arm64) | ||
echo "building for linux/arm64 and linux/amd64 platforms..." | ||
docker build --tag=${IMAGE}_linux_amd64 --platform=linux/amd64 --target amd64 . -f "$dockerfile" | ||
docker build --tag=${IMAGE}_linux_arm64 --platform=linux/arm64 --target arm64 . -f "$dockerfile" | ||
if $PUSH_IMAGE; then | ||
docker push ${IMAGE}_linux_amd64 | ||
docker push ${IMAGE}_linux_arm64 | ||
|
||
# compose manifest for multi-arch image. | ||
pushed_repo="${IMAGE%:*}" | ||
tag="${IMAGE#*:}" | ||
yq -n ".tags = [\"$tag\"]" >manifest.yaml | ||
|
||
# linux/amd64 | ||
manifest-tool inspect --raw ${IMAGE}_linux_amd64 >manifest_linux_amd64.json | ||
yq -i '.manifests += [{}]' manifest.yaml | ||
digest=$(jq -r '.digest' manifest_linux_amd64.json) | ||
yq -i ".manifests[-1].image = \"${pushed_repo}@${digest}\"" manifest.yaml | ||
yq -i '.manifests[-1].platform.os = "linux"' manifest.yaml | ||
yq -i '.manifests[-1].platform.architecture = "amd64"' manifest.yaml | ||
# linux/arm64 | ||
manifest-tool inspect --raw ${IMAGE}_linux_arm64 >manifest_linux_arm64.json | ||
yq -i '.manifests += [{}]' manifest.yaml | ||
digest=$(jq -r '.digest' manifest_linux_arm64.json) | ||
yq -i ".manifests[-1].image = \"${pushed_repo}@${digest}\"" manifest.yaml | ||
yq -i '.manifests[-1].platform.os = "linux"' manifest.yaml | ||
yq -i '.manifests[-1].platform.architecture = "arm64"' manifest.yaml | ||
|
||
# push multi-arch image | ||
manifest-tool push from-spec manifest.yaml | ||
fi | ||
;; | ||
*) | ||
echo "default (none of above)" | ||
;; | ||
esac | ||
} | ||
|
||
echo "image: $IMAGE" | ||
echo "platforms: $PLATFORMS" | ||
context_dir="${1:-.}" | ||
dockerfile="${2:-Dockerfile}" | ||
cd "$context_dir" | ||
build "$dockerfile" |
10 changes: 10 additions & 0 deletions
10
dockerfiles/bases/ng-monitoring-base/release-6.5.Dockerfile
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,10 @@ | ||
############## linux/amd64 ################## | ||
FROM pingcap/alpine-glibc:alpine-3.14.6 AS amd64 | ||
|
||
############## linux/arm64 ################## | ||
FROM pingcap/centos-stream:8 AS arm64 | ||
# CentOS 7,8 has reached EOL | ||
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo | ||
ADD https://github.com/golang/go/raw/go1.22.5/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip |
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,10 @@ | ||
############## linux/amd64 ################## | ||
FROM pingcap/alpine-glibc:alpine-3.14.6 AS amd64 | ||
RUN apk add --no-cache jq | ||
|
||
############## linux/arm64 ################## | ||
FROM pingcap/centos-stream:8 AS arm64 | ||
# CentOS 7,8 has reached EOL | ||
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo |
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
# linux/amd64: https://github.com/PingCAP-QE/ci-dockerfile/blob/master/jenkins/amd64/alpine-3.14.6 | ||
# TODO: compose a multi-arch image. | ||
############## linux/amd64 ################## | ||
FROM pingcap/alpine-glibc:alpine-3.14.6 AS amd64 | ||
RUN apk add --no-cache curl | ||
|
||
# linux/arm64: | ||
# base: https://github.com/PingCAP-QE/artifacts/blob/main/dockerfiles/old-bases/arm64/centos-stream.Dockerfile | ||
############## linux/arm64 ################## | ||
FROM pingcap/centos-stream:8 AS arm64 | ||
# CentOS 7,8 has reached EOL | ||
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo | ||
|
||
RUN set -e && \ | ||
dnf install bind-utils curl nmap-ncat -y && \ | ||
dnf clean all |
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,14 @@ | ||
FROM centos:7.9.2009 | ||
|
||
# CentOS 7 has reached EOL | ||
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo | ||
|
||
# Update packages | ||
RUN yum update -y bind-license cyrus-sasl-lib expat glib2 gzip krb5-libs openssl-libs systemd systemd-libs xz xz-libs zlib nss nss-sysinit nss-tools | ||
|
||
# Set timezone | ||
ENV TZ Asia/Shanghai | ||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \ | ||
echo $TZ > /etc/timezone |
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,7 @@ | ||
############## linux/amd64 ################## | ||
FROM pingcap/alpine-glibc:alpine-3.14.6 as amd64 | ||
RUN apk add --no-cache tzdata bash curl socat | ||
|
||
############## linux/arm64 ################## | ||
FROM alpine:3.12 as arm64 | ||
RUN apk add --no-cache tzdata bash curl socat |
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,16 @@ | ||
############## linux/amd64 ################## | ||
FROM pingcap/alpine-glibc:alpine-3.14.6 AS amd64 | ||
# set timezone | ||
ENV TZ=/etc/localtime | ||
ENV TZDIR=/usr/share/zoneinfo | ||
|
||
############## linux/arm64 ################## | ||
FROM pingcap/centos-stream:8 AS arm64 | ||
# CentOS 7,8 has reached EOL | ||
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo | ||
# set timezone | ||
ENV TZ=/etc/localtime | ||
ENV TZDIR=/usr/share/zoneinfo | ||
|
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,11 @@ | ||
############## linux/amd64 ################## | ||
FROM pingcap/alpine-glibc:alpine-3.14.6 AS amd64 | ||
ADD https://github.com/golang/go/raw/go1.22.5/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
|
||
############## linux/arm64 ################## | ||
FROM pingcap/centos-stream:8 AS arm64 | ||
# CentOS 7,8 has reached EOL | ||
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo \ | ||
&& sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo | ||
ADD https://github.com/golang/go/raw/go1.22.5/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip |
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,3 +1,3 @@ | ||
FROM pingcap/alpine-glibc:alpine-3.14.6 | ||
COPY zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
COPY br /br | ||
ADD https://github.com/golang/go/raw/go1.22.5/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
COPY br /br |
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,3 +1,3 @@ | ||
FROM pingcap/alpine-glibc:alpine-3.14.6 | ||
COPY zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
COPY dumpling /dumpling | ||
ADD https://github.com/golang/go/raw/go1.22.5/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
COPY dumpling /dumpling |
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,9 +1,9 @@ | ||
FROM pingcap/alpine-glibc:alpine-3.14.6 | ||
COPY zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
ADD https://github.com/golang/go/raw/go1.22.5/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
COPY pump /pump | ||
COPY drainer /drainer | ||
COPY reparo /reparo | ||
COPY binlogctl /binlogctl | ||
EXPOSE 4000 | ||
EXPOSE 8249 8250 | ||
CMD ["/pump"] | ||
CMD ["/pump"] |
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,5 +1,5 @@ | ||
FROM pingcap/alpine-glibc:alpine-3.14.6 | ||
COPY zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
ADD https://github.com/golang/go/raw/go1.22.5/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
COPY tidb-lightning /tidb-lightning | ||
COPY tidb-lightning-ctl /tidb-lightning-ctl | ||
COPY br /br |
4 changes: 2 additions & 2 deletions
4
...ucts/ng-monitoring/le6.5/arm64.Dockerfile → ...s/products/ng-monitoring/le6.5/Dockerfile
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,5 +1,5 @@ | ||
FROM pingcap/centos-stream:8 | ||
COPY zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
ARG BASE_IMG=ghcr.io/pingcap-qe/bases/ng-monitoring-base:v1.0.0-old | ||
FROM $BASE_IMG | ||
COPY ng-monitoring-server /ng-monitoring-server | ||
EXPOSE 12020 | ||
ENTRYPOINT ["/ng-monitoring-server"] |
This file was deleted.
Oops, something went wrong.
5 changes: 2 additions & 3 deletions
5
...les/products/pd/le6.5/pd.amd64.Dockerfile → dockerfiles/products/pd/le6.5/Dockerfile
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
Oops, something went wrong.