@@ -27,8 +27,6 @@ public class DockerService implements DisposableBean {
27
27
private static final Logger LOGGER = LoggerFactory .getLogger (DockerService .class );
28
28
private static final String WORKER_LABEL = "jshell-api-worker" ;
29
29
private static final UUID WORKER_UNIQUE_ID = UUID .randomUUID ();
30
- private static final String IMAGE_NAME = "togetherjava.org:5001/togetherjava/jshellwrapper" ;
31
- private static final String IMAGE_TAG = "master" ;
32
30
33
31
private final DockerClient client ;
34
32
private final Config config ;
@@ -39,7 +37,8 @@ public class DockerService implements DisposableBean {
39
37
40
38
private final String jshellWrapperBaseImageName ;
41
39
42
- public DockerService (Config config , StartupScriptsService startupScriptsService ) throws InterruptedException , IOException {
40
+ public DockerService (Config config , StartupScriptsService startupScriptsService )
41
+ throws InterruptedException , IOException {
43
42
this .startupScriptsService = startupScriptsService ;
44
43
DefaultDockerClientConfig clientConfig =
45
44
DefaultDockerClientConfig .createDefaultConfigBuilder ().build ();
@@ -83,11 +82,11 @@ private void cleanupLeftovers(UUID currentId) {
83
82
*/
84
83
private boolean isImagePresentLocally () {
85
84
return client .listImagesCmd ()
86
- .withFilter ("reference" , List .of (jshellWrapperBaseImageName ))
87
- .exec ()
88
- .stream ()
89
- .flatMap (it -> Arrays .stream (it .getRepoTags ()))
90
- .anyMatch (it -> it .endsWith (Config .JSHELL_WRAPPER_IMAGE_NAME_TAG ));
85
+ .withFilter ("reference" , List .of (jshellWrapperBaseImageName ))
86
+ .exec ()
87
+ .stream ()
88
+ .flatMap (it -> Arrays .stream (it .getRepoTags ()))
89
+ .anyMatch (it -> it .endsWith (Config .JSHELL_WRAPPER_IMAGE_NAME_TAG ));
91
90
}
92
91
93
92
/**
@@ -96,9 +95,9 @@ private boolean isImagePresentLocally() {
96
95
private void pullImage () throws InterruptedException {
97
96
if (!isImagePresentLocally ()) {
98
97
client .pullImageCmd (jshellWrapperBaseImageName )
99
- .withTag (IMAGE_TAG )
100
- .exec (new PullImageResultCallback ())
101
- .awaitCompletion (5 , TimeUnit .MINUTES );
98
+ .withTag ("master" )
99
+ .exec (new PullImageResultCallback ())
100
+ .awaitCompletion (5 , TimeUnit .MINUTES );
102
101
}
103
102
}
104
103
@@ -120,18 +119,19 @@ public String createContainer(String name) {
120
119
.withCpuCount ((long ) Math .ceil (config .dockerCPUsUsage ()))
121
120
.withCpusetCpus (config .dockerCPUSetCPUs ());
122
121
123
- return client .createContainerCmd (jshellWrapperBaseImageName + Config .JSHELL_WRAPPER_IMAGE_NAME_TAG )
124
- .withHostConfig (hostConfig )
125
- .withStdinOpen (true )
126
- .withAttachStdin (true )
127
- .withAttachStderr (true )
128
- .withAttachStdout (true )
129
- .withEnv ("evalTimeoutSeconds=" + config .evalTimeoutSeconds (),
130
- "sysOutCharLimit=" + config .sysOutCharLimit ())
131
- .withLabels (Map .of (WORKER_LABEL , WORKER_UNIQUE_ID .toString ()))
132
- .withName (name )
133
- .exec ()
134
- .getId ();
122
+ return client
123
+ .createContainerCmd (jshellWrapperBaseImageName + Config .JSHELL_WRAPPER_IMAGE_NAME_TAG )
124
+ .withHostConfig (hostConfig )
125
+ .withStdinOpen (true )
126
+ .withAttachStdin (true )
127
+ .withAttachStderr (true )
128
+ .withAttachStdout (true )
129
+ .withEnv ("evalTimeoutSeconds=" + config .evalTimeoutSeconds (),
130
+ "sysOutCharLimit=" + config .sysOutCharLimit ())
131
+ .withLabels (Map .of (WORKER_LABEL , WORKER_UNIQUE_ID .toString ()))
132
+ .withName (name )
133
+ .exec ()
134
+ .getId ();
135
135
}
136
136
137
137
/**
@@ -143,7 +143,7 @@ public String createContainer(String name) {
143
143
*/
144
144
public ContainerState initializeContainer (String name , StartupScriptId startupScriptId )
145
145
throws IOException {
146
- if (cachedContainers .isEmpty () || !cachedContainers .containsKey (startupScriptId )) {
146
+ if (startupScriptId == null || cachedContainers .isEmpty () || !cachedContainers .containsKey (startupScriptId )) {
147
147
String containerId = createContainer (name );
148
148
return setupContainerWithScript (containerId , true , startupScriptId );
149
149
}
0 commit comments