Skip to content

Commit

Permalink
fix: do not set network flag when building dockerfile images
Browse files Browse the repository at this point in the history
The network flag is unsupported by the docker image build command under buildx (which is default now).

Closes dokku#7520
  • Loading branch information
josegonzalez committed Mar 9, 2025
1 parent ed58641 commit 87cbbdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions plugins/network/src/triggers/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ func main() {
switch trigger {
case "docker-args-process-build":
appName := flag.Arg(0)
err = network.TriggerDockerArgsProcess(appName)
imageSourceType := flag.Arg(1)
err = network.TriggerDockerArgsProcess("build", appName, imageSourceType)
case "docker-args-process-deploy":
appName := flag.Arg(0)
err = network.TriggerDockerArgsProcess(appName)
imageSourceType := flag.Arg(1)
err = network.TriggerDockerArgsProcess("deploy", appName, imageSourceType)
case "docker-args-process-run":
appName := flag.Arg(0)
err = network.TriggerDockerArgsProcess(appName)
imageSourceType := flag.Arg(1)
err = network.TriggerDockerArgsProcess("run", appName, imageSourceType)
case "install":
err = network.TriggerInstall()
case "network-build-config":
Expand Down
7 changes: 6 additions & 1 deletion plugins/network/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ import (
)

// 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)
if err != nil {
return err
}

if stage == "build" && imageSourceType == "dockerfile" {
fmt.Print(string(stdin))
return nil
}

initialNetwork := reportComputedInitialNetwork(appName)
if initialNetwork != "" {
fmt.Printf(" --network=%s ", initialNetwork)
Expand Down

0 comments on commit 87cbbdb

Please sign in to comment.