|
|
@@ -7,14 +7,15 @@ import cn.reghao.jutil.jdk.exception.ExceptionUtil;
|
|
|
import cn.reghao.jutil.jdk.converter.DateTimeConverter;
|
|
|
import cn.reghao.jutil.jdk.text.TextFile;
|
|
|
import com.github.dockerjava.api.DockerClient;
|
|
|
+import com.github.dockerjava.api.async.ResultCallback;
|
|
|
import com.github.dockerjava.api.command.*;
|
|
|
import com.github.dockerjava.api.model.*;
|
|
|
import com.github.dockerjava.core.DefaultDockerClientConfig;
|
|
|
import com.github.dockerjava.core.DockerClientConfig;
|
|
|
import com.github.dockerjava.core.DockerClientImpl;
|
|
|
-import com.github.dockerjava.core.command.PushImageResultCallback;
|
|
|
import com.github.dockerjava.httpclient5.ApacheDockerHttpClient;
|
|
|
import com.github.dockerjava.transport.DockerHttpClient;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.time.Duration;
|
|
|
@@ -28,6 +29,7 @@ import java.util.stream.Collectors;
|
|
|
* @author reghao
|
|
|
* @date 2021-10-27 03:41:38
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
public class DockerImpl implements Docker {
|
|
|
private DockerClient dockerClient;
|
|
|
private final TextFile textFile = new TextFile();
|
|
|
@@ -109,36 +111,22 @@ public class DockerImpl implements Docker {
|
|
|
@Override
|
|
|
public void push(String image) throws Exception {
|
|
|
try {
|
|
|
- dockerClient.pushImageCmd(image).exec(new PushImageResultCallback()).awaitCompletion();
|
|
|
+ ResultCallback.Adapter<PushResponseItem> callback = new ResultCallback.Adapter<>() {
|
|
|
+ @Override
|
|
|
+ public void onNext(PushResponseItem object) {
|
|
|
+ log.info("{} {} {}", object.getStatus(), object.getId(), object.getProgressDetail());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete() {
|
|
|
+ super.onComplete();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ dockerClient.pushImageCmd(image).exec(callback).awaitCompletion();
|
|
|
+ //dockerClient.pushImageCmd(image).exec(new PushImageResultCallback()).awaitCompletion();
|
|
|
} catch (InterruptedException e) {
|
|
|
throw new Exception(ExceptionUtil.errorMsg(e));
|
|
|
}
|
|
|
- /*dockerClient.pushImageCmd(image).exec(new ResultCallback<PushResponseItem>() {
|
|
|
- @Override
|
|
|
- public void onStart(Closeable closeable) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onNext(PushResponseItem object) {
|
|
|
- System.out.println(object.getStatus());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onError(Throwable throwable) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onComplete() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void close() throws IOException {
|
|
|
-
|
|
|
- }
|
|
|
- }).onComplete();*/
|
|
|
}
|
|
|
|
|
|
@Override
|