Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #104 from vania-pooh/master
Browse files Browse the repository at this point in the history
Correctly mounting Selenoid volumes for video recording
  • Loading branch information
vania-pooh authored Nov 23, 2017
2 parents 2d84bb5 + 74ce10b commit a71ee59
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions selenoid/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit a71ee59

Please sign in to comment.