diff --git a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/codenvy/che.properties b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/codenvy/che.properties index dc527f17eb4..20743cecb18 100644 --- a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/codenvy/che.properties +++ b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/codenvy/che.properties @@ -133,6 +133,11 @@ che.docker.privilege=false # Limits the number of processes that can be forked inside a cgroup. Set -1 for unlimited. # Since 4.3 kernel. che.docker.pids_limit=-1 +# Adds options when mounting the /projects volume. +che.docker.volumes_projects_options=Z + +# Adds options when mounting the /mnt/che/terminal, /mnt/che/ws-agent.tar.gz, /mnt/che/conf volume +che.docker.volumes_agent_options=ro,Z # If the browser clients that are accessing Che are remote AND the configuration of Docker is an # internal IP address or using Unix sockets, then remote browser clients will not be able to connect diff --git a/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/DockerExtConfBindingProvider.java b/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/DockerExtConfBindingProvider.java index b27bf1ead1b..70b490af2a3 100644 --- a/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/DockerExtConfBindingProvider.java +++ b/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/DockerExtConfBindingProvider.java @@ -17,6 +17,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; import java.io.File; @@ -37,9 +39,13 @@ public class DockerExtConfBindingProvider implements Provider { public static final String EXT_CHE_LOCAL_CONF_DIR = "/mnt/che/conf"; private static final String PLUGIN_CONF = "plugin-conf"; - private static final String CONTAINER_TARGET = ":" + EXT_CHE_LOCAL_CONF_DIR + ":ro,Z"; + private static final String CONTAINER_TARGET = ":" + EXT_CHE_LOCAL_CONF_DIR; private static final Logger LOG = LoggerFactory.getLogger(DockerExtConfBindingProvider.class); + @Inject + @Named("che.docker.volumes_agent_options") + private String volumeOptions; + @Override public String get() { String localConfDir = System.getenv(CheBootstrap.CHE_LOCAL_CONF_DIR); @@ -54,19 +60,23 @@ public String get() { } return null; } - if (SystemInfo.isWindows()) { try { final Path cheHome = WindowsHostUtils.ensureCheHomeExist(); final Path plgConfDir = cheHome.resolve(PLUGIN_CONF); IoUtil.copy(extConfDir, plgConfDir.toFile(), null, true); - return plgConfDir.toString() + CONTAINER_TARGET; + return getTargetOptions(plgConfDir.toString()); } catch (IOException e) { LOG.warn(e.getMessage()); throw new RuntimeException(e); } } else { - return extConfDir.getAbsolutePath() + CONTAINER_TARGET; + return getTargetOptions(extConfDir.getAbsolutePath()); } } + + private String getTargetOptions(final String path) { + return path + CONTAINER_TARGET + ":" + volumeOptions; + } + } diff --git a/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/TerminalVolumeProvider.java b/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/TerminalVolumeProvider.java index 7de29f3c9fa..0926871556a 100644 --- a/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/TerminalVolumeProvider.java +++ b/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/TerminalVolumeProvider.java @@ -34,7 +34,7 @@ @Singleton public class TerminalVolumeProvider implements Provider { - private static final String CONTAINER_TARGET = ":/mnt/che/terminal:ro,Z"; + private static final String CONTAINER_TARGET = ":/mnt/che/terminal"; private static final String TERMINAL = "terminal"; private static final Logger LOG = LoggerFactory.getLogger(TerminalVolumeProvider.class); @@ -42,6 +42,10 @@ public class TerminalVolumeProvider implements Provider { @Named("che.workspace.terminal_linux_amd64") private String terminalArchivePath; + @Inject + @Named("che.docker.volumes_agent_options") + private String volumeOptions; + @Override public String get() { if (SystemInfo.isWindows()) { @@ -49,13 +53,18 @@ public String get() { final Path cheHome = WindowsHostUtils.ensureCheHomeExist(); final Path terminalPath = cheHome.resolve(TERMINAL); IoUtil.copy(Paths.get(terminalArchivePath).toFile(), terminalPath.toFile(), null, true); - return terminalPath.toString() + CONTAINER_TARGET; + return getTargetOptions(terminalPath.toString()); } catch (IOException e) { LOG.warn(e.getMessage()); throw new RuntimeException(e); } } else { - return terminalArchivePath + CONTAINER_TARGET; + return getTargetOptions(terminalArchivePath); } } + + private String getTargetOptions(final String path) { + return path + CONTAINER_TARGET + ":" + volumeOptions; + } + } diff --git a/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/WsAgentVolumeProvider.java b/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/WsAgentVolumeProvider.java index 38d8c58cf51..a990a55ab65 100644 --- a/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/WsAgentVolumeProvider.java +++ b/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/ext/provider/WsAgentVolumeProvider.java @@ -37,7 +37,7 @@ @Singleton public class WsAgentVolumeProvider implements Provider { - private static final String CONTAINER_TARGET = ":/mnt/che/ws-agent.tar.gz:ro,Z"; + private static final String CONTAINER_TARGET = ":/mnt/che/ws-agent.tar.gz"; private static final String WS_AGENT = "ws-agent.tar.gz"; private static final Logger LOG = LoggerFactory.getLogger(WsAgentVolumeProvider.class); @@ -46,19 +46,28 @@ public class WsAgentVolumeProvider implements Provider { @Named("che.workspace.agent.dev") private String wsAgentArchivePath; + @Inject + @Named("che.docker.volumes_agent_options") + private String volumeOptions; + @Override public String get() { + if (SystemInfo.isWindows()) { try { final Path cheHome = WindowsHostUtils.ensureCheHomeExist(); final Path path = Files.copy(Paths.get(wsAgentArchivePath), cheHome.resolve(WS_AGENT), REPLACE_EXISTING); - return path.toString() + CONTAINER_TARGET; + return getTargetOptions(path.toString()); } catch (IOException e) { LOG.warn(e.getMessage()); throw new RuntimeException(e); } } else { - return wsAgentArchivePath + CONTAINER_TARGET; + return getTargetOptions(wsAgentArchivePath); } } + + private String getTargetOptions(final String path) { + return path + CONTAINER_TARGET + ":" + volumeOptions; + } } diff --git a/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/local/LocalCheInfrastructureProvisioner.java b/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/local/LocalCheInfrastructureProvisioner.java index bd3306f8575..baff2e17480 100644 --- a/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/local/LocalCheInfrastructureProvisioner.java +++ b/plugins/plugin-docker/che-plugin-docker-machine/src/main/java/org/eclipse/che/plugin/docker/machine/local/LocalCheInfrastructureProvisioner.java @@ -35,16 +35,19 @@ public class LocalCheInfrastructureProvisioner extends DefaultInfrastructureProv private final WorkspaceFolderPathProvider workspaceFolderPathProvider; private final WindowsPathEscaper pathEscaper; private final String projectFolderPath; + private final String volumesOptions; @Inject public LocalCheInfrastructureProvisioner(AgentConfigApplier agentConfigApplier, WorkspaceFolderPathProvider workspaceFolderPathProvider, WindowsPathEscaper pathEscaper, - @Named("che.workspace.projects.storage") String projectFolderPath) { + @Named("che.workspace.projects.storage") String projectFolderPath, + @Named("che.docker.volumes_agent_options") String volumeOptions) { super(agentConfigApplier); this.workspaceFolderPathProvider = workspaceFolderPathProvider; this.pathEscaper = pathEscaper; this.projectFolderPath = projectFolderPath; + this.volumesOptions = volumeOptions; } @Override @@ -66,9 +69,9 @@ public void provision(Environment envConfig, CheServicesEnvironmentImpl internal // add bind-mount volume for projects in a workspace String projectFolderVolume; try { - projectFolderVolume = format("%s:%s:Z", + projectFolderVolume = format("%s:%s:%s", workspaceFolderPathProvider.getPath(internalEnv.getWorkspaceId()), - projectFolderPath); + projectFolderPath, volumesOptions); } catch (IOException e) { throw new EnvironmentException("Error occurred on resolving path to files of workspace " + internalEnv.getWorkspaceId());