diff --git a/.github/workflows/pull-cd-util-images.yaml b/.github/workflows/pull-cd-util-images.yaml new file mode 100644 index 00000000..1b8675aa --- /dev/null +++ b/.github/workflows/pull-cd-util-images.yaml @@ -0,0 +1,65 @@ +name: Pull test for CD utils images +on: + pull_request: + branches: + - main + paths: + - "dockerfiles/cd/utils/**/Dockerfile" + - "dockerfiles/cd/utils/**/*.Dockerfile" + - "dockerfiles/cd/utils/skaffold.yaml" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + skaffold: + name: build images with skaffold + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + strategy: + max-parallel: 1 + matrix: + module: [utils] + builder-profile: [local-docker] + platform: [linux/amd64, linux/arm64] + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup skaffold + run: | + curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v2.8.0/skaffold-linux-amd64 && \ + sudo install skaffold /usr/local/bin/ + + - name: Build images + working-directory: dockerfiles/cd/utils + run: | + skaffold build \ + --build-concurrency 1 \ + --cache-artifacts \ + --default-repo ghcr.io/pingcap-qe/cd/utils \ + --module ${{ matrix.module }} \ + --platform ${{ matrix.platform }} \ + --profile ${{ matrix.builder-profile }} \ + --push=false diff --git a/.github/workflows/pull-ci-runtime-images.yaml b/.github/workflows/pull-ci-runtime-images.yaml index 60f2947a..43e8780c 100644 --- a/.github/workflows/pull-ci-runtime-images.yaml +++ b/.github/workflows/pull-ci-runtime-images.yaml @@ -24,15 +24,11 @@ jobs: strategy: max-parallel: 1 matrix: - module: [base, release-utils] + module: [base] platform: [linux/amd64, linux/arm64] builder-profile: [local-docker] go-profile: [go-1.21, go-1.20, go-1.19] - exclude: - - module: release-utils - go-profile: go-1.20 - - module: release-utils - go-profile: go-1.19 + steps: - name: Checkout sources uses: actions/checkout@v4 diff --git a/.github/workflows/release-cd-util-images.yaml b/.github/workflows/release-cd-util-images.yaml new file mode 100644 index 00000000..0ac9a15a --- /dev/null +++ b/.github/workflows/release-cd-util-images.yaml @@ -0,0 +1,59 @@ +name: Publish CD utils images +on: + workflow_dispatch: + push: + branches: + - main + paths: + - "dockerfiles/cd/utils/**/Dockerfile" + - "dockerfiles/cd/utils/**/*.Dockerfile" + - "dockerfiles/cd/utils/skaffold.yaml" + +jobs: + skaffold: + name: publish images with skaffold + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + strategy: + max-parallel: 1 + matrix: + module: [utils] + builder-profile: [local-docker] + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup skaffold + run: | + curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v2.8.0/skaffold-linux-amd64 && \ + sudo install skaffold /usr/local/bin/ + + - name: Publish images + working-directory: dockerfiles/cd/utils + run: | + skaffold build \ + --build-concurrency 1 \ + --cache-artifacts \ + --default-repo ghcr.io/pingcap-qe/cd/utils \ + --module ${{ matrix.module }} \ + --profile ${{ matrix.builder-profile }} diff --git a/.github/workflows/release-ci-runtime-images.yaml b/.github/workflows/release-ci-runtime-images.yaml index 0d250214..6dc0c556 100644 --- a/.github/workflows/release-ci-runtime-images.yaml +++ b/.github/workflows/release-ci-runtime-images.yaml @@ -21,14 +21,10 @@ jobs: strategy: max-parallel: 1 matrix: - module: [base, release-utils] + module: [base] builder-profile: [local-docker] go-profile: [go-1.21, go-1.20, go-1.19] - exclude: - - module: release-utils - go-profile: go-1.20 - - module: release-utils - go-profile: go-1.19 + steps: - name: Checkout sources uses: actions/checkout@v4 diff --git a/dockerfiles/cd/utils/release/Dockerfile b/dockerfiles/cd/utils/release/Dockerfile new file mode 100644 index 00000000..7124b9b7 --- /dev/null +++ b/dockerfiles/cd/utils/release/Dockerfile @@ -0,0 +1,19 @@ +FROM golang:1.21.4-alpine3.18 as gomplate_builder + +RUN wget https://github.com/hairyhenderson/gomplate/archive/refs/heads/main.zip -O - | unzip - && cd gomplate-main && go build -o /usr/local/bin/gomplate ./cmd/gomplate + +FROM alpine:3.18.4 + +LABEL org.opencontainers.image.authors "wuhui.zuo@pingcap.com" +LABEL org.opencontainers.image.description "utils image for CD release" + +# install tools: bash, git, jq, yq, goemplate +# RUN apk add --no-cache bash git jq yq gomplate +RUN apk add --no-cache bash git jq yq +COPY --from=gomplate_builder /usr/bin/gomplate /usr/local/bin/gomplate + +# install tools: oras +COPY --from=ghcr.io/oras-project/oras:v1.1.0 /bin/oras /usr/local/bin/oras + +# install tools: manifest-tool +COPY --from=mplatform/manifest-tool:alpine-v2.1.3 /manifest-tool /usr/local/bin/manifest-tool diff --git a/dockerfiles/cd/utils/skaffold.yaml b/dockerfiles/cd/utils/skaffold.yaml new file mode 100644 index 00000000..df057cce --- /dev/null +++ b/dockerfiles/cd/utils/skaffold.yaml @@ -0,0 +1,44 @@ +--- +apiVersion: skaffold/v4beta6 +kind: Config +metadata: + name: utils +build: + artifacts: + - image: release + platforms: [linux/amd64, linux/arm64] + kaniko: + dockerfile: utils/release/Dockerfile + cache: {} + tagPolicy: + customTemplate: + template: "{{ .SHA }}" + components: + - name: SHA + gitCommit: + variant: AbbrevCommitSha + cluster: + concurrency: 0 + randomDockerConfigSecret: false + randomPullSecret: false + dockerConfig: + secretName: hub-pingcap-net-ee + resources: + requests: + cpu: "1" + memory: 2Gi + limits: + cpu: "2" + memory: 4Gi +profiles: + - name: local-docker + build: + local: + useDockerCLI: true + useBuildkit: true + concurrency: 0 + tryImportMissing: true + patches: + - op: move + from: /build/artifacts/0/kaniko + path: /build/artifacts/0/docker diff --git a/dockerfiles/ci/release-build-base/tikv/Dockerfile b/dockerfiles/ci/release-build-base/tikv/Dockerfile deleted file mode 100644 index c44bc5d6..00000000 --- a/dockerfiles/ci/release-build-base/tikv/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM rockylinux:8.8.20230518 -RUN yum groupinstall -y "Development Tools" -RUN yum --enablerepo=powertools install -y git make cmake gawk llvm protobuf-compiler libstdc++-static python3 && yum clean all -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s - -y --default-toolchain none -RUN ln -s /usr/bin/python3 /usr/bin/python -ENV PATH /root/.cargo/bin/:$PATH diff --git a/dockerfiles/ci/release-utils/Dockerfile b/dockerfiles/ci/release-utils/Dockerfile deleted file mode 100644 index 043ae2ff..00000000 --- a/dockerfiles/ci/release-utils/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM golang:1.21.4-alpine3.18 as gomplate_builder - -RUN wget https://github.com/wuhuizuo/gomplate/archive/refs/heads/feature/semver-functions.zip -O - | unzip - && cd gomplate-feature-semver-functions && go build -o /usr/bin/gomplate ./cmd/gomplate - -FROM alpine:3.18.4 - -LABEL org.opencontainers.image.authors "wuhui.zuo@pingcap.com" -LABEL org.opencontainers.image.description "utils image for CD release" - -# install tools: bash, git, jq, yq, goemplate -# RUN apk add --no-cache bash git jq yq gomplate -RUN apk add --no-cache bash git jq yq -COPY --from=gomplate_builder /usr/bin/gomplate /usr/bin/gomplate - -# install tools: oras -COPY --from=ghcr.io/oras-project/oras:v1.1.0 /bin/oras /usr/bin/oras diff --git a/dockerfiles/ci/skaffold.yaml b/dockerfiles/ci/skaffold.yaml index 3c5d3021..ae54faa6 100644 --- a/dockerfiles/ci/skaffold.yaml +++ b/dockerfiles/ci/skaffold.yaml @@ -147,47 +147,3 @@ profiles: value: # renovate: datasource=docker depName=golang GOLANG_VERSION: 1.19.12 ---- -apiVersion: skaffold/v4beta6 -kind: Config -metadata: - name: release-utils -build: - artifacts: - - image: release-utils - platforms: [linux/amd64, linux/arm64] - kaniko: - dockerfile: release-utils/Dockerfile - cache: {} - tagPolicy: - customTemplate: - template: "{{ .SHA }}" - components: - - name: SHA - gitCommit: - variant: AbbrevCommitSha - cluster: - concurrency: 0 - randomDockerConfigSecret: false - randomPullSecret: false - dockerConfig: - secretName: hub-pingcap-net-ee - resources: - requests: - cpu: "1" - memory: 2Gi - limits: - cpu: "2" - memory: 4Gi -profiles: - - name: local-docker - build: - local: - useDockerCLI: true - useBuildkit: true - concurrency: 0 - tryImportMissing: true - patches: - - op: move - from: /build/artifacts/0/kaniko - path: /build/artifacts/0/docker