Skip to content
Snippets Groups Projects
Commit 3b714d14 authored by Luc Everse's avatar Luc Everse :passport_control:
Browse files

Merge branch 'development' into 'master'

Release v2.3.4

See merge request !167
parents 36dc6292 62f4387c
No related branches found
No related tags found
1 merge request!167Release v2.3.4
Pipeline #444559 passed
......@@ -26,7 +26,7 @@ allprojects {
apply plugin: ScompPlugin
group 'nl.tudelft.ewi'
version = '2.3.3'
version = '2.3.4'
sourceCompatibility = '1.11'
targetCompatibility = '1.11'
......
......@@ -36,6 +36,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.GZIPOutputStream;
......@@ -68,6 +69,16 @@ public class DockerRunner extends JobAnalyzer {
*/
private static final Path OUTPUT_PATH = BASE_PATH.resolve("out");
/**
* The pattern matching characters that are not allowed in Docker image names.
*/
private static final Pattern DOCKER_CONTAINER_NAME_ILLEGALS = Pattern.compile("[^a-zA-Z0-9_-]");
/**
* The default memory limit to give to containers.
*/
private static final long DEFAULT_MEMORY_LIMIT = 4L * 1024 * 1024 * 1024;
/**
* The Docker API instance to use.
*/
......@@ -175,7 +186,14 @@ public class DockerRunner extends JobAnalyzer {
final var config = new HashMap<String, Object>();
config.put("Image", id);
final var container = this.api.createContainer(config);
config.put("HostConfig", Map.of(
"Memory", DEFAULT_MEMORY_LIMIT,
"MemorySwap", DEFAULT_MEMORY_LIMIT
));
final var container = this.api.createContainer(
"auta-job-" + DOCKER_CONTAINER_NAME_ILLEGALS.matcher(id).replaceAll("_"),
config
);
logger.info("Created container with ID {}", container);
return container;
......
......@@ -53,6 +53,20 @@ public class DockerApi {
return res.get("Id").getAsString();
}
/**
* Creates a new Docker container.
*
* @param name the name of the container
* @param config the container configuration, passed as-is
*
* @return the ID of the container
*/
public String createContainer(final String name, final Map<String, Object> config) {
final var res = this.api.postWithJson("/containers/create?name=" + name, config);
return res.get("Id").getAsString();
}
/**
* Starts the container.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment