Switch default docker exec command back to `bash {script}`
but allow for setting it via env for testing.
@@ -26,10 +26,12 @@ import (
var (
defaultDockerNumCPUer dockerNumCPUer = &stdlibNumCPUer{}
defaultDockerSSHDialTimeout = 5 * time.Second
+ defaultExecCmd = "bash /home/travis/build.sh"
dockerHelp = map[string]string{
"ENDPOINT / HOST": "[REQUIRED] tcp or unix address for connecting to Docker",
"CERT_PATH": "directory where ca.pem, cert.pem, and key.pem are located (default \"\")",
"CMD": "command (CMD) to run when creating containers (default \"/sbin/init\")",
+ "EXEC_CMD": fmt.Sprintf("command to run when exec'ing the running container (default %q)", defaultExecCmd),
"MEMORY": "memory to allocate to each container (0 disables allocation, default \"4G\")",
"CPUS": "cpu count to allocate to each container (0 disables allocation, default 2)",
"CPU_SET_SIZE": "size of available cpu set (default detected locally via runtime.NumCPU)",
@@ -63,6 +65,7 @@ type dockerProvider struct {
runMemory uint64
runCPUs int
runNative bool
+ execCmd []string
cpuSetsMutex sync.Mutex
cpuSets []bool
@@ -126,6 +129,11 @@ func newDockerProvider(cfg *config.ProviderConfig) (Provider, error) {
cmd = strings.Split(cfg.Get("CMD"), " ")
}
+ execCmd := strings.Split(defaultExecCmd, " ")
+ if cfg.IsSet("EXEC_CMD") {
+ execCmd = strings.Split(cfg.Get("EXEC_CMD"), " ")
+ }
+
memory := uint64(1024 * 1024 * 1024 * 4)
if cfg.IsSet("MEMORY") {
if parsedMemory, err := humanize.ParseBytes(cfg.Get("MEMORY")); err == nil {
@@ -164,6 +172,8 @@ func newDockerProvider(cfg *config.ProviderConfig) (Provider, error) {
runCPUs: int(cpus),
runNative: runNative,
+ execCmd: execCmd,
+
cpuSets: make([]bool, cpuSetSize),
}, nil
}
@@ -439,7 +449,7 @@ func (i *dockerInstance) runScriptExec(ctx gocontext.Context, output io.Writer)
AttachStdout: true,
AttachStderr: true,
Tty: true,
- Cmd: []string{"bash", "-l", "/home/travis/build.sh"},
+ Cmd: i.provider.execCmd,
User: "travis",
Container: i.container.ID,
}
