Skip to content

Unable to build a native image with a custom application directory #366

Open
@stefferro

Description

@stefferro

Hi,

I am working on a spring boot project with maven and try to build a native image. The spring boot maven plugin uses buildpacks to generate its OCI images, that the reason why I am raising the issue here.
The build process ends fine and the native image works as expected. But when I specify a different application directory (the spring boot maven plugin has this option), the build process fails at the very end.

Expected Behavior

Changing the application directory should not make the build process failing.

Current Behavior

Changing the application directory makes the build process failing with the following message

[INFO]     [creator]     Finished generating 'com.example.demo.DemoApplication' in 1m 48s.
[INFO]     [creator]       Removing bytecode
[INFO]     [creator]     unable to invoke layer creator
[INFO]     [creator]     unable to remove /myapp/BOOT-INF
[INFO]     [creator]     unlinkat /myapp/BOOT-INF: permission denied
[INFO]     [creator]     ERROR: failed to build: exit status 1

Steps to Reproduce

  • Generate a spring boot project using Spring Initializr; You can use this link
  • Modify the spring-boot-maven-plugin configuration from the pom.xml file as below. It specifies an application directory other than /workspace and enables the native build.
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
	    <image>
	        <applicationDirectory>/myapp</applicationDirectory>
		<env>
		    <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
		</env>
	    </image>
	</configuration>
</plugin>
  • Run the maven command to generate the image
./mvnw spring-boot:build-image -Pnative

Motivations

Since we have packaged our applications into docker images, we store the binaries at a specific location. We would like to deploy our native images using the same binary location.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions