MCPcopy
hub / github.com/nektos/act / newStepContainer

Method newStepContainer

pkg/runner/step_docker.go:92–135  ·  view source on GitHub ↗
(ctx context.Context, image string, cmd []string, entrypoint []string)

Source from the content-addressed store, hash-verified

90)
91
92func (sd *stepDocker) newStepContainer(ctx context.Context, image string, cmd []string, entrypoint []string) container.Container {
93 rc := sd.RunContext
94 step := sd.Step
95
96 rawLogger := common.Logger(ctx).WithField("raw_output", true)
97 logWriter := common.NewLineWriter(rc.commandHandler(ctx), func(s string) bool {
98 if rc.Config.LogOutput {
99 rawLogger.Infof("%s", s)
100 } else {
101 rawLogger.Debugf("%s", s)
102 }
103 return true
104 })
105 envList := make([]string, 0)
106 for k, v := range sd.env {
107 envList = append(envList, fmt.Sprintf("%s=%s", k, v))
108 }
109
110 envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TOOL_CACHE", "/opt/hostedtoolcache"))
111 envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_OS", "Linux"))
112 envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_ARCH", container.RunnerArch(ctx)))
113 envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))
114
115 binds, mounts := rc.GetBindsAndMounts()
116 stepContainer := ContainerNewContainer(&container.NewContainerInput{
117 Cmd: cmd,
118 Entrypoint: entrypoint,
119 WorkingDir: rc.JobContainer.ToContainerPath(rc.Config.Workdir),
120 Image: image,
121 Username: rc.Config.Secrets["DOCKER_USERNAME"],
122 Password: rc.Config.Secrets["DOCKER_PASSWORD"],
123 Name: createContainerName(rc.jobContainerName(), step.ID),
124 Env: envList,
125 Mounts: mounts,
126 NetworkMode: fmt.Sprintf("container:%s", rc.jobContainerName()),
127 Binds: binds,
128 Stdout: logWriter,
129 Stderr: logWriter,
130 Privileged: rc.Config.Privileged,
131 UsernsMode: rc.Config.UsernsMode,
132 Platform: rc.Config.ContainerArchitecture,
133 })
134 return stepContainer
135}

Callers 1

runUsesContainerMethod · 0.95

Calls 9

LoggerFunction · 0.92
NewLineWriterFunction · 0.92
RunnerArchFunction · 0.92
makeFunction · 0.85
createContainerNameFunction · 0.85
commandHandlerMethod · 0.80
GetBindsAndMountsMethod · 0.80
jobContainerNameMethod · 0.80
ToContainerPathMethod · 0.65

Tested by

no test coverage detected