Skip to content

Commit

Permalink
Merge pull request #13809 from ioforks/tarball-native-fix
Browse files Browse the repository at this point in the history
Openshift docker build strategy fixes
  • Loading branch information
iocanel authored Dec 17, 2020
2 parents b43b639 + b570068 commit dcc59d0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
<aws-alexa-sdk.version>2.37.1</aws-alexa-sdk.version>
<azure-functions-java-library.version>1.3.0</azure-functions-java-library.version>
<kotlin.version>1.4.20</kotlin.version>
<dekorate.version>0.13.6</dekorate.version>
<dekorate.version>0.14.0</dekorate.version>
<maven-artifact-transfer.version>0.10.0</maven-artifact-transfer.version>
<jline.version>2.14.6</jline.version>
<maven-invoker.version>3.0.1</maven-invoker.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,23 @@ public void openshiftRequirementsJvm(OpenshiftConfig openshiftConfig,
builderImageProducer.produce(new BaseImageInfoBuildItem(config.baseJvmImage));
Optional<OpenshiftBaseJavaImage> baseImage = OpenshiftBaseJavaImage.findMatching(config.baseJvmImage);

baseImage.ifPresent(b -> {
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getJarEnvVar(), pathToJar, null));
envProducer.produce(
KubernetesEnvBuildItem.createSimpleVar(b.getJarLibEnvVar(), concatUnixPaths(jarDirectory, "lib"), null));
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getClasspathEnvVar(), classpath, null));
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getJvmOptionsEnvVar(),
String.join(" ", config.jvmArguments), null));
});

if (!baseImage.isPresent()) {
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar("JAVA_APP_JAR", pathToJar, null));
envProducer.produce(
KubernetesEnvBuildItem.createSimpleVar("JAVA_LIB_DIR", concatUnixPaths(jarDirectory, "lib"), null));
commandProducer.produce(new KubernetesCommandBuildItem("java", args.toArray(new String[args.size()])));
if (config.buildStrategy != BuildStrategy.DOCKER) {
baseImage.ifPresent(b -> {
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getJarEnvVar(), pathToJar, null));
envProducer.produce(
KubernetesEnvBuildItem.createSimpleVar(b.getJarLibEnvVar(), concatUnixPaths(jarDirectory, "lib"),
null));
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getClasspathEnvVar(), classpath, null));
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getJvmOptionsEnvVar(),
String.join(" ", config.jvmArguments), null));
});

if (!baseImage.isPresent()) {
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar("JAVA_APP_JAR", pathToJar, null));
envProducer.produce(
KubernetesEnvBuildItem.createSimpleVar("JAVA_LIB_DIR", concatUnixPaths(jarDirectory, "lib"), null));
commandProducer.produce(new KubernetesCommandBuildItem("java", args.toArray(new String[args.size()])));
}
}
}

Expand Down Expand Up @@ -184,22 +187,23 @@ public void openshiftRequirementsNative(OpenshiftConfig openshiftConfig,
nativeBinaryFileName = config.nativeBinaryFileName.orElse(outputNativeBinaryFileName);
}

String pathToNativeBinary = concatUnixPaths(config.nativeBinaryDirectory, nativeBinaryFileName);

builderImageProducer.produce(new BaseImageInfoBuildItem(config.baseNativeImage));
Optional<OpenshiftBaseNativeImage> baseImage = OpenshiftBaseNativeImage.findMatching(config.baseNativeImage);
baseImage.ifPresent(b -> {
envProducer.produce(
KubernetesEnvBuildItem.createSimpleVar(b.getHomeDirEnvVar(), config.nativeBinaryDirectory,
OPENSHIFT));
envProducer.produce(
KubernetesEnvBuildItem.createSimpleVar(b.getOptsEnvVar(), String.join(" ", config.nativeArguments),
OPENSHIFT));
});

if (!baseImage.isPresent()) {
commandProducer.produce(new KubernetesCommandBuildItem(pathToNativeBinary,
config.nativeArguments.toArray(new String[config.nativeArguments.size()])));
if (config.buildStrategy != BuildStrategy.DOCKER) {
String pathToNativeBinary = concatUnixPaths(config.nativeBinaryDirectory, nativeBinaryFileName);
builderImageProducer.produce(new BaseImageInfoBuildItem(config.baseNativeImage));
Optional<OpenshiftBaseNativeImage> baseImage = OpenshiftBaseNativeImage.findMatching(config.baseNativeImage);
baseImage.ifPresent(b -> {
envProducer.produce(
KubernetesEnvBuildItem.createSimpleVar(b.getHomeDirEnvVar(), config.nativeBinaryDirectory,
OPENSHIFT));
envProducer.produce(
KubernetesEnvBuildItem.createSimpleVar(b.getOptsEnvVar(), String.join(" ", config.nativeArguments),
OPENSHIFT));
});

if (!baseImage.isPresent()) {
commandProducer.produce(new KubernetesCommandBuildItem(pathToNativeBinary,
config.nativeArguments.toArray(new String[config.nativeArguments.size()])));
}
}
}

Expand Down Expand Up @@ -282,7 +286,7 @@ public void openshiftBuildFromNative(OpenshiftConfig openshiftConfig, S2iConfig
return;
}

createContainerImage(kubernetesClient, openshiftYml.get(), config, null, out.getOutputDirectory(),
createContainerImage(kubernetesClient, openshiftYml.get(), config, "target", out.getOutputDirectory(),
nativeImage.getPath());
artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Collections.emptyMap()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.openshift.api.model.BuildConfig;
import io.fabric8.openshift.api.model.DeploymentConfig;
import io.quarkus.bootstrap.model.AppArtifact;
import io.quarkus.builder.Version;
import io.quarkus.test.ProdBuildResults;
Expand Down Expand Up @@ -41,6 +42,16 @@ public void assertGeneratedResources() throws IOException {
.isDirectoryContaining(p -> p.getFileName().endsWith("openshift.yml"));
List<HasMetadata> openshiftList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("openshift.yml"));

//Assert that the container contains neither command nor arguments
assertThat(openshiftList).filteredOn(d -> "DeploymentConfig".equals(d.getKind())).singleElement().satisfies(d -> {
assertThat(d).isInstanceOfSatisfying(DeploymentConfig.class, dc -> {
assertThat(dc.getSpec().getTemplate().getSpec().getContainers()).singleElement().satisfies(c -> {
assertThat(c.getCommand()).isNullOrEmpty();
assertThat(c.getArgs()).isNullOrEmpty();
});
});
});

assertThat(openshiftList).filteredOn(h -> "BuildConfig".equals(h.getKind())).singleElement().satisfies(h -> {
assertThat(h.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("openshift-s2i");
Expand All @@ -52,5 +63,6 @@ public void assertGeneratedResources() throws IOException {
});
});
});

}
}

0 comments on commit dcc59d0

Please sign in to comment.