Skip to content

Commit

Permalink
Added new property to pass volumes to the container
Browse files Browse the repository at this point in the history
  • Loading branch information
fmichielssen committed Dec 15, 2016
1 parent b87dfb1 commit 83a91a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/eu/openanalytics/services/AppService.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static class ShinyApp {
private String[] dockerDns;
private String dockerMemory;
private String dockerEnvFile;
private String[] dockerVolumes;
private String[] groups;

public String getName() {
Expand Down Expand Up @@ -119,6 +120,13 @@ public String getDockerEnvFile() {
public void setDockerEnvFile(String dockerEnvFile) {
this.dockerEnvFile = dockerEnvFile;
}

public String[] getDockerVolumes() {
return dockerVolumes;
}
public void setDockerVolumes(String[] dockerVolumes) {
this.dockerVolumes = dockerVolumes;
}

public String[] getGroups() {
return groups;
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/eu/openanalytics/services/DockerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ private Proxy startProxy(String userName, String appName) {
.exposedPorts("3838")
.cmd(app.getDockerCmd())
.env(buildEnv(userName, app))
.volumes(buildVolumes(app))
.build();

ContainerCreation container = dockerClient.createContainer(containerConfig);
Expand Down Expand Up @@ -328,6 +329,18 @@ private List<String> buildEnv(String userName, ShinyApp app) throws IOException
return env;
}

private Set<String> buildVolumes(ShinyApp app) {
Set<String> volumes = new HashSet<>();

if (app.getDockerVolumes() != null) {
for (String vol: app.getDockerVolumes()) {
volumes.add(vol);
}
}

return volumes;
}

private int getFreePort() {
int startPort = Integer.valueOf(environment.getProperty("shiny.proxy.docker.port-range-start"));
int nextPort = startPort;
Expand Down

0 comments on commit 83a91a5

Please sign in to comment.