-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*: add build arm64 dockerfile and shell script
- Loading branch information
Showing
4 changed files
with
199 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
|
||
############################################################################## | ||
# Build Sidecar | ||
############################################################################### | ||
# Build the manager binary | ||
FROM golang:1.17.13 as builder | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
|
||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
# RUN if [ $(date +%z) = "+0800" ] ; then go env -w GOPROXY=https://goproxy.cn,direct; fi | ||
# RUN go env -w GOPROXY=https://goproxy.cn,direct | ||
# go mod download | ||
RUN go mod download | ||
|
||
# Copy the go source | ||
COPY cmd/sidecar/main.go cmd/sidecar/main.go | ||
COPY sidecar/ sidecar/ | ||
COPY utils/ utils/ | ||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -o bin/sidecar cmd/sidecar/main.go | ||
|
||
|
||
# Build mysql checker for mysql conatiner | ||
COPY cmd/s3cmd/main.go cmd/s3cmd/main.go | ||
COPY cmd/s3cmd/s3upload.go cmd/s3cmd/s3upload.go | ||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -a -o bin/s3upload cmd/s3cmd/main.go cmd/s3cmd/s3upload.go | ||
|
||
# Build mysql checker for mysql conatiner | ||
COPY cmd/mysql/main.go cmd/mysql/main.go | ||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -a -o bin/mysqlchecker cmd/mysql/main.go | ||
|
||
############################################################################### | ||
# Docker image for Sidecar | ||
############################################################################### | ||
FROM oraclelinux:8-slim | ||
|
||
LABEL org.opencontainers.image.authors="[email protected]" | ||
RUN set -ex; \ | ||
groupadd --gid 1001 --system mysql; \ | ||
useradd \ | ||
--uid 1001 \ | ||
--system \ | ||
--home-dir /var/lib/mysql \ | ||
--no-create-home \ | ||
--gid mysql \ | ||
mysql; | ||
|
||
RUN microdnf -y update; \ | ||
microdnf -y install glibc-langpack-en | ||
|
||
ARG XTRABACKUP_PKG=percona-xtrabackup-24 | ||
|
||
# check repository package signature in secure way | ||
#percona-xtrabackup-24-2.4.26 | ||
#percona-xtrabackup-test-80-8.0.28 | ||
RUN set -ex; \ | ||
{ \ | ||
echo '[mysql-server-minimal]'; \ | ||
echo 'name=MySQL Server Minimal'; \ | ||
echo 'enabled=1'; \ | ||
echo 'baseurl=http://139.198.40.93:801' ;\ | ||
echo 'gpgcheck=0'; \ | ||
echo 'module_hotfixes=true' ;\ | ||
} | tee /etc/yum.repos.d/mysql-community-minimal.repo | ||
|
||
RUN set -ex; \ | ||
#dnf --setopt=install_weak_deps=False install -y \ | ||
microdnf -y install \ | ||
${XTRABACKUP_PKG} \ | ||
libev \ | ||
curl \ | ||
gnutls \ | ||
wget; | ||
RUN microdnf --enablerepo='*' update; \ | ||
microdnf clean all; \ | ||
rm -rf /var/cache/dnf /var/cache/yum; | ||
WORKDIR / | ||
COPY --from=builder /workspace/bin/sidecar /usr/local/bin/sidecar | ||
COPY --from=builder /workspace/bin/mysqlchecker /mnt/mysqlchecker | ||
COPY --from=builder /workspace/bin/s3upload /mnt/s3upload | ||
ENTRYPOINT ["sidecar"] |
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,52 @@ | ||
############################################################################## | ||
# Build Xenon | ||
############################################################################### | ||
|
||
FROM golang:1.17.13 as builder | ||
|
||
ARG XENON_BRANCH=master | ||
RUN go env -w GO111MODULE=off; | ||
RUN set -ex; \ | ||
mkdir -p /go/src/github.com/radondb; \ | ||
cd /go/src/github.com/radondb; \ | ||
git clone --branch $XENON_BRANCH https://github.com/radondb/xenon.git; \ | ||
cd xenon; \ | ||
make build | ||
WORKDIR /workspace | ||
# Copy the go source | ||
COPY cmd/xenon/main.go cmd/xenon/main.go | ||
COPY utils/ utils/ | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
ARG GO_PROXY=off | ||
RUN if [ "$GO_PROXY" = "on" ]; then \ | ||
go env -w GOPROXY=https://goproxy.cn,direct; \ | ||
fi | ||
RUN go env -w GO111MODULE=on && go mod download | ||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -o xenonchecker cmd/xenon/main.go | ||
############################################################################### | ||
# Docker image for Xenon | ||
############################################################################### | ||
|
||
FROM alpine:3.13 | ||
|
||
RUN set -ex \ | ||
&& addgroup -g 1001 mysql && adduser -u 1001 -g 1001 -S mysql \ | ||
&& apk add --no-cache curl bash jq \ | ||
&& mkdir -p /etc/xenon /var/lib/xenon /lib64 \ | ||
&& ln -s /lib/ld-musl-aarch64.so.1 /lib/ld-linux-aarch64.so.1 \ | ||
&& echo "/etc/xenon/xenon.json" > /config.path \ | ||
# allow to change config files | ||
&& chown -R 1001:1001 /etc/xenon /var/lib/xenon | ||
|
||
COPY --from=builder /go/src/github.com/radondb/xenon/bin/xenon /usr/local/bin/xenon | ||
COPY --from=builder /go/src/github.com/radondb/xenon/bin/xenoncli /usr/local/bin/xenoncli | ||
COPY --from=builder /workspace/xenonchecker /xenonchecker | ||
USER 1001 | ||
WORKDIR / | ||
EXPOSE 8801 | ||
VOLUME ["/var/lib/xenon", "/etc/xenon"] | ||
|
||
ENTRYPOINT ["xenon"] | ||
CMD ["-c", "/etc/xenon/xenon.json"] |
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,59 @@ | ||
|
||
# | ||
TAG=v3.0.0 | ||
IMGPREFIX=radondb/ | ||
builder_exists=$(docker buildx ls | awk '{if ($1=="multi-platform") print $1}') | ||
if [ "$builder_exists" ]; then | ||
docker buildx rm multi-platform | ||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
fi | ||
docker buildx create --use --name multi-platform --platform=linux/amd64,linux/arm64 > /dev/null | ||
|
||
IMGAMD=${IMGPREFIX}mysql-operator-amd64:${TAG} | ||
IMGARM=${IMGPREFIX}mysql-operator-arm64:${TAG} | ||
GO_PROXY=on | ||
DOCKER_BUILDKIT=1 docker build --build-arg GO_PROXY=${GO_PROXY} -t ${IMGAMD} . | ||
|
||
docker buildx create --use --name multi-platform --driver docker-container --platform=linux/amd64,linux/arm64 --config /root/radondb-mysql-kubernetes/buildkitd.toml > /dev/null | ||
docker buildx build --build-arg GO_PROXY=on --platform linux/arm64 -t $IMGARM -o type=docker . | ||
docker push ${IMGAMD} | ||
docker push ${IMGARM} | ||
docker manifest create ${IMGPREFIX}mysql-operator:${TAG} ${IMGAMD} ${IMGARM} | ||
docker manifest push --purge ${IMGPREFIX}mysql-operator:${TAG} | ||
|
||
|
||
XENON_IMGAMD=${IMGPREFIX}xenon-amd64:${TAG} | ||
XENON_IMGARM=${IMGPREFIX}xenon-arm64:${TAG} | ||
GO_PROXY=on | ||
DOCKER_BUILDKIT=1 docker build -f build/xenon/Dockerfile --build-arg GO_PROXY=${GO_PROXY} -t ${XENON_IMGAMD} . | ||
#docker buildx create --use --name multi-platform --driver docker-container --platform=linux/amd64,linux/arm64 --config /root/radondb-mysql-kubernetes/buildkitd.toml > /dev/null | ||
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 . | ||
docker push $XENON_IMGAMD | ||
docker push $XENON_IMGARM | ||
docker manifest create ${IMGPREFIX}xenon:${TAG} ${XENON_IMGAMD} ${XENON_IMGARM} | ||
docker manifest push --purge ${IMGPREFIX}xenon:${TAG} | ||
|
||
|
||
|
||
|
||
|
||
SIDECAR57_IMGAMD=${IMGPREFIX}mysql57-sidecar-amd64:${TAG} | ||
SIDECAR80_IMGAMD=${IMGPREFIX}mysql80-sidecar-amd64:${TAG} | ||
SIDECAR57_IMGARM=${IMGPREFIX}mysql57-sidecar-arm64:${TAG} | ||
SIDECAR80_IMGARM=${IMGPREFIX}mysql80-sidecar-arm64:${TAG} | ||
GO_PROXY=on | ||
DOCKER_BUILDKIT=1 docker build --build-arg XTRABACKUP_PKG=percona-xtrabackup-80 --build-arg GO_PROXY=${GO_PROXY} -f Dockerfile.sidecar -t ${SIDECAR80_IMGAMD} . | ||
DOCKER_BUILDKIT=1 docker build -f Dockerfile.sidecar --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR57_IMGAMD} . | ||
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 . | ||
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 . | ||
docker push ${SIDECAR57_IMGAMD} | ||
docker push ${SIDECAR80_IMGAMD} | ||
docker push ${SIDECAR57_IMGARM} | ||
docker push ${SIDECAR80_IMGARM} | ||
docker manifest create ${IMGPREFIX}mysql57-sidecar:${TAG} ${SIDECAR57_IMGAMD} ${SIDECAR57_IMGARM} | ||
docker manifest push --purge ${IMGPREFIX}mysql57-sidecar:${TAG} | ||
docker manifest create ${IMGPREFIX}mysql80-sidecar:${TAG} ${SIDECAR80_IMGAMD} ${SIDECAR80_IMGARM} | ||
docker manifest push --purge ${IMGPREFIX}mysql80-sidecar:${TAG} | ||
|
||
|
||
|