-
Notifications
You must be signed in to change notification settings - Fork 529
Chore: add fast development build system for operator images #6339
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Development .dockerignore - includes _output for pre-compiled binaries | ||
| # Only exclude what we don't need | ||
| manifests | ||
| examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,12 +32,22 @@ NEED_PREFIX["prestop-checker"]=1 | |||||||||||||||||||||
| function image::build() { | ||||||||||||||||||||||
| local targets=() | ||||||||||||||||||||||
| local with_push=0 | ||||||||||||||||||||||
| local dockerfile="Dockerfile" | ||||||||||||||||||||||
| local dockerignore="" | ||||||||||||||||||||||
| while [[ $# -gt 0 ]]; do | ||||||||||||||||||||||
| case $1 in | ||||||||||||||||||||||
| --push) | ||||||||||||||||||||||
| with_push=1 | ||||||||||||||||||||||
| shift | ||||||||||||||||||||||
| ;; | ||||||||||||||||||||||
| --dockerfile=*) | ||||||||||||||||||||||
| dockerfile="${1#*=}" | ||||||||||||||||||||||
| shift | ||||||||||||||||||||||
| ;; | ||||||||||||||||||||||
| --dockerignore=*) | ||||||||||||||||||||||
| dockerignore="${1#*=}" | ||||||||||||||||||||||
| shift | ||||||||||||||||||||||
| ;; | ||||||||||||||||||||||
| -*|--*) | ||||||||||||||||||||||
| echo "Unknown option $1" | ||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||
|
|
@@ -73,7 +83,20 @@ function image::build() { | |||||||||||||||||||||
| if [[ -n "${NEED_PREFIX[$target]+x}" ]]; then | ||||||||||||||||||||||
| image=tidb-operator-${image} | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| echo "build image ${image}" | ||||||||||||||||||||||
| echo "build image ${image} using ${dockerfile}" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Handle custom dockerignore file | ||||||||||||||||||||||
| local dockerignore_backup="" | ||||||||||||||||||||||
| if [[ -n "$dockerignore" ]]; then | ||||||||||||||||||||||
| # Backup original .dockerignore if it exists | ||||||||||||||||||||||
| if [[ -f "$ROOT/.dockerignore" ]]; then | ||||||||||||||||||||||
| dockerignore_backup="$ROOT/.dockerignore.backup.$$" | ||||||||||||||||||||||
| mv "$ROOT/.dockerignore" "$dockerignore_backup" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| # Copy custom dockerignore | ||||||||||||||||||||||
| cp "$ROOT/$dockerignore" "$ROOT/.dockerignore" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
||||||||||||||||||||||
| fi | |
| if [[ ! -f "$ROOT/$dockerignore" ]]; then | |
| echo "Error: Custom dockerignore file '$ROOT/$dockerignore' does not exist." >&2 | |
| # Restore original .dockerignore if it was backed up | |
| if [[ -n "$dockerignore_backup" && -f "$dockerignore_backup" ]]; then | |
| mv "$dockerignore_backup" "$ROOT/.dockerignore" | |
| fi | |
| exit 1 | |
| fi | |
| cp "$ROOT/$dockerignore" "$ROOT/.dockerignore" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Development Dockerfile for faster builds | ||
| # This Dockerfile expects pre-compiled binaries from local build | ||
| FROM ghcr.io/pingcap-qe/bases/pingcap-base:v1.9.2 AS tidb-operator | ||
|
|
||
| WORKDIR / | ||
|
|
||
| # Copy pre-compiled binary from local build (relative to build context root) | ||
| COPY _output/bin/tidb-operator tidb-operator | ||
|
|
||
| USER 65532:65532 | ||
|
|
||
| ENTRYPOINT ["/tidb-operator"] | ||
|
|
||
| FROM ghcr.io/pingcap-qe/bases/pingcap-base:v1.9.2 AS prestop-checker | ||
|
|
||
| WORKDIR / | ||
|
|
||
| # Copy pre-compiled binary from local build | ||
| COPY _output/bin/prestop-checker prestop-checker | ||
|
|
||
| USER 65532:65532 | ||
|
|
||
| ENTRYPOINT ["/prestop-checker"] | ||
|
|
||
| FROM ghcr.io/pingcap-qe/bases/pingcap-base:v1.9.2 AS testing-workload | ||
|
|
||
| WORKDIR / | ||
|
|
||
| # Copy pre-compiled binary from local build | ||
| COPY _output/bin/testing-workload testing-workload | ||
|
|
||
| USER 65532:65532 | ||
|
|
||
| ENTRYPOINT ["/testing-workload"] | ||
|
|
||
| FROM ghcr.io/pingcap-qe/bases/pingcap-base:v1.9.2 AS tidb-backup-manager | ||
|
|
||
| WORKDIR / | ||
|
|
||
| # Copy pre-compiled binary from local build | ||
| COPY _output/bin/tidb-backup-manager tidb-backup-manager | ||
|
|
||
| USER 65532:65532 | ||
|
|
||
| ENTRYPOINT ["/tidb-backup-manager"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using $$ (process ID) for backup filename could cause race conditions if multiple builds run simultaneously. Consider using a more unique identifier like $(date +%s%N) or mktemp to generate unique backup filenames.