Skip to content

Commit

Permalink
#179 update ci profile to use fabric8 for multi-platform docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
csun-cpointe committed Jul 4, 2024
1 parent d893c51 commit 426f4ad
Showing 8 changed files with 45 additions and 109 deletions.
18 changes: 0 additions & 18 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
@@ -1090,24 +1090,6 @@ To suppress enforce-helm-version rule, you must add following plugin to the root
<hide.manual.actions>true</hide.manual.actions>
</properties>
</profile>
<profile>
<id>arm64</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.technologybrewery.habushu</groupId>
<artifactId>habushu-maven-plugin</artifactId>
<version>${version.habushu.plugin}</version>
<configuration>
<!-- we don't need to deploy "any" wheel artifacts twice: -->
<skipDeploy>true</skipDeploy>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ public void theConfigLoaderUsesVaultPropertyDaoToWriteToVault() {

private void setupVaultContainer() {
final Properties encryptProperties = Krausening.getInstance().getProperties("encrypt.properties");
String dockerImage = "ghcr.io/boozallen/aissemble-vault:" + System.getProperty("version.aissemble.vault") + this.getSystemArchitectureTag();
String dockerImage = "ghcr.io/boozallen/aissemble-vault:" + System.getProperty("version.aissemble.vault");
final DockerImageName vaultImage = DockerImageName.parse(dockerImage).asCompatibleSubstituteFor("vault");
vaultContainer = new VaultContainer(vaultImage);
vaultContainer.setWaitStrategy(Wait.forListeningPort());
@@ -106,15 +106,6 @@ private void setupVaultContainer() {
encryptProperties.setProperty("secrets.unseal.keys", unsealKeysJSONArrayString.replaceAll("[\\s|\\[\\]\"]", ""));
}

private String getSystemArchitectureTag() {
String arch = System.getProperty("os.arch").toLowerCase().trim();
switch(arch) {
case "aarch64":
case "arm64": return "-arm64";
default: return "-amd64";
}
}

private String inputStreamToString(InputStream inputStream) {
try {
return new String(inputStream.readAllBytes());
66 changes: 38 additions & 28 deletions extensions/extensions-docker/pom.xml
Original file line number Diff line number Diff line change
@@ -18,37 +18,47 @@

<profiles>
<profile>
<id>x86</id>
<properties>
<target.architecture>amd64</target.architecture>
<docker.platforms>linux/amd64</docker.platforms>
</properties>
</profile>
<profile>
<id>arm64</id>
<properties>
<target.architecture>arm64</target.architecture>
<docker.platforms>linux/arm64</docker.platforms>
</properties>
<id>ci</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>default-push</id>
<configuration>
<images>
<image>
<name>${docker.baseline.repo.id}/${dockerImageName}:${dockerImageVersion}</name>
<build>
<buildx>
<platforms>
<platform>${docker.platforms}</platform>
</platforms>
</buildx>
<args>
<DELTA_HIVE_CONNECTOR_VERSION>${version.delta.hive.connector}</DELTA_HIVE_CONNECTOR_VERSION>
<DOCKER_BASELINE_REPO_ID>${docker.baseline.repo.id}/</DOCKER_BASELINE_REPO_ID>
<VERSION_AISSEMBLE>${version.aissemble}</VERSION_AISSEMBLE>
<SPARK_VERSION>${version.spark}</SPARK_VERSION>
</args>
<contextDir>${project.basedir}</contextDir>
<dockerFile>./src/main/resources/docker/Dockerfile</dockerFile>
</build>
</image>
</images>
</configuration>
<goals>
<goal>push</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ci</id>
<properties>
<dockerImageVersion>${project.version}-${target.architecture}</dockerImageVersion>
</properties>
</profile>
<profile>
<id>ensure-docker-dependencies</id>
<!-- This profile is used to ensure that the docker dependencies are encoded in Maven properly. Because of
Original file line number Diff line number Diff line change
@@ -61,23 +61,9 @@ def before_feature(context, feature):
# using major, minor, patch and -SNAPSHOT if dev
version = metadata.version("aissemble-extensions-encryption-vault-python")
docker_image += version_to_tag(version)
base_docker_image = docker_image

try:
if platform.machine().lower() in ["arm64", "aarch64"]:
docker_image += "-arm64"
else:
docker_image += "-amd64"

context.test_container = SafeDockerContainer(docker_image)
start_container(context, docker_image, feature)

except:
logger.info(
f"Could not find container {docker_image} (with specific platform). Trying without platform..."
)
context.test_container = SafeDockerContainer(base_docker_image)
start_container(context, base_docker_image, feature)

context.test_container = SafeDockerContainer(docker_image)
start_container(context, docker_image, feature)

root_key_tuple = context.test_container.exec("cat /root_key.txt")
secrets_root_key = root_key_tuple.output.decode()
Original file line number Diff line number Diff line change
@@ -45,21 +45,12 @@ public class HashingSteps {
private static final Logger logger = LoggerFactory.getLogger(HashingSteps.class);
private final GenericContainer<?> genericContainer = new GenericContainer<>(
DockerImageName.parse(
"ghcr.io/boozallen/aissemble-vault:" + System.getProperty("version.aissemble.vault") + this.getSystemArchitectureTag()
"ghcr.io/boozallen/aissemble-vault:" + System.getProperty("version.aissemble.vault")
)
).withCreateContainerCmdModifier(
cmd -> cmd.withCapAdd(Capability.IPC_LOCK)
);

private String getSystemArchitectureTag() {
String arch = System.getProperty("os.arch").toLowerCase().trim();
switch(arch) {
case "aarch64":
case "arm64": return "-arm64";
default: return "-amd64";
}
}

@After("@hashing")
public void tearDown() {
encryptedData = null;
Original file line number Diff line number Diff line change
@@ -24,13 +24,6 @@
logger = LogManager.get_instance().get_logger("Environment")


def select_docker_compose_arch():
machine_arch = platform.machine().lower()
if machine_arch in ["arm64", "aarch64"]:
return "docker-compose-arm64.yml"
return "docker-compose.yml"


def before_all(context):
print("Executing setup for tests...")
os.environ["KRAUSENING_BASE"] = "tests/resources/config/base"
@@ -75,7 +68,7 @@ def before_feature(context, feature):
f"Starting services defined in Docker Compose file at {test_staging_path}"
)

compose = DockerCompose(test_staging_path, select_docker_compose_arch())
compose = DockerCompose(test_staging_path, "docker-compose.yml")
context.docker_compose_containers = compose

compose.start()

This file was deleted.

Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ services:
vault:
# For testing we will pull the image directly from the remote server as opposed to a locally built image.
# This will ensure that the Vault keys are in sync.
image: "ghcr.io/boozallen/aissemble-vault:${version.aissemble}-amd64"
image: "ghcr.io/boozallen/aissemble-vault:${version.aissemble}"
cap_add:
- IPC_LOCK
environment:

0 comments on commit 426f4ad

Please sign in to comment.