Skip to content

Commit 09de42f

Browse files
authored
Support for docker steps in host environment (#1674)
* Support for docker steps in host environment * removed workdir changes
1 parent 6744e68 commit 09de42f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pkg/runner/action.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,10 @@ func newStepContainer(ctx context.Context, step step, image string, cmd []string
356356
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))
357357

358358
binds, mounts := rc.GetBindsAndMounts()
359-
359+
networkMode := fmt.Sprintf("container:%s", rc.jobContainerName())
360+
if rc.IsHostEnv(ctx) {
361+
networkMode = "default"
362+
}
360363
stepContainer := container.NewContainer(&container.NewContainerInput{
361364
Cmd: cmd,
362365
Entrypoint: entrypoint,
@@ -367,7 +370,7 @@ func newStepContainer(ctx context.Context, step step, image string, cmd []string
367370
Name: createContainerName(rc.jobContainerName(), stepModel.ID),
368371
Env: envList,
369372
Mounts: mounts,
370-
NetworkMode: fmt.Sprintf("container:%s", rc.jobContainerName()),
373+
NetworkMode: networkMode,
371374
Binds: binds,
372375
Stdout: logWriter,
373376
Stderr: logWriter,

pkg/runner/run_context.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,18 @@ func (rc *RunContext) interpolateOutputs() common.Executor {
384384

385385
func (rc *RunContext) startContainer() common.Executor {
386386
return func(ctx context.Context) error {
387-
image := rc.platformImage(ctx)
388-
if strings.EqualFold(image, "-self-hosted") {
387+
if rc.IsHostEnv(ctx) {
389388
return rc.startHostEnvironment()(ctx)
390389
}
391390
return rc.startJobContainer()(ctx)
392391
}
393392
}
394393

394+
func (rc *RunContext) IsHostEnv(ctx context.Context) bool {
395+
image := rc.platformImage(ctx)
396+
return strings.EqualFold(image, "-self-hosted")
397+
}
398+
395399
func (rc *RunContext) stopContainer() common.Executor {
396400
return rc.stopJobContainer()
397401
}

0 commit comments

Comments
 (0)