Skip to content

Commit

Permalink
Support for command flag in services
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinguidee committed Oct 7, 2023
1 parent 0d69f8a commit 2e446bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions adapter/docker_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (a DockerCliAdapter) CreateContainer(options types.CreateContainerOptions)
Tty: true,
AttachStdout: true,
AttachStderr: true,
Cmd: options.Cmd,
}

hostConfig := container.HostConfig{
Expand Down
5 changes: 5 additions & 0 deletions adapter/runner_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ func (a RunnerDockerAdapter) Start(inst *types.Instance, setStatus func(status s
options.Sysctls = *service.Methods.Docker.Sysctls
}

// cmd
if service.Methods.Docker.Cmd != nil {
options.Cmd = strings.Split(*service.Methods.Docker.Cmd, " ")
}

if service.Methods.Docker.Dockerfile != nil {
options.ImageName = inst.DockerImageVertexName()
id, err = a.createContainer(options)
Expand Down
1 change: 1 addition & 0 deletions types/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type CreateContainerOptions struct {
Env []string `json:"env,omitempty"`
CapAdd []string `json:"cap_add,omitempty"`
Sysctls map[string]string `json:"sysctls,omitempty"`
Cmd []string `json:"cmd,omitempty"`
}

type BuildImageOptions struct {
Expand Down
3 changes: 3 additions & 0 deletions types/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ type ServiceMethodDocker struct {

// Sysctls allows to modify kernel parameters.
Sysctls *map[string]string `yaml:"sysctls,omitempty" json:"sysctls,omitempty"`

// Cmd is the command to run in the container.
Cmd *string `yaml:"command,omitempty" json:"command,omitempty"`
}

type ServiceMethods struct {
Expand Down

0 comments on commit 2e446bb

Please sign in to comment.