Skip to content

Commit

Permalink
Add option to mount volumes via envvar (#39)
Browse files Browse the repository at this point in the history
By setting VSYNCER_DOCKER_VOLUMES=/path/to/something,/path/to/something/else,
one can mount these directories in the docker container as if using `-v path:path`.

Signed-off-by: Diogo Behrens <diogo.behrens@huawei.com>
  • Loading branch information
db7 authored Apr 18, 2024
1 parent c290619 commit c1196a9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/docker.go
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ func init() {
RegEnv("VSYNCER_DOCKER", useDocker, "Use Docker container when calling clang, GenMC, Dat3M, etc")
RegEnv("VSYNCER_DOCKER_IMAGE", dockerImage, "Docker image with clang, GenMC, Dat3M")
RegEnv("VSYNCER_DOCKER_TAG", dockerTag, "Docker image tag")
RegEnv("VSYNCER_DOCKER_VOLUMES", "", "Comma-separated list of additional volumes to mount")
}

func DockerPull(ctx context.Context) error {
@@ -90,6 +91,10 @@ func DockerRun(ctx context.Context, args []string, volumes []string) error {
// mount current directory
cmd = append(cmd, "-v", fmt.Sprintf("%s:%s", cwd, cwd))

if v := GetEnv("VSYNCER_DOCKER_VOLUMES"); v != "" {
volumes = append(volumes, strings.Split(v, ",")...)
}

for _, v := range volumes {
cmd = append(cmd, "-v", fmt.Sprintf("%s:%s", v, v))
}

0 comments on commit c1196a9

Please sign in to comment.