Skip to content
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
11 changes: 5 additions & 6 deletions pkg/docker/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ func Build(dir, dockerfile, imageName string, secrets []string, noCache bool, pr
var args []string

args = append(args,
"buildx", "build", "--load",
"buildx", "build",
)

if util.IsAppleSiliconMac(runtime.GOOS, runtime.GOARCH) {
// Fixes "WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested"
args = append(args, "--platform", "linux/amd64")
args = append(args, "--platform", "linux/amd64", "--load")
}

for _, secret := range secrets {
Expand Down Expand Up @@ -71,16 +71,16 @@ func Build(dir, dockerfile, imageName string, secrets []string, noCache bool, pr
return cmd.Run()
}

func BuildAddLabelsAndSchemaToImage(dir, image string, labels map[string]string, bundledSchemaFile string, bundledSchemaPy string) error {
func BuildAddLabelsAndSchemaToImage(image string, labels map[string]string, bundledSchemaFile string, bundledSchemaPy string) error {
var args []string

args = append(args,
"buildx", "build", "--load",
"buildx", "build",
)

if util.IsAppleSiliconMac(runtime.GOOS, runtime.GOARCH) {
// Fixes "WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested"
args = append(args, "--platform", "linux/amd64")
args = append(args, "--platform", "linux/amd64", "--load")
}

args = append(args,
Expand All @@ -95,7 +95,6 @@ func BuildAddLabelsAndSchemaToImage(dir, image string, labels map[string]string,
// We're not using context, but Docker requires we pass a context
args = append(args, ".")
cmd := exec.Command("docker", args...)
cmd.Dir = dir

dockerfile := "FROM " + image + "\n"
dockerfile += "COPY " + bundledSchemaFile + " .cog\n"
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func Build(cfg *config.Config, dir, imageName string, secrets []string, noCache,
}
}

if err := docker.BuildAddLabelsAndSchemaToImage(dir, imageName, labels, bundledSchemaFile, bundledSchemaPy); err != nil {
if err := docker.BuildAddLabelsAndSchemaToImage(imageName, labels, bundledSchemaFile, bundledSchemaPy); err != nil {
return fmt.Errorf("Failed to add labels to image: %w", err)
}
return nil
Expand Down