Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dockerfiles/cd/builders): add builder image for tidb-operator #338

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-operator.git tidb
# - rm tidb-operator/.dockerignore # make step depended on git metadata.
# - docker build -t tidb-operator -f Dockerfile ./tidb-operator

########### stage: Builder
ARG GOLANG_VERSION=1.21.12
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