use of io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem in project quarkus by quarkusio.
the class AugmentActionImpl method createProductionApplication.
@Override
public AugmentResult createProductionApplication() {
if (launchMode != LaunchMode.NORMAL) {
throw new IllegalStateException("Can only create a production application when using NORMAL launch mode");
}
ClassLoader classLoader = curatedApplication.createDeploymentClassLoader();
BuildResult result = runAugment(true, Collections.emptySet(), null, classLoader, ArtifactResultBuildItem.class, DeploymentResultBuildItem.class);
writeDebugSourceFile(result);
JarBuildItem jarBuildItem = result.consumeOptional(JarBuildItem.class);
NativeImageBuildItem nativeImageBuildItem = result.consumeOptional(NativeImageBuildItem.class);
List<ArtifactResultBuildItem> artifactResultBuildItems = result.consumeMulti(ArtifactResultBuildItem.class);
BuildSystemTargetBuildItem buildSystemTargetBuildItem = result.consume(BuildSystemTargetBuildItem.class);
// this depends on the fact that the order in which we can obtain MultiBuildItems is the same as they are produced
// we want to write result of the final artifact created
ArtifactResultBuildItem lastResult = artifactResultBuildItems.get(artifactResultBuildItems.size() - 1);
writeArtifactResultMetadataFile(buildSystemTargetBuildItem, lastResult);
return new AugmentResult(artifactResultBuildItems.stream().map(a -> new ArtifactResult(a.getPath(), a.getType(), a.getMetadata())).collect(Collectors.toList()), jarBuildItem != null ? jarBuildItem.toJarResult() : null, nativeImageBuildItem != null ? nativeImageBuildItem.getPath() : null);
}
use of io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem in project quarkus by quarkusio.
the class S2iProcessor method s2iBuildFromNative.
@BuildStep(onlyIf = { IsNormalNotRemoteDev.class, S2iBuild.class, NativeBuild.class })
public void s2iBuildFromNative(S2iConfig s2iConfig, ContainerImageConfig containerImageConfig, KubernetesClientBuildItem kubernetesClient, ContainerImageInfoBuildItem containerImage, ArchiveRootBuildItem archiveRoot, OutputTargetBuildItem out, PackageConfig packageConfig, List<GeneratedFileSystemResourceBuildItem> generatedResources, Optional<ContainerImageBuildRequestBuildItem> buildRequest, Optional<ContainerImagePushRequestBuildItem> pushRequest, BuildProducer<ArtifactResultBuildItem> artifactResultProducer, BuildProducer<ContainerImageBuilderBuildItem> containerImageBuilder, NativeImageBuildItem nativeImage) {
if (containerImageConfig.isBuildExplicitlyDisabled()) {
return;
}
if (!containerImageConfig.isBuildExplicitlyEnabled() && !containerImageConfig.isPushExplicitlyEnabled() && !buildRequest.isPresent() && !pushRequest.isPresent()) {
return;
}
String namespace = Optional.ofNullable(kubernetesClient.getClient().getNamespace()).orElse("default");
LOG.info("Performing s2i binary build with native image on server: " + kubernetesClient.getClient().getMasterUrl() + " in namespace:" + namespace + ".");
Optional<GeneratedFileSystemResourceBuildItem> openshiftYml = generatedResources.stream().filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml")).findFirst();
if (openshiftYml.isEmpty()) {
LOG.warn("No Openshift manifests were generated so no s2i process will be taking place");
return;
}
createContainerImage(kubernetesClient, openshiftYml.get(), s2iConfig, out.getOutputDirectory(), nativeImage.getPath());
artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Collections.emptyMap()));
containerImageBuilder.produce(new ContainerImageBuilderBuildItem(S2I));
}
use of io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem in project quarkus by quarkusio.
the class JibProcessor method buildFromNative.
@BuildStep(onlyIf = { IsNormalNotRemoteDev.class, JibBuild.class, NativeBuild.class })
public void buildFromNative(ContainerImageConfig containerImageConfig, JibConfig jibConfig, ContainerImageInfoBuildItem containerImage, NativeImageBuildItem nativeImage, OutputTargetBuildItem outputTarget, Optional<ContainerImageBuildRequestBuildItem> buildRequest, Optional<ContainerImagePushRequestBuildItem> pushRequest, List<ContainerImageLabelBuildItem> containerImageLabels, // used to ensure that we work with the compressed native binary if compression was enabled
Optional<UpxCompressedBuildItem> upxCompressed, BuildProducer<ArtifactResultBuildItem> artifactResultProducer, BuildProducer<ContainerImageBuilderBuildItem> containerImageBuilder) {
boolean buildContainerImage = buildContainerImageNeeded(containerImageConfig, buildRequest);
boolean pushContainerImage = pushContainerImageNeeded(containerImageConfig, pushRequest);
if (!buildContainerImage && !pushContainerImage) {
return;
}
if (!NativeBinaryUtil.nativeIsLinuxBinary(nativeImage)) {
throw new RuntimeException("The native binary produced by the build is not a Linux binary and therefore cannot be used in a Linux container image. Consider adding \"quarkus.native.container-build=true\" to your configuration");
}
JibContainerBuilder jibContainerBuilder = createContainerBuilderFromNative(jibConfig, containerImageConfig, nativeImage, containerImageLabels);
setUser(jibConfig, jibContainerBuilder);
setPlatforms(jibConfig, jibContainerBuilder);
handleExtraFiles(outputTarget, jibContainerBuilder);
log.info("Starting (local) container image build for native binary using jib.");
JibContainer container = containerize(containerImageConfig, jibConfig, containerImage, jibContainerBuilder, pushRequest.isPresent());
writeOutputFiles(container, jibConfig, outputTarget);
artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Map.of("container-image", container.getTargetImage().toString(), "pull-required", "" + pushContainerImage)));
containerImageBuilder.produce(new ContainerImageBuilderBuildItem(JIB));
}
use of io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem in project quarkus by quarkusio.
the class JibProcessor method buildFromJar.
@BuildStep(onlyIf = { IsNormalNotRemoteDev.class, JibBuild.class }, onlyIfNot = NativeBuild.class)
public void buildFromJar(ContainerImageConfig containerImageConfig, JibConfig jibConfig, PackageConfig packageConfig, ContainerImageInfoBuildItem containerImage, JarBuildItem sourceJar, MainClassBuildItem mainClass, OutputTargetBuildItem outputTarget, CurateOutcomeBuildItem curateOutcome, CompiledJavaVersionBuildItem compiledJavaVersion, Optional<ContainerImageBuildRequestBuildItem> buildRequest, Optional<ContainerImagePushRequestBuildItem> pushRequest, List<ContainerImageLabelBuildItem> containerImageLabels, Optional<AppCDSResultBuildItem> appCDSResult, BuildProducer<ArtifactResultBuildItem> artifactResultProducer, BuildProducer<ContainerImageBuilderBuildItem> containerImageBuilder) {
boolean buildContainerImage = buildContainerImageNeeded(containerImageConfig, buildRequest);
boolean pushContainerImage = pushContainerImageNeeded(containerImageConfig, pushRequest);
if (!buildContainerImage && !pushContainerImage) {
return;
}
JibContainerBuilder jibContainerBuilder;
String packageType = packageConfig.type;
if (packageConfig.isLegacyJar() || packageType.equalsIgnoreCase(PackageConfig.UBER_JAR)) {
jibContainerBuilder = createContainerBuilderFromLegacyJar(determineBaseJvmImage(jibConfig, compiledJavaVersion), jibConfig, containerImageConfig, sourceJar, outputTarget, mainClass, containerImageLabels);
} else if (packageConfig.isFastJar()) {
jibContainerBuilder = createContainerBuilderFromFastJar(determineBaseJvmImage(jibConfig, compiledJavaVersion), jibConfig, containerImageConfig, sourceJar, curateOutcome, containerImageLabels, appCDSResult);
} else {
throw new IllegalArgumentException("Package type '" + packageType + "' is not supported by the container-image-jib extension");
}
setUser(jibConfig, jibContainerBuilder);
setPlatforms(jibConfig, jibContainerBuilder);
handleExtraFiles(outputTarget, jibContainerBuilder);
log.info("Starting (local) container image build for jar using jib.");
JibContainer container = containerize(containerImageConfig, jibConfig, containerImage, jibContainerBuilder, pushRequest.isPresent());
writeOutputFiles(container, jibConfig, outputTarget);
artifactResultProducer.produce(new ArtifactResultBuildItem(null, "jar-container", Map.of("container-image", container.getTargetImage().toString(), "pull-required", Boolean.toString(pushContainerImage))));
containerImageBuilder.produce(new ContainerImageBuilderBuildItem(JIB));
}
use of io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem in project quarkus by quarkusio.
the class BuildpackProcessor method buildFromNative.
@BuildStep(onlyIf = { IsNormalNotRemoteDev.class, BuildpackBuild.class, NativeBuild.class })
public void buildFromNative(ContainerImageConfig containerImageConfig, BuildpackConfig buildpackConfig, ContainerImageInfoBuildItem containerImage, NativeImageBuildItem nativeImage, OutputTargetBuildItem outputTarget, Optional<ContainerImageBuildRequestBuildItem> buildRequest, Optional<ContainerImagePushRequestBuildItem> pushRequest, List<ContainerImageLabelBuildItem> containerImageLabels, BuildProducer<ArtifactResultBuildItem> artifactResultProducer, BuildProducer<ContainerImageBuilderBuildItem> containerImageBuilder) {
if (containerImageConfig.isBuildExplicitlyDisabled()) {
return;
}
if (!containerImageConfig.isBuildExplicitlyEnabled() && !containerImageConfig.isPushExplicitlyEnabled() && !buildRequest.isPresent() && !pushRequest.isPresent()) {
return;
}
if (!NativeBinaryUtil.nativeIsLinuxBinary(nativeImage)) {
throw new RuntimeException("The native binary produced by the build is not a Linux binary and therefore cannot be used in a Linux container image. Consider adding \"quarkus.native.container-build=true\" to your configuration");
}
log.info("Starting (local) container image build for native binary using buildpack.");
String targetImageName = runBuildpackBuild(buildpackConfig, containerImage, containerImageConfig, pushRequest, outputTarget, true);
artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Collections.singletonMap("container-image", targetImageName)));
containerImageBuilder.produce(new ContainerImageBuilderBuildItem(BUILDPACK));
}
Aggregations