From 638aeea565d5b7b8b7001793a1fffdfb16f1a9da Mon Sep 17 00:00:00 2001 From: Wu Date: Mon, 17 Apr 2023 14:40:44 +0800 Subject: [PATCH] Add postgre operator multi arch build --- .github/workflows/release.yml | 41 +++++++++++++++++++---- arm64/images/postgres-operator/Dockerfile | 34 +++++++++++++++++++ 2 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 arm64/images/postgres-operator/Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b803c463..76a8d960a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -97,10 +97,39 @@ jobs: # ${{ env.ONLINE_REGISTER }}/ot-redis-operator:latest # cache-from: type=gha # cache-to: type=gha,mode=max - rclone-redis: +# rclone-redis: +# runs-on: ubuntu-latest +# steps: +# - name: Git clone mysql-operator 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/setup-buildx-action@v2.0.0 +# - name: mysql-operator +# uses: docker/build-push-action@v3.1.1 +# with: +# context: ./arm64/images/rclone-redis +# file: ./arm64/images/rclone-redis/Dockerfile-replace-dockefile +# github-token: ${{ secrets.GITHUB_TOKEN }} +# push: true +# platforms: ${{ env.BUILD_PLATFORM }} +# tags: | +# ${{ env.ONLINE_REGISTER }}/rclone-redis:v0.1.8 +# cache-from: type=gha +# cache-to: type=gha,mode=max + postgres-operator: runs-on: ubuntu-latest steps: - - name: Git clone mysql-operator repo + - name: Git clone repo uses: actions/checkout@v3 with: fetch-depth: 0 @@ -114,15 +143,15 @@ jobs: uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2.0.0 - - name: mysql-operator + - name: postgres-operator uses: docker/build-push-action@v3.1.1 with: - context: ./arm64/images/rclone-redis - file: ./arm64/images/rclone-redis/Dockerfile-replace-dockefile + context: ./arm64/images/postgres-operator + file: ./arm64/images/postgres-operator/Dockerfile github-token: ${{ secrets.GITHUB_TOKEN }} push: true platforms: ${{ env.BUILD_PLATFORM }} tags: | - ${{ env.ONLINE_REGISTER }}/rclone-redis:v0.1.8 + ${{ env.ONLINE_REGISTER }}/postgres-operator:${{ github.ref_name }} cache-from: type=gha cache-to: type=gha,mode=max \ No newline at end of file diff --git a/arm64/images/postgres-operator/Dockerfile b/arm64/images/postgres-operator/Dockerfile new file mode 100644 index 000000000..dc822a408 --- /dev/null +++ b/arm64/images/postgres-operator/Dockerfile @@ -0,0 +1,34 @@ +FROM --platform=$TARGETPLATFORM golang:1.18 as builder + +USER root + +RUN apt update -y +RUN apt install -y wget unzip + +ENV GOPROXY=https://goproxy.cn +ENV GOPATH=/workspace + +WORKDIR /workspace + +RUN wget -O postgres-operator-1.9.0.zip https://github.com/zalando/postgres-operator/archive/refs/tags/v1.9.0.zip +RUN unzip postgres-operator-1.9.0.zip +WORKDIR /workspace/postgres-operator-1.9.0 +RUN go mod tidy + +RUN GOOS=linux CGO_ENABLED=0 go build -o build/linux/postgres-operator -v -ldflags "-X=main.version=v1.9.0" ./cmd/main.go + +FROM --platform=$TARGETPLATFORM alpine:3.15 +LABEL maintainer="Team ACID @ Zalando " + +# We need root certificates to deal with teams api over https +RUN apk --no-cache add curl +RUN apk --no-cache add ca-certificates + +COPY --from=builder /workspace/postgres-operator-1.9.0/build/linux/ / + +RUN addgroup -g 1000 pgo +RUN adduser -D -u 1000 -G pgo -g 'Postgres Operator' pgo + +USER 1000:1000 + +ENTRYPOINT ["/postgres-operator"] \ No newline at end of file