Skip to content

Commit

Permalink
refactor(dockerfiles/cd): split image from ci dir to cd/utils
Browse files Browse the repository at this point in the history
and add `manifest-tool` in the release util image

Signed-off-by: wuhuizuo <wuhuizuo@126.com>
  • Loading branch information
wuhuizuo committed Nov 28, 2023
1 parent df42de1 commit 26ea48a
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 78 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/pull-cd-util-images.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions .github/workflows/pull-ci-runtime-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/release-cd-util-images.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 2 additions & 6 deletions .github/workflows/release-ci-runtime-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions dockerfiles/cd/utils/release/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions dockerfiles/cd/utils/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 0 additions & 6 deletions dockerfiles/ci/release-build-base/tikv/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions dockerfiles/ci/release-utils/Dockerfile

This file was deleted.

44 changes: 0 additions & 44 deletions dockerfiles/ci/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 26ea48a

Please sign in to comment.