diff --git a/build-server/src/main/java/nl/tudelft/ewi/build/Config.java b/build-server/src/main/java/nl/tudelft/ewi/build/Config.java index 1ccbfc5..332fb35 100644 --- a/build-server/src/main/java/nl/tudelft/ewi/build/Config.java +++ b/build-server/src/main/java/nl/tudelft/ewi/build/Config.java @@ -8,11 +8,11 @@ public interface Config { int getMaximumConcurrentJobs(); String getStagingDirectory(); - - String getWorkingDirectory(); - + String getClientId(); String getClientSecret(); - + + String getDockerUser(); + } diff --git a/build-server/src/main/java/nl/tudelft/ewi/build/PropertyBasedConfig.java b/build-server/src/main/java/nl/tudelft/ewi/build/PropertyBasedConfig.java index 9442495..ed7790f 100644 --- a/build-server/src/main/java/nl/tudelft/ewi/build/PropertyBasedConfig.java +++ b/build-server/src/main/java/nl/tudelft/ewi/build/PropertyBasedConfig.java @@ -15,7 +15,7 @@ public PropertyBasedConfig() { this.properties = new Properties(); reload(); } - + public void reload() { try (InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream("/config.properties"))) { properties.load(reader); @@ -24,29 +24,35 @@ public void reload() { log.error(e.getMessage()); } } - + + @Override public int getHttpPort() { return Integer.parseInt(properties.getProperty("http.port", "8080")); } - + + @Override public int getMaximumConcurrentJobs() { return Integer.parseInt(properties.getProperty("docker.max-containers")); } - + + @Override public String getStagingDirectory() { return properties.getProperty("docker.staging-directory"); } - - public String getWorkingDirectory() { - return properties.getProperty("docker.working-directory"); - } - + + @Override public String getClientId() { return properties.getProperty("authorization.client-id"); } - + + @Override public String getClientSecret() { return properties.getProperty("authorization.client-secret"); } - + + @Override + public String getDockerUser() { + return properties.getProperty("docker.user", "root"); + } + } diff --git a/build-server/src/main/java/nl/tudelft/ewi/build/builds/BuildManager.java b/build-server/src/main/java/nl/tudelft/ewi/build/builds/BuildManager.java index 22c8efd..a6e7f51 100644 --- a/build-server/src/main/java/nl/tudelft/ewi/build/builds/BuildManager.java +++ b/build-server/src/main/java/nl/tudelft/ewi/build/builds/BuildManager.java @@ -272,6 +272,7 @@ public ContainerExit call() throws Exception { ContainerConfig.Builder configBuilder = ContainerConfig.builder() .image(buildInstructionInterpreter.getImage(buildInstruction)) .cmd(buildInstructionInterpreter.getCommand(buildInstruction).split(" ")) + .user(config.getDockerUser()) .volumes(volume) .workingDir(WORK_DIR); diff --git a/build-server/src/main/resources/config.properties b/build-server/src/main/resources/config.properties index b458038..84ff336 100644 --- a/build-server/src/main/resources/config.properties +++ b/build-server/src/main/resources/config.properties @@ -4,5 +4,6 @@ authorization.client-secret = t2hLCXVE docker.max-containers = 3 docker.staging-directory = /workspace docker.working-directory = /workspace +docker.user = root http.port = 8082