Skip to content

Commit 88990ac

Browse files
committed
*: add build arm64 dockerfile and shell script
1 parent 13235d3 commit 88990ac

File tree

4 files changed

+199
-1
lines changed

4 files changed

+199
-1
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ COPY utils/ utils/
2424
COPY mysqluser/ mysqluser/
2525

2626
# Build
27-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager cmd/manager/main.go
27+
RUN CGO_ENABLED=0 GOOS=linux go build -a -o manager cmd/manager/main.go
2828

2929
# Use distroless as minimal base image to package the manager binary
3030
# Refer to https://github.com/GoogleContainerTools/distroless for more details

Dockerfile.sidecar-arm64

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
2+
##############################################################################
3+
# Build Sidecar
4+
###############################################################################
5+
# Build the manager binary
6+
FROM golang:1.17.13 as builder
7+
8+
WORKDIR /workspace
9+
# Copy the Go Modules manifests
10+
COPY go.mod go.mod
11+
COPY go.sum go.sum
12+
13+
# cache deps before building and copying source so that we don't need to re-download as much
14+
# and so that source changes don't invalidate our downloaded layer
15+
# RUN if [ $(date +%z) = "+0800" ] ; then go env -w GOPROXY=https://goproxy.cn,direct; fi
16+
# RUN go env -w GOPROXY=https://goproxy.cn,direct
17+
# go mod download
18+
RUN go mod download
19+
20+
# Copy the go source
21+
COPY cmd/sidecar/main.go cmd/sidecar/main.go
22+
COPY sidecar/ sidecar/
23+
COPY utils/ utils/
24+
25+
# Build
26+
RUN CGO_ENABLED=0 GOOS=linux go build -a -o bin/sidecar cmd/sidecar/main.go
27+
28+
29+
# Build mysql checker for mysql conatiner
30+
COPY cmd/s3cmd/main.go cmd/s3cmd/main.go
31+
COPY cmd/s3cmd/s3upload.go cmd/s3cmd/s3upload.go
32+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -a -o bin/s3upload cmd/s3cmd/main.go cmd/s3cmd/s3upload.go
33+
34+
# Build mysql checker for mysql conatiner
35+
COPY cmd/mysql/main.go cmd/mysql/main.go
36+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -a -o bin/mysqlchecker cmd/mysql/main.go
37+
38+
###############################################################################
39+
# Docker image for Sidecar
40+
###############################################################################
41+
FROM oraclelinux:8-slim
42+
43+
LABEL org.opencontainers.image.authors="info@percona.com"
44+
RUN set -ex; \
45+
groupadd --gid 1001 --system mysql; \
46+
useradd \
47+
--uid 1001 \
48+
--system \
49+
--home-dir /var/lib/mysql \
50+
--no-create-home \
51+
--gid mysql \
52+
mysql;
53+
54+
RUN microdnf -y update; \
55+
microdnf -y install glibc-langpack-en
56+
57+
ARG XTRABACKUP_PKG=percona-xtrabackup-24
58+
59+
# check repository package signature in secure way
60+
#percona-xtrabackup-24-2.4.26
61+
#percona-xtrabackup-test-80-8.0.28
62+
RUN set -ex; \
63+
{ \
64+
echo '[mysql-server-minimal]'; \
65+
echo 'name=MySQL Server Minimal'; \
66+
echo 'enabled=1'; \
67+
echo 'baseurl=http://139.198.40.93:801' ;\
68+
echo 'gpgcheck=0'; \
69+
echo 'module_hotfixes=true' ;\
70+
} | tee /etc/yum.repos.d/mysql-community-minimal.repo
71+
72+
RUN set -ex; \
73+
#dnf --setopt=install_weak_deps=False install -y \
74+
microdnf -y install \
75+
${XTRABACKUP_PKG} \
76+
libev \
77+
curl \
78+
gnutls \
79+
wget;
80+
RUN microdnf --enablerepo='*' update; \
81+
microdnf clean all; \
82+
rm -rf /var/cache/dnf /var/cache/yum;
83+
WORKDIR /
84+
COPY --from=builder /workspace/bin/sidecar /usr/local/bin/sidecar
85+
COPY --from=builder /workspace/bin/mysqlchecker /mnt/mysqlchecker
86+
COPY --from=builder /workspace/bin/s3upload /mnt/s3upload
87+
ENTRYPOINT ["sidecar"]

build/xenon/Dockerfile.arm64

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
##############################################################################
2+
# Build Xenon
3+
###############################################################################
4+
5+
FROM golang:1.17.13 as builder
6+
7+
ARG XENON_BRANCH=master
8+
RUN go env -w GO111MODULE=off;
9+
RUN set -ex; \
10+
mkdir -p /go/src/github.com/radondb; \
11+
cd /go/src/github.com/radondb; \
12+
git clone --branch $XENON_BRANCH https://github.com/radondb/xenon.git; \
13+
cd xenon; \
14+
make build
15+
WORKDIR /workspace
16+
# Copy the go source
17+
COPY cmd/xenon/main.go cmd/xenon/main.go
18+
COPY utils/ utils/
19+
COPY go.mod go.mod
20+
COPY go.sum go.sum
21+
ARG GO_PROXY=off
22+
RUN if [ "$GO_PROXY" = "on" ]; then \
23+
go env -w GOPROXY=https://goproxy.cn,direct; \
24+
fi
25+
RUN go env -w GO111MODULE=on && go mod download
26+
# Build
27+
RUN CGO_ENABLED=0 GOOS=linux go build -a -o xenonchecker cmd/xenon/main.go
28+
###############################################################################
29+
# Docker image for Xenon
30+
###############################################################################
31+
32+
FROM alpine:3.13
33+
34+
RUN set -ex \
35+
&& addgroup -g 1001 mysql && adduser -u 1001 -g 1001 -S mysql \
36+
&& apk add --no-cache curl bash jq \
37+
&& mkdir -p /etc/xenon /var/lib/xenon /lib64 \
38+
&& ln -s /lib/ld-musl-aarch64.so.1 /lib/ld-linux-aarch64.so.1 \
39+
&& echo "/etc/xenon/xenon.json" > /config.path \
40+
# allow to change config files
41+
&& chown -R 1001:1001 /etc/xenon /var/lib/xenon
42+
43+
COPY --from=builder /go/src/github.com/radondb/xenon/bin/xenon /usr/local/bin/xenon
44+
COPY --from=builder /go/src/github.com/radondb/xenon/bin/xenoncli /usr/local/bin/xenoncli
45+
COPY --from=builder /workspace/xenonchecker /xenonchecker
46+
USER 1001
47+
WORKDIR /
48+
EXPOSE 8801
49+
VOLUME ["/var/lib/xenon", "/etc/xenon"]
50+
51+
ENTRYPOINT ["xenon"]
52+
CMD ["-c", "/etc/xenon/xenon.json"]

build_mutiplatform.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
#
3+
TAG=v3.0.0
4+
IMGPREFIX=radondb/
5+
builder_exists=$(docker buildx ls | awk '{if ($1=="multi-platform") print $1}')
6+
if [ "$builder_exists" ]; then
7+
docker buildx rm multi-platform
8+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
9+
fi
10+
docker buildx create --use --name multi-platform --platform=linux/amd64,linux/arm64 > /dev/null
11+
12+
IMGAMD=${IMGPREFIX}mysql-operator-amd64:${TAG}
13+
IMGARM=${IMGPREFIX}mysql-operator-arm64:${TAG}
14+
GO_PROXY=on
15+
DOCKER_BUILDKIT=1 docker build --build-arg GO_PROXY=${GO_PROXY} -t ${IMGAMD} .
16+
17+
docker buildx create --use --name multi-platform --driver docker-container --platform=linux/amd64,linux/arm64 --config /root/radondb-mysql-kubernetes/buildkitd.toml > /dev/null
18+
docker buildx build --build-arg GO_PROXY=on --platform linux/arm64 -t $IMGARM -o type=docker .
19+
docker push ${IMGAMD}
20+
docker push ${IMGARM}
21+
docker manifest create ${IMGPREFIX}mysql-operator:${TAG} ${IMGAMD} ${IMGARM}
22+
docker manifest push --purge ${IMGPREFIX}mysql-operator:${TAG}
23+
24+
25+
XENON_IMGAMD=${IMGPREFIX}xenon-amd64:${TAG}
26+
XENON_IMGARM=${IMGPREFIX}xenon-arm64:${TAG}
27+
GO_PROXY=on
28+
DOCKER_BUILDKIT=1 docker build -f build/xenon/Dockerfile --build-arg GO_PROXY=${GO_PROXY} -t ${XENON_IMGAMD} .
29+
#docker buildx create --use --name multi-platform --driver docker-container --platform=linux/amd64,linux/arm64 --config /root/radondb-mysql-kubernetes/buildkitd.toml > /dev/null
30+
docker buildx build --build-arg GO_PROXY=on --platform linux/arm64 -f build/xenon/Dockerfile.arm64 --build-arg GO_PROXY=${GO_PROXY} -t ${XENON_IMGARM} -o type=docker .
31+
docker push $XENON_IMGAMD
32+
docker push $XENON_IMGARM
33+
docker manifest create ${IMGPREFIX}xenon:${TAG} ${XENON_IMGAMD} ${XENON_IMGARM}
34+
docker manifest push --purge ${IMGPREFIX}xenon:${TAG}
35+
36+
37+
38+
39+
40+
SIDECAR57_IMGAMD=${IMGPREFIX}mysql57-sidecar-amd64:${TAG}
41+
SIDECAR80_IMGAMD=${IMGPREFIX}mysql80-sidecar-amd64:${TAG}
42+
SIDECAR57_IMGARM=${IMGPREFIX}mysql57-sidecar-arm64:${TAG}
43+
SIDECAR80_IMGARM=${IMGPREFIX}mysql80-sidecar-arm64:${TAG}
44+
GO_PROXY=on
45+
DOCKER_BUILDKIT=1 docker build --build-arg XTRABACKUP_PKG=percona-xtrabackup-80 --build-arg GO_PROXY=${GO_PROXY} -f Dockerfile.sidecar -t ${SIDECAR80_IMGAMD} .
46+
DOCKER_BUILDKIT=1 docker build -f Dockerfile.sidecar --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR57_IMGAMD} .
47+
docker buildx build --build-arg GO_PROXY=on --platform linux/arm64 --build-arg XTRABACKUP_PKG=percona-xtrabackup-80 --build-arg GO_PROXY=${GO_PROXY} -f Dockerfile.sidecar-arm64 -t ${SIDECAR80_IMGARM} -o type=docker .
48+
docker buildx build --build-arg GO_PROXY=on --platform linux/arm64 -f Dockerfile.sidecar2 --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR57_IMGARM} -o type=docker .
49+
docker push ${SIDECAR57_IMGAMD}
50+
docker push ${SIDECAR80_IMGAMD}
51+
docker push ${SIDECAR57_IMGARM}
52+
docker push ${SIDECAR80_IMGARM}
53+
docker manifest create ${IMGPREFIX}mysql57-sidecar:${TAG} ${SIDECAR57_IMGAMD} ${SIDECAR57_IMGARM}
54+
docker manifest push --purge ${IMGPREFIX}mysql57-sidecar:${TAG}
55+
docker manifest create ${IMGPREFIX}mysql80-sidecar:${TAG} ${SIDECAR80_IMGAMD} ${SIDECAR80_IMGARM}
56+
docker manifest push --purge ${IMGPREFIX}mysql80-sidecar:${TAG}
57+
58+
59+

0 commit comments

Comments
 (0)