Support for docker steps in host environment (#1674)
* Support for docker steps in host environment * removed workdir changes
This commit is contained in:
parent
6744e68ee2
commit
09de42f067
|
@ -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"))
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))
|
||||||
|
|
||||||
binds, mounts := rc.GetBindsAndMounts()
|
binds, mounts := rc.GetBindsAndMounts()
|
||||||
|
networkMode := fmt.Sprintf("container:%s", rc.jobContainerName())
|
||||||
|
if rc.IsHostEnv(ctx) {
|
||||||
|
networkMode = "default"
|
||||||
|
}
|
||||||
stepContainer := container.NewContainer(&container.NewContainerInput{
|
stepContainer := container.NewContainer(&container.NewContainerInput{
|
||||||
Cmd: cmd,
|
Cmd: cmd,
|
||||||
Entrypoint: entrypoint,
|
Entrypoint: entrypoint,
|
||||||
|
@ -367,7 +370,7 @@ func newStepContainer(ctx context.Context, step step, image string, cmd []string
|
||||||
Name: createContainerName(rc.jobContainerName(), stepModel.ID),
|
Name: createContainerName(rc.jobContainerName(), stepModel.ID),
|
||||||
Env: envList,
|
Env: envList,
|
||||||
Mounts: mounts,
|
Mounts: mounts,
|
||||||
NetworkMode: fmt.Sprintf("container:%s", rc.jobContainerName()),
|
NetworkMode: networkMode,
|
||||||
Binds: binds,
|
Binds: binds,
|
||||||
Stdout: logWriter,
|
Stdout: logWriter,
|
||||||
Stderr: logWriter,
|
Stderr: logWriter,
|
||||||
|
|
|
@ -384,14 +384,18 @@ func (rc *RunContext) interpolateOutputs() common.Executor {
|
||||||
|
|
||||||
func (rc *RunContext) startContainer() common.Executor {
|
func (rc *RunContext) startContainer() common.Executor {
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
image := rc.platformImage(ctx)
|
if rc.IsHostEnv(ctx) {
|
||||||
if strings.EqualFold(image, "-self-hosted") {
|
|
||||||
return rc.startHostEnvironment()(ctx)
|
return rc.startHostEnvironment()(ctx)
|
||||||
}
|
}
|
||||||
return rc.startJobContainer()(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 {
|
func (rc *RunContext) stopContainer() common.Executor {
|
||||||
return rc.stopJobContainer()
|
return rc.stopJobContainer()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue