Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds ability to specify container options in process-compose.yml #249

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/app/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ func (p *Process) getCommander() command.Commander {
p.procConf.Executable,
p.mergeExtraArgs(),
)
} else if p.procConf.IsContainer && strings.ToLower(p.procConf.ContainerRuntime) == "apptainer" {
return command.BuildApptainerCommand(
p.procConf.ContainerRuntime,
p.procConf.ContainerExec,
p.procConf.ContainerVolumes,
p.procConf.ContainerArgs,
p.procConf.ContainerImage,
p.procConf.Executable,
p.mergeExtraArgs(),
)
} else {
return command.BuildCommand(
p.procConf.Executable,
Expand Down
13 changes: 13 additions & 0 deletions src/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"runtime"
"strings"
)

func BuildCommand(cmd string, args []string) *CmdWrapper {
Expand All @@ -32,6 +33,18 @@ func BuildCommandShellArgContext(ctx context.Context, shell ShellConfig, cmd str
}
}

func BuildApptainerCommand(containerRuntime string, containerExecution string, containerVolumes []string, containerArgs []string, containerImage string, containerCmd string, cmdArgs []string) *CmdWrapper {
volumes := "-B " + strings.Join(containerVolumes, ",")
container_args := strings.Join(containerArgs, " ")
args_string := strings.Join(cmdArgs, " ")

args := []string{containerExecution, volumes, container_args, containerImage, containerCmd, args_string}

return &CmdWrapper{
cmd: exec.Command(containerRuntime, args...),
}
}

func getRunnerShell() string {
shell, ok := os.LookupEnv("COMPOSE_SHELL")
if !ok {
Expand Down
6 changes: 6 additions & 0 deletions src/types/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ type ProcessConfig struct {
IsForeground bool `yaml:"is_foreground"`
IsTty bool `yaml:"is_tty"`
IsElevated bool `yaml:"is_elevated"`
IsContainer bool `yaml:"is_container"`
ContainerRuntime string `yaml:"container_runtime"`
ContainerExec string `yaml:"container_execution"`
ContainerVolumes []string `yaml:"container_volumes"`
ContainerImage string `yaml:"container_image"`
ContainerArgs []string `yaml:"container_args"`
ReplicaNum int
ReplicaName string
Executable string
Expand Down