-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "remove airbyte-commons-docker (#21756)"
This reverts commit 9c4100b.
- Loading branch information
1 parent
c686c6d
commit 2f8f303
Showing
33 changed files
with
159 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
plugins { | ||
id "java-library" | ||
} | ||
|
||
dependencies { | ||
implementation 'org.apache.commons:commons-compress:1.20' | ||
implementation 'com.github.docker-java:docker-java:3.2.8' | ||
implementation 'com.github.docker-java:docker-java-transport-httpclient5:3.2.8' | ||
|
||
testImplementation 'org.apache.commons:commons-lang3:3.11' | ||
} | ||
|
||
Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# airbyte-commons-docker | ||
|
||
This module contains common helpers for interacting with Docker and Docker images from Java. |
39 changes: 39 additions & 0 deletions
39
airbyte-commons-docker/src/main/java/io/airbyte/commons/docker/DockerUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.commons.docker; | ||
|
||
import com.github.dockerjava.api.DockerClient; | ||
import com.github.dockerjava.api.command.BuildImageResultCallback; | ||
import com.github.dockerjava.core.DefaultDockerClientConfig; | ||
import com.github.dockerjava.core.DockerClientConfig; | ||
import com.github.dockerjava.core.DockerClientImpl; | ||
import com.github.dockerjava.httpclient5.ApacheDockerHttpClient; | ||
import com.github.dockerjava.transport.DockerHttpClient; | ||
import java.io.File; | ||
import java.util.Set; | ||
|
||
public class DockerUtils { | ||
|
||
private static final DockerClientConfig CONFIG = DefaultDockerClientConfig.createDefaultConfigBuilder().build(); | ||
private static final DockerHttpClient HTTP_CLIENT = new ApacheDockerHttpClient.Builder() | ||
.dockerHost(CONFIG.getDockerHost()) | ||
.sslConfig(CONFIG.getSSLConfig()) | ||
.maxConnections(100) | ||
.build(); | ||
private static final DockerClient DOCKER_CLIENT = DockerClientImpl.getInstance(CONFIG, HTTP_CLIENT); | ||
|
||
public static String getTaggedImageName(final String dockerRepository, final String tag) { | ||
return String.join(":", dockerRepository, tag); | ||
} | ||
|
||
public static String buildImage(final String dockerFilePath, final String tag) { | ||
return DOCKER_CLIENT.buildImageCmd() | ||
.withDockerfile(new File(dockerFilePath)) | ||
.withTags(Set.of(tag)) | ||
.exec(new BuildImageResultCallback()) | ||
.awaitImageId(); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
airbyte-commons-docker/src/test/java/io/airbyte/commons/docker/DockerUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.commons.docker; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class DockerUtilsTest { | ||
|
||
@Test | ||
void testGetTaggedImageName() { | ||
final String repository = "airbyte/repo"; | ||
final String tag = "12.3"; | ||
assertEquals("airbyte/repo:12.3", DockerUtils.getTaggedImageName(repository, tag)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.