Skip to content

Commit

Permalink
feat(dockerfiles/cd/builders): add builder image for tidb-operator
Browse files Browse the repository at this point in the history
Signed-off-by: wuhuizuo <wuhuizuo@126.com>
  • Loading branch information
wuhuizuo committed Jul 3, 2024
1 parent f60f629 commit 2594b69
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dockerfiles/cd/builders/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ build:
dockerfile: tidb-dashboard/Dockerfile
cache: {}
target: builder
- image: tidb-operator
platforms: [linux/amd64, linux/arm64]
kaniko:
dockerfile: tidb-operator/Dockerfile
cache: {}
target: builder
cluster:
concurrency: 0
randomDockerConfigSecret: false
Expand All @@ -253,6 +259,7 @@ profiles:
tryImportMissing: true
patches:
- { op: move, from: /build/artifacts/0/kaniko, path: /build/artifacts/0/docker }
- { op: move, from: /build/artifacts/1/kaniko, path: /build/artifacts/1/docker }
---
apiVersion: skaffold/v4beta6
kind: Config
Expand Down
31 changes: 31 additions & 0 deletions dockerfiles/cd/builders/tidb-operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# build requires:
# - docker >= v20.10
#
# build steps:
# - git clone https://github.com/pingcap/tidb.git tidb
# - rm tidb/.dockerignore # make step depended on git metadata.
# - docker build -t tidb -f Dockerfile ./tidb

########### stage: Builder
ARG GOLANG_VERSION=1.21.11
FROM golang:${GOLANG_VERSION} as builder

# install packages.
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y uuid-runtime

LABEL go-version="${GOLANG_VERSION}"

########### stage: Buiding
FROM builder as building
COPY . /ws
ARG GOPROXY
RUN GOPROXY=${GOPROXY} make build -C /ws && mv /ws/images/tidb-operator/bin/$(arch) /ws/bin

########### stage: Final image
FROM ghcr.io/pingcap-qe/bases/tidb-base:v1.9.0

COPY --from=building /ws/bin/tidb-scheduler /usr/local/bin/tidb-scheduler
COPY --from=building /ws/bin/tidb-discovery /usr/local/bin/tidb-discovery
COPY --from=building /ws/bin/tidb-controller-manager /usr/local/bin/tidb-controller-manager
COPY --from=building /ws/bin/tidb-admission-webhook /usr/local/bin/tidb-admission-webhook

0 comments on commit 2594b69

Please sign in to comment.