Skip to content

Commit

Permalink
fix docker worker command build
Browse files Browse the repository at this point in the history
  • Loading branch information
zc2638 committed Apr 5, 2024
1 parent b8eb09d commit d76d137
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions core/worker/hooks/docker/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ import (
)

func toContainerConfig(spec *worker.Workflow, step *worker.Step) *container.Config {
env := step.CombineEnv(map[string]string{
"INK_SCRIPT": shell.Script(step.Command),
})

cfg := &container.Config{
AttachStdin: false,
AttachStdout: true,
Expand All @@ -42,13 +38,17 @@ func toContainerConfig(spec *worker.Workflow, step *worker.Step) *container.Conf
ArgsEscaped: false,
WorkingDir: step.WorkingDir,
Image: step.Image,
Env: worker.EnvToSlice(env),
}

var configEnv map[string]string

if len(step.Entrypoint) > 0 {
cfg.Entrypoint = step.Entrypoint
cfg.Cmd = step.Command
} else {
} else if len(step.Command) > 0 {
configEnv = map[string]string{
"INK_SCRIPT": shell.Script(step.Command),
}
cmdName, args := shell.Command()
if len(step.Shell) > 0 {
cmdName = step.Shell[0]
Expand All @@ -57,6 +57,8 @@ func toContainerConfig(spec *worker.Workflow, step *worker.Step) *container.Conf
cfg.Entrypoint = append([]string{cmdName}, args...)
cfg.Cmd = shell.EchoEnvCommand("INK_SCRIPT", cmdName)
}
env := step.CombineEnv(configEnv)
cfg.Env = worker.EnvToSlice(env)

if len(step.VolumeMounts) != 0 {
cfg.Volumes = toVolumeSet(spec, step)
Expand Down

0 comments on commit d76d137

Please sign in to comment.