Skip to content

Commit

Permalink
new xtrabackup
Browse files Browse the repository at this point in the history
  • Loading branch information
drivebyer committed Aug 8, 2024
1 parent 9801e77 commit a7cbf5d
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 19 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release_manually.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ on:
- 'logical-backup'
- 'ci-builder'
- 'elasticsearch-with-s3-plugin'
- 'mysql-operator-sidecar-80'
upstream-ref:
description: 'upstream ref'
required: false
Expand All @@ -42,6 +43,38 @@ env:
BUILD_PLATFORM: linux/amd64,linux/arm64

jobs:
mysql-operator-sidecar-80:
if : ${{ inputs.job == 'mysql-operator-sidecar-80' }}
runs-on: ubuntu-latest
steps:
- name: Git clone repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: mysql-operator-sidecar-80
uses: docker/[email protected]
with:
context: ./arm64/images/mysql-operator-sidecar-8.0
file: ./arm64/images/mysql-operator-sidecar-8.0/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
push: true
platforms: ${{ env.BUILD_PLATFORM }}
tags: |
${{ env.ONLINE_REGISTER }}/mysql-operator-sidecar-8.0:${{ inputs.tag }}
${{ env.ONLINE_REGISTER }}/mysql-operator-sidecar-8.0:latest
cache-from: type=gha
cache-to: type=gha,mode=max

ci-builder:
if : ${{ inputs.job == 'ci-builder' }}
runs-on: ubuntu-latest
Expand Down
66 changes: 47 additions & 19 deletions arm64/images/mysql-operator-sidecar-8.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ ENV GOPROXY=https://goproxy.cn
ENV GOPATH=/build

WORKDIR /build
RUN wget -O arm64.zip https://github.com/ksmartdata/mysql-operator/archive/refs/heads/arm64.zip
RUN unzip arm64.zip
WORKDIR /build/mysql-operator-arm64
RUN wget -O extra_image.zip https://github.com/ksmartdata/mysql-operator/archive/refs/heads/extra_image.zip
RUN unzip extra_image.zip
WORKDIR /build/mysql-operator-extra_image
RUN go mod tidy
RUN CGO_ENABLED=0 go build -o /mysql-operator-sidecar cmd/mysql-operator-sidecar/main.go

Expand All @@ -26,6 +26,7 @@ FROM --platform=$TARGETPLATFORM centos:8.3.2011 as all

USER root

ARG XTRABACKUP_VERSION=8.0.35-31

COPY rootfs/ /

Expand Down Expand Up @@ -57,17 +58,17 @@ RUN chmod +x /usr/local/bin/rclone

# percona-xtrabackup
WORKDIR /build
RUN wget -O percona-xtrabackup-8.0.29-22.zip https://github.com/percona/percona-xtrabackup/archive/refs/tags/percona-xtrabackup-8.0.29-22.zip
RUN unzip percona-xtrabackup-8.0.29-22
WORKDIR /build/percona-xtrabackup-percona-xtrabackup-8.0.29-22
RUN wget -O percona-xtrabackup-${XTRABACKUP_VERSION}.zip https://github.com/percona/percona-xtrabackup/archive/refs/tags/percona-xtrabackup-${XTRABACKUP_VERSION}.zip
RUN unzip percona-xtrabackup-${XTRABACKUP_VERSION}
WORKDIR /build/percona-xtrabackup-percona-xtrabackup-${XTRABACKUP_VERSION}

RUN yum -y install cmake openssl-devel libaio libaio-devel automake autoconf \
bison libtool ncurses-devel libgcrypt-devel libev-devel libcurl-devel zlib-devel \
vim-common


WORKDIR /build/percona-xtrabackup-percona-xtrabackup-8.0.29-22/build
WORKDIR /build/percona-xtrabackup-percona-xtrabackup-8.0.29-22
WORKDIR /build/percona-xtrabackup-percona-xtrabackup-${XTRABACKUP_VERSION}/build
WORKDIR /build/percona-xtrabackup-percona-xtrabackup-${XTRABACKUP_VERSION}

RUN yum install -y gcc-toolset-11-gcc gcc-toolset-11-gcc-c++ gcc-toolset-11-binutils

Expand All @@ -79,20 +80,44 @@ RUN yum install -y libudev-devel
RUN wget -O libkmip.zip https://github.com/Percona-Lab/libkmip/archive/0ecda33598838b67bb4bb7a0005c92eea8b7405a.zip
RUN unzip libkmip.zip
RUN cp -r libkmip-0ecda33598838b67bb4bb7a0005c92eea8b7405a/. extra/libkmip/

RUN cmake -DWITH_BOOST=PATH-TO-BOOST-LIBRARY -DDOWNLOAD_BOOST=ON \
-DBUILD_CONFIG=xtrabackup_release -DWITH_MAN_PAGES=OFF -B ..

WORKDIR /build
RUN make -j4
RUN make install
# todo
#RUN cmake -DWITH_BOOST=PATH-TO-BOOST-LIBRARY -DDOWNLOAD_BOOST=ON \
#-DBUILD_CONFIG=xtrabackup_release -DWITH_MAN_PAGES=OFF -B ..
#
#WORKDIR /build
#RUN make -j4
#RUN make install

COPY --from=builder /mysql-operator-sidecar /usr/local/bin/

RUN chmod +x /usr/local/bin/mysql-operator-sidecar
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

WORKDIR /build

# 设置环境变量
ENV GO_VERSION=1.22.4
ENV GO_DOWNLOAD_URL=https://golang.org/dl/
ENV GO_TARBALL=go${GO_VERSION}.linux-amd64.tar.gz

# 使用条件语句根据系统架构选择下载的 Go 包
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
GO_TARBALL=go${GO_VERSION}.linux-amd64.tar.gz; \
elif [ "$ARCH" = "armv7l" ]; then \
GO_TARBALL=go${GO_VERSION}.linux-armv6l.tar.gz; \
elif [ "$ARCH" = "aarch64" ]; then \
GO_TARBALL=go${GO_VERSION}.linux-arm64.tar.gz; \
else \
echo "Unsupported architecture: $ARCH"; exit 1; \
fi && \
wget ${GO_DOWNLOAD_URL}${GO_TARBALL} && \
tar -C /usr/local -xzf ${GO_TARBALL} && \
rm ${GO_TARBALL}

ENV PATH=$PATH:/usr/local/go/bin
RUN go version

RUN wget -O percona-toolkit.zip https://github.com/percona/percona-toolkit/archive/refs/heads/3.x.zip
RUN unzip percona-toolkit.zip
WORKDIR /build/percona-toolkit-3.x
Expand All @@ -105,10 +130,6 @@ RUN make install
RUN yum -y install perl-DBI
RUN yum -y install perl-DBD-MySQL





RUN usermod -u 994 systemd-coredump
RUN groupmod -g 994 systemd-coredump
RUN groupmod -g 993 input
Expand Down Expand Up @@ -139,6 +160,13 @@ RUN cd /etc/yum.repos.d/ && sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d
&& yum makecache
RUN yum install -y perl perl-DBI perl-DBD-MySQL

# 换成直接用 yum 安装,避免编译耗时太长超过 github 超时时间
# date: 2024年 08月 08日 星期四 17:37:18 CST, 最新版本是 8.0.35-31
# https://docs.percona.com/percona-xtrabackup/8.0/release-notes/8.0/8.0.35-31.0.html
RUN yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm -y
RUN percona-release enable-only tools
RUN yum install percona-xtrabackup-80 -y

COPY rootfs/ /

COPY --from=all /usr/local/ /usr/local/
Expand Down

0 comments on commit a7cbf5d

Please sign in to comment.