Skip to content

Commit e508866

Browse files
committed
FnCLI fn deploy
1 parent 06e5e0d commit e508866

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

common/common.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const (
5555
MinRequiredDockerVersion = "17.5.0"
5656
BuildxBuilderInstance = "oci_fn_builder"
5757
DefaultAppShape = modelsv2.AppShapeGENERICX86
58+
ContainerEngineType = "docker"
5859
)
5960

6061
var GlobalVerbose bool
@@ -435,7 +436,6 @@ func buildXDockerCommand(imageName, dockerfile string, buildArgs []string, noCac
435436
var label = "imageName=" + imageName
436437
args = append(args, "--build-arg", arg)
437438
args = append(args, "--label", label)
438-
args = append(args, "--push")
439439
}
440440

441441
args = append(args,
@@ -515,10 +515,12 @@ func RunBuild(verbose bool, dir, imageName, dockerfile string, buildArgs []strin
515515
var mappedArchitectures []string
516516
if arch, ok := ShapeMap[shape]; ok {
517517
mappedArchitectures = append(mappedArchitectures, arch...)
518-
err := initializeContainerBuilder(containerEngineType, mappedArchitectures)
519-
if err != nil {
520-
done <- err
521-
return
518+
if containerEngineType == ContainerEngineType {
519+
err := initializeContainerBuilder(containerEngineType, mappedArchitectures)
520+
if err != nil {
521+
done <- err
522+
return
523+
}
522524
}
523525

524526
dockerBuildCmdArgs = buildXDockerCommand(imageName, dockerfile, buildArgs, noCache, mappedArchitectures)
@@ -551,6 +553,15 @@ func RunBuild(verbose bool, dir, imageName, dockerfile string, buildArgs []strin
551553
fmt.Fprintln(os.Stderr)
552554
return fmt.Errorf("build cancelled on signal %v", signal)
553555
}
556+
// Push to docker registry
557+
fmt.Println("Using Container engine", containerEngineType, "to push")
558+
fmt.Printf("Pushing %v to docker registry...", imageName)
559+
cmd := exec.Command(containerEngineType, "push", imageName)
560+
cmd.Stderr = os.Stderr
561+
cmd.Stdout = os.Stdout
562+
if err := cmd.Run(); err != nil {
563+
return fmt.Errorf("error running %v push, are you logged?: %v", containerEngineType, err)
564+
}
554565
return nil
555566
}
556567

0 commit comments

Comments
 (0)