feat: support more options of containers
This commit is contained in:
parent
97629ae8af
commit
b9c20dcaa4
5 changed files with 11 additions and 2 deletions
|
@ -57,6 +57,8 @@ type NewContainerInput struct {
|
|||
UsernsMode string
|
||||
Platform string
|
||||
Options string
|
||||
|
||||
AutoRemove bool
|
||||
}
|
||||
|
||||
// FileEntry is a file to copy to a container
|
||||
|
@ -475,6 +477,7 @@ func (cr *containerReference) create(capAdd []string, capDrop []string) common.E
|
|||
NetworkMode: container.NetworkMode(input.NetworkMode),
|
||||
Privileged: input.Privileged,
|
||||
UsernsMode: container.UsernsMode(input.UsernsMode),
|
||||
AutoRemove: input.AutoRemove,
|
||||
}
|
||||
logger.Debugf("Common container.HostConfig ==> %+v", hostConfig)
|
||||
|
||||
|
|
|
@ -366,6 +366,7 @@ func newStepContainer(ctx context.Context, step step, image string, cmd []string
|
|||
Privileged: rc.Config.Privileged,
|
||||
UsernsMode: rc.Config.UsernsMode,
|
||||
Platform: rc.Config.ContainerArchitecture,
|
||||
AutoRemove: rc.Config.AutoRemove,
|
||||
})
|
||||
return stepContainer
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"github.com/opencontainers/selinux/go-selinux"
|
||||
|
@ -150,7 +151,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
|||
|
||||
rc.JobContainer = container.NewContainer(&container.NewContainerInput{
|
||||
Cmd: nil,
|
||||
Entrypoint: []string{"/usr/bin/tail", "-f", "/dev/null"},
|
||||
Entrypoint: []string{"/bin/sleep", fmt.Sprint(rc.Config.ContainerMaxLifetime.Round(time.Second).Seconds())},
|
||||
WorkingDir: rc.Config.ContainerWorkdir(),
|
||||
Image: image,
|
||||
Username: username,
|
||||
|
@ -158,7 +159,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
|||
Name: name,
|
||||
Env: envList,
|
||||
Mounts: mounts,
|
||||
NetworkMode: "host",
|
||||
NetworkMode: rc.Config.ContainerNetworkMode,
|
||||
Binds: binds,
|
||||
Stdout: logWriter,
|
||||
Stderr: logWriter,
|
||||
|
@ -166,6 +167,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
|||
UsernsMode: rc.Config.UsernsMode,
|
||||
Platform: rc.Config.ContainerArchitecture,
|
||||
Options: rc.options(ctx),
|
||||
AutoRemove: rc.Config.AutoRemove,
|
||||
})
|
||||
|
||||
return common.NewPipelineExecutor(
|
||||
|
|
|
@ -59,6 +59,8 @@ type Config struct {
|
|||
PresetGitHubContext *model.GithubContext // the preset github context, overrides some fields like DefaultBranch, Env, Secrets etc.
|
||||
EventJSON string // the content of JSON file to use for event.json in containers, overrides EventPath
|
||||
ContainerNamePrefix string // the prefix of container name
|
||||
ContainerMaxLifetime time.Duration // the max lifetime of job containers
|
||||
ContainerNetworkMode string // the network mode of job containers
|
||||
DefaultActionInstance string // the default actions web site
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ func (sd *stepDocker) newStepContainer(ctx context.Context, image string, cmd []
|
|||
Privileged: rc.Config.Privileged,
|
||||
UsernsMode: rc.Config.UsernsMode,
|
||||
Platform: rc.Config.ContainerArchitecture,
|
||||
AutoRemove: rc.Config.AutoRemove,
|
||||
})
|
||||
return stepContainer
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue