From f22b28328c6bd1b59bd870ef6b3a49bf0281375f Mon Sep 17 00:00:00 2001 From: Jinjing Zhou Date: Wed, 3 Aug 2022 20:25:47 +0800 Subject: [PATCH] bug: allow multiple run command and use bash -c (#720) fix run Signed-off-by: Jinjing.Zhou --- pkg/lang/ir/consts.go | 2 +- pkg/lang/ir/interface.go | 2 +- pkg/lang/ir/system.go | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/lang/ir/consts.go b/pkg/lang/ir/consts.go index 989a4c29c..fe765c62d 100644 --- a/pkg/lang/ir/consts.go +++ b/pkg/lang/ir/consts.go @@ -16,7 +16,7 @@ package ir const ( osDefault = "ubuntu20.04" - languageDefault = "python" + languageDefault = "python3" pypiIndexModeAuto = "auto" // used inside the container diff --git a/pkg/lang/ir/interface.go b/pkg/lang/ir/interface.go index c62c27f08..601538215 100644 --- a/pkg/lang/ir/interface.go +++ b/pkg/lang/ir/interface.go @@ -142,7 +142,7 @@ func RStudioServer() error { func Run(commands []string) error { // TODO(gaocegege): Support order-based exec. - DefaultGraph.Exec = commands + DefaultGraph.Exec = append(DefaultGraph.Exec, commands...) return nil } diff --git a/pkg/lang/ir/system.go b/pkg/lang/ir/system.go index ad56ab9f3..9078c2419 100644 --- a/pkg/lang/ir/system.go +++ b/pkg/lang/ir/system.go @@ -47,13 +47,14 @@ func (g Graph) compileRun(root llb.State) llb.State { return root } root = root.AddEnv("PATH", "$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/conda/bin:/usr/local/julia/bin:/opt/conda/envs/envd/bin") + logrus.Debugf("compile run: %s", strings.Join(g.Exec, " ")) if len(g.Exec) == 1 { - return root.Run(llb.Shlex(g.Exec[0])).Root() + return root.Run(llb.Shlex(fmt.Sprintf("bash -c \"%s\"", g.Exec[0]))).Root() } - run := root.Run(llb.Shlex(g.Exec[0])) + run := root.Run(llb.Shlex(fmt.Sprintf("bash -c \"%s\"", g.Exec[0]))) for _, c := range g.Exec[1:] { - run = run.Run(llb.Shlex(c)) + run = run.Run(llb.Shlex(fmt.Sprintf("bash -c \"%s\"", c))) } return run.Root() }