From 74ce10b3d24de6a612c3ef32fbbdf9b8adcc6982 Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 23 Nov 2017 18:02:19 +0300 Subject: [PATCH] Correctly mounting Selenoid volumes for video recording --- selenoid/docker.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/selenoid/docker.go b/selenoid/docker.go index 043901f..3d8c17f 100644 --- a/selenoid/docker.go +++ b/selenoid/docker.go @@ -510,23 +510,27 @@ func (c *DockerConfigurator) Start() error { return errors.New("Selenoid image is not downloaded: this is probably a bug") } - volumeConfigDir := c.getVolumeConfigDir(selenoidConfigDirElem) - volumes := []string{fmt.Sprintf("%s:/etc/selenoid:ro", volumeConfigDir)} + const videoDirName = "video" + volumeConfigDir := getVolumeConfigDir(c.ConfigDir, selenoidConfigDirElem) + videoConfigDir := getVolumeConfigDir(filepath.Join(c.ConfigDir, videoDirName), append(selenoidConfigDirElem, videoDirName)) + volumes := []string{ + fmt.Sprintf("%s:/etc/selenoid:ro", volumeConfigDir), + fmt.Sprintf("%s:/output", videoConfigDir), + } const dockerSocket = "/var/run/docker.sock" if fileExists(dockerSocket) { volumes = append(volumes, fmt.Sprintf("%s:%s", dockerSocket, dockerSocket)) } overrideEnv := strings.Fields(c.Env) - videoPath := filepath.Join(c.ConfigDir, "video") if !strings.Contains(c.Env, "OVERRIDE_VIDEO_OUTPUT_DIR") { - overrideEnv = append(overrideEnv, fmt.Sprintf("OVERRIDE_VIDEO_OUTPUT_DIR=%s", videoPath)) + overrideEnv = append(overrideEnv, fmt.Sprintf("OVERRIDE_VIDEO_OUTPUT_DIR=%s", videoConfigDir)) } return c.startContainer(selenoidContainerName, image, c.Port, SelenoidDefaultPort, volumes, []string{}, strings.Fields(c.Args), overrideEnv) } -func (c *DockerConfigurator) getVolumeConfigDir(elem []string) string { - configDir := chooseVolumeConfigDir(c.ConfigDir, elem) +func getVolumeConfigDir(defaultConfigDir string, elem []string) string { + configDir := chooseVolumeConfigDir(defaultConfigDir, elem) if runtime.GOOS == "windows" { //A bit ugly, but conditional compilation is even worse return postProcessPath(configDir) }