Merge pull request #7580 from dokku/7520-drop-network-on-dockerfile-build

Do not set network flag when building dockerfile images
This commit is contained in:
Jose Diaz-Gonzalez
2025-03-09 06:05:10 -05:00
committed by GitHub
2 changed files with 12 additions and 4 deletions

View File

@@ -20,13 +20,16 @@ func main() {
switch trigger { switch trigger {
case "docker-args-process-build": case "docker-args-process-build":
appName := flag.Arg(0) appName := flag.Arg(0)
err = network.TriggerDockerArgsProcess(appName) imageSourceType := flag.Arg(1)
err = network.TriggerDockerArgsProcess("build", appName, imageSourceType)
case "docker-args-process-deploy": case "docker-args-process-deploy":
appName := flag.Arg(0) appName := flag.Arg(0)
err = network.TriggerDockerArgsProcess(appName) imageSourceType := flag.Arg(1)
err = network.TriggerDockerArgsProcess("deploy", appName, imageSourceType)
case "docker-args-process-run": case "docker-args-process-run":
appName := flag.Arg(0) appName := flag.Arg(0)
err = network.TriggerDockerArgsProcess(appName) imageSourceType := flag.Arg(1)
err = network.TriggerDockerArgsProcess("run", appName, imageSourceType)
case "install": case "install":
err = network.TriggerInstall() err = network.TriggerInstall()
case "network-build-config": case "network-build-config":

View File

@@ -10,12 +10,17 @@ import (
) )
// TriggerDockerArgsProcess outputs the network plugin docker options for an app // TriggerDockerArgsProcess outputs the network plugin docker options for an app
func TriggerDockerArgsProcess(appName string) error { func TriggerDockerArgsProcess(stage string, appName string, imageSourceType string) error {
stdin, err := io.ReadAll(os.Stdin) stdin, err := io.ReadAll(os.Stdin)
if err != nil { if err != nil {
return err return err
} }
if stage == "build" && imageSourceType == "dockerfile" {
fmt.Print(string(stdin))
return nil
}
initialNetwork := reportComputedInitialNetwork(appName) initialNetwork := reportComputedInitialNetwork(appName)
if initialNetwork != "" { if initialNetwork != "" {
fmt.Printf(" --network=%s ", initialNetwork) fmt.Printf(" --network=%s ", initialNetwork)