Skip to content

Commit

Permalink
Support for docker steps in host environment (#1674)
Browse files Browse the repository at this point in the history
* Support for docker steps in host environment

* removed workdir changes
  • Loading branch information
shubham149 authored Mar 14, 2023
1 parent 6744e68 commit 09de42f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions pkg/runner/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,10 @@ func newStepContainer(ctx context.Context, step step, image string, cmd []string
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))

binds, mounts := rc.GetBindsAndMounts()

networkMode := fmt.Sprintf("container:%s", rc.jobContainerName())
if rc.IsHostEnv(ctx) {
networkMode = "default"
}
stepContainer := container.NewContainer(&container.NewContainerInput{
Cmd: cmd,
Entrypoint: entrypoint,
Expand All @@ -367,7 +370,7 @@ func newStepContainer(ctx context.Context, step step, image string, cmd []string
Name: createContainerName(rc.jobContainerName(), stepModel.ID),
Env: envList,
Mounts: mounts,
NetworkMode: fmt.Sprintf("container:%s", rc.jobContainerName()),
NetworkMode: networkMode,
Binds: binds,
Stdout: logWriter,
Stderr: logWriter,
Expand Down
8 changes: 6 additions & 2 deletions pkg/runner/run_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,18 @@ func (rc *RunContext) interpolateOutputs() common.Executor {

func (rc *RunContext) startContainer() common.Executor {
return func(ctx context.Context) error {
image := rc.platformImage(ctx)
if strings.EqualFold(image, "-self-hosted") {
if rc.IsHostEnv(ctx) {
return rc.startHostEnvironment()(ctx)
}
return rc.startJobContainer()(ctx)
}
}

func (rc *RunContext) IsHostEnv(ctx context.Context) bool {
image := rc.platformImage(ctx)
return strings.EqualFold(image, "-self-hosted")
}

func (rc *RunContext) stopContainer() common.Executor {
return rc.stopJobContainer()
}
Expand Down

0 comments on commit 09de42f

Please sign in to comment.