feat: replace docker push with native chunked registry push
- commit
- c8966e7cd8bd27b27c231d723bff39c2219915a8
- author
- brice · · 2026-03-14 14:08 UTC
- parent
- 485dfa5
- signature
- unsigned
1 file · +7 -7
M internal/adapters/in/cli/push.go +7 -7
| @@ -18,6 +18,7 @@ import ( | |||
| 18 | 18 | "github.com/bnema/gordon/internal/adapters/in/cli/ui/components" | |
| 19 | 19 | "github.com/bnema/gordon/internal/adapters/in/cli/ui/styles" | |
| 20 | 20 | "github.com/bnema/gordon/internal/domain" | |
| 21 | + | "github.com/bnema/gordon/pkg/registrypush" | |
| 21 | 22 | "github.com/bnema/gordon/pkg/validation" | |
| 22 | 23 | ) | |
| 23 | 24 | ||
| @@ -473,9 +474,8 @@ func buildAndPush(ctx context.Context, version, platform, dockerfile string, bui | |||
| 473 | 474 | } | |
| 474 | 475 | ||
| 475 | 476 | // Build and load into local daemon (NOT --push). | |
| 476 | - | // BuildKit's --push uses monolithic blob uploads that exceed | |
| 477 | - | // Cloudflare's 100MB per-request limit. Loading locally then | |
| 478 | - | // using docker push gives us chunked uploads (~5MB per request). | |
| 477 | + | // The native registry push client handles chunked uploads to stay | |
| 478 | + | // within Cloudflare's 100MB per-request limit. | |
| 479 | 479 | fmt.Println("\nBuilding image...") | |
| 480 | 480 | buildCmd := exec.CommandContext(ctx, "docker", buildImageArgs(ctx, version, platform, dockerfile, buildArgs, versionRef, latestRef)...) // #nosec G204 | |
| 481 | 481 | buildCmd.Env = os.Environ() // VERSION is now passed as --build-arg VERSION=<value> | |
| @@ -744,10 +744,10 @@ func dockerTag(ctx context.Context, src, dst string) error { | |||
| 744 | 744 | } | |
| 745 | 745 | ||
| 746 | 746 | func dockerPush(ctx context.Context, ref string) error { | |
| 747 | - | cmd := exec.CommandContext(ctx, "docker", "push", ref) //nolint:gosec // binary is constant; image ref validated by OCI ref parser | |
| 748 | - | cmd.Stdout = os.Stdout | |
| 749 | - | cmd.Stderr = os.Stderr | |
| 750 | - | return cmd.Run() | |
| 747 | + | pusher := registrypush.New( | |
| 748 | + | registrypush.WithProgress(os.Stderr), | |
| 749 | + | ) | |
| 750 | + | return pusher.Push(ctx, ref) | |
| 751 | 751 | } | |
| 752 | 752 | ||
| 753 | 753 | func dockerImageExists(ctx context.Context, image string) bool { | |
| @@ -18,6 +18,7 @@ import ( | |||||
| 18 | "github.com/bnema/gordon/internal/adapters/in/cli/ui/components" | 18 | "github.com/bnema/gordon/internal/adapters/in/cli/ui/components" | ||
| 19 | "github.com/bnema/gordon/internal/adapters/in/cli/ui/styles" | 19 | "github.com/bnema/gordon/internal/adapters/in/cli/ui/styles" | ||
| 20 | "github.com/bnema/gordon/internal/domain" | 20 | "github.com/bnema/gordon/internal/domain" | ||
| 21 | + | "github.com/bnema/gordon/pkg/registrypush" | |||
| 21 | "github.com/bnema/gordon/pkg/validation" | 22 | "github.com/bnema/gordon/pkg/validation" | ||
| 22 | ) | 23 | ) | ||
| 23 | 24 | ||||
| @@ -473,9 +474,8 @@ func buildAndPush(ctx context.Context, version, platform, dockerfile string, bui | |||||
| 473 | } | 474 | } | ||
| 474 | 475 | ||||
| 475 | // Build and load into local daemon (NOT --push). | 476 | // Build and load into local daemon (NOT --push). | ||
| 476 | - | // BuildKit's --push uses monolithic blob uploads that exceed | 477 | + | // The native registry push client handles chunked uploads to stay |
| 477 | - | // Cloudflare's 100MB per-request limit. Loading locally then | 478 | + | // within Cloudflare's 100MB per-request limit. |
| 478 | - | // using docker push gives us chunked uploads (~5MB per request). | |||
| 479 | fmt.Println("\nBuilding image...") | 479 | fmt.Println("\nBuilding image...") | ||
| 480 | buildCmd := exec.CommandContext(ctx, "docker", buildImageArgs(ctx, version, platform, dockerfile, buildArgs, versionRef, latestRef)...) // #nosec G204 | 480 | buildCmd := exec.CommandContext(ctx, "docker", buildImageArgs(ctx, version, platform, dockerfile, buildArgs, versionRef, latestRef)...) // #nosec G204 | ||
| 481 | buildCmd.Env = os.Environ() // VERSION is now passed as --build-arg VERSION=<value> | 481 | buildCmd.Env = os.Environ() // VERSION is now passed as --build-arg VERSION=<value> | ||
| @@ -744,10 +744,10 @@ func dockerTag(ctx context.Context, src, dst string) error { | |||||
| 744 | } | 744 | } | ||
| 745 | 745 | ||||
| 746 | func dockerPush(ctx context.Context, ref string) error { | 746 | func dockerPush(ctx context.Context, ref string) error { | ||
| 747 | - | cmd := exec.CommandContext(ctx, "docker", "push", ref) //nolint:gosec // binary is constant; image ref validated by OCI ref parser | 747 | + | pusher := registrypush.New( |
| 748 | - | cmd.Stdout = os.Stdout | 748 | + | registrypush.WithProgress(os.Stderr), |
| 749 | - | cmd.Stderr = os.Stderr | 749 | + | ) |
| 750 | - | return cmd.Run() | 750 | + | return pusher.Push(ctx, ref) |
| 751 | } | 751 | } | ||
| 752 | 752 | ||||
| 753 | func dockerImageExists(ctx context.Context, image string) bool { | 753 | func dockerImageExists(ctx context.Context, image string) bool { | ||