|
|
@@ -17,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import java.io.File;
|
|
|
import java.time.Duration;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -88,27 +89,29 @@ public class DockerImpl implements Docker {
|
|
|
// repoTag 格式为 docker.reghao.cn/devops:12345678
|
|
|
.withTags(Set.of(repoTag))
|
|
|
.start()
|
|
|
- .awaitImageId();
|
|
|
+ .awaitImageId(300, TimeUnit.SECONDS);
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception(ExceptionUtil.errorMsg(e));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
public void build(String repoTag, String compileHome) throws Exception {
|
|
|
String dockerfilePath = compileHome + "/Dockerfile";
|
|
|
dockerClient.buildImageCmd()
|
|
|
.withDockerfile(new File(dockerfilePath))
|
|
|
.withTags(Set.of(repoTag))
|
|
|
.start()
|
|
|
- .awaitImageId();
|
|
|
+ .awaitImageId(300, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void push(String image) throws Exception {
|
|
|
try {
|
|
|
ResultCallback.Adapter<PushResponseItem> callback = new PushCallback();
|
|
|
- dockerClient.pushImageCmd(image).exec(callback).awaitCompletion();
|
|
|
+ dockerClient.pushImageCmd(image)
|
|
|
+ //.exec(new ResultCallback.Adapter<>())
|
|
|
+ .exec(callback)
|
|
|
+ .awaitCompletion(300, TimeUnit.SECONDS);
|
|
|
PushCallback pushCallback = (PushCallback) callback;
|
|
|
int code = pushCallback.getCode();
|
|
|
if (code != 0) {
|
|
|
@@ -319,11 +322,11 @@ public class DockerImpl implements Docker {
|
|
|
public void onNext(PushResponseItem object) {
|
|
|
PushResponseItem.ErrorDetail errorDetail = object.getErrorDetail();
|
|
|
if (errorDetail != null) {
|
|
|
- log.info("error: {} {}", errorDetail.getCode(), errorDetail.getMessage());
|
|
|
+ //log.info("error: {} {}", errorDetail.getCode(), errorDetail.getMessage());
|
|
|
code = 1;
|
|
|
msg = errorDetail.getMessage();
|
|
|
} else {
|
|
|
- log.info("info: {} {} {}", object.getStatus(), object.getId(), object.getProgressDetail());
|
|
|
+ //log.info("info: {} {} {}", object.getStatus(), object.getId(), object.getProgressDetail());
|
|
|
}
|
|
|
}
|
|
|
|