Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certain Native image artifacts are not copied to run image #308

Closed
tabiStein opened this issue Jan 30, 2024 · 42 comments · Fixed by #329
Closed

Certain Native image artifacts are not copied to run image #308

tabiStein opened this issue Jan 30, 2024 · 42 comments · Fixed by #329
Labels
type:enhancement A general enhancement

Comments

@tabiStein
Copy link

tabiStein commented Jan 30, 2024

I am using the builder-jammy-base buildpack with the spring-boot-maven-plugin to build a native image. After some troubleshooting with the Graal team (oracle/graal#8273) it seems that certain required artifacts (jdk_library and jdk_liberary_shim .so files) are not being included in the workspace/ directory of containers using the run image generated by this buildpack. We do see them listed as "produced artifacts" in the build log, however.

Expected Behavior

The following .so files (in bold) from the log snippet below should be included in the workspace/ directory alongside the native image executable (org.example.App):

INFO] [creator] Produced artifacts:
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libawt.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libawt_headless.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libawt_xawt.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libfontmanager.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libfreetype.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libjava.so (jdk_library_shim)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libjavajpeg.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libjvm.so (jdk_library_shim)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/liblcms.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/org.example.App (executable)

Current Behavior

The files are not included, the directory in the run container only contains the native executable:
image

Steps to Reproduce

Repro:

  1. Please check out the following project for a small, single-class repro of this error: reproduce-awt-lib-error-graal
  2. Run mvn clean install in the root directory of the project to build the jar
  3. Run mvn -Pnative package to build the native image, called test/repro-awt-lib-error
  4. Read the log output and verify that the jdk library artifacts were produced. Attached is a copy of mine for your convenience:
    packageOutput.txt
  5. Run docker run test/repro-awt-lib-error
  6. The run fails because the libawt.so file is not in the same directory as the image executable (according to the Graal team: UnsatisfiedLinkError: No awt in java.library.path oracle/graal#8273 (comment))

Environment:
GraalVM version 23.0.2 (as determined by buildpack)
JDK major version: 17
OS: MacOS Sonoma 14.2.1
Architecture: 6-Core Intel Core i9
Maven version: 3.9.6
Docker version: 24.0.7

Motivations

My company is trying to convert one of our microservices to a native executable, using your buildpack. The service uses the Apache PDDocument class, which relies on the Java awt library. Since the library is not available to the native image at runtime, the executable crashes.

@fniephaus
Copy link

Native Image also provides an experimental option -H:+GenerateBuildArtifactsFile which will generate a JSON validating against this schema and includes a categorized list of all artifacts. Any jdk_libraries should definitely ship with a native executable. Feel free to provide us with feedback so that we can eventually provide a stable option for this infrastructure.

@tabiStein
Copy link
Author

Native Image also provides an experimental option -H:+GenerateBuildArtifactsFile which will generate a JSON validating against this schema and includes a categorized list of all artifacts. Any jdk_libraries should definitely ship with a native executable. Feel free to provide us with feedback so that we can eventually provide a stable option for this infrastructure.

@fniephaus Brief clarification -- are you suggesting adding this parameter will fix the issue I'm experiencing?

@saugion
Copy link

saugion commented Jan 31, 2024

For me this does not solve the issue

java.lang.UnsatisfiedLinkError: No awt in java.library.path
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:136) ~[na:na]

I'm using paketobuildpacks/builder-jammy-tiny:latest with the gradle bootBuildImage task, and the libraries that use awt are com.google.zxing:javase and com.google.zxing:core

I'm passing the args
"BP_NATIVE_IMAGE_BUILD_ARGUMENTS": "--initialize-at-build-time=com.google.zxing.common.StringUtils -H:+UnlockExperimentalVMOptions -H:+GenerateBuildArtifactsFile"

@dmikusa dmikusa transferred this issue from paketo-buildpacks/builder-jammy-base Feb 11, 2024
@dmikusa
Copy link
Contributor

dmikusa commented Feb 11, 2024

Sorry for the delay, just saw this issue as it was opened originally under a repo that the Java team does not monitor. We'll need to look into this more.

Off-hand, I wasn't aware that this could happen. I thought that the produced native image binary would include everything it needs to run minus glibc and libz.

@fniephaus Do you have a doc link on how this works in GraalVM? Are there certain build flags that will result in this build output? I just want to brush up on it and make sure I understand how this all works before we make changes in the buildpack. Thanks

@fniephaus
Copy link

@tabiStein

Brief clarification -- are you suggesting adding this parameter will fix the issue I'm experiencing?

Not really. I just wanted to point out that there is -H:+GenerateBuildArtifactsFile, which allows generating a description of what Native Image has spit out as part of the build.


@dmikusa

Do you have a doc link on how this works in GraalVM?

I'm not 100% sure this really is documented (need to double check), but it can certainly be the case that Native Image outputs more than just a binary.

Are there certain build flags that will result in this build output?

This behavior does not necessarily depend on certain flags, it depends on the app fed into Native Image. If the static analysis finds certain JDK libraries reachable, it will output them together with the executable. A good example is any app that somehow uses AWT (like the one from @tabiStein). AWT is dynamically linked against the shared libs of the JDK and some shims that Native Image produces for libjava and libjvm. For more info on this, take a look at oracle/graal#4921.

A simple way to deal with this is to extend the buildpack infra that copies the native executable to also copy any additional .so files found next to it.

@dmikusa dmikusa added the type:enhancement A general enhancement label Feb 19, 2024
@fniephaus
Copy link

I've added documentation for this, see here: https://github.com/oracle/graal/pull/8424/files#diff-9e46ede5ec9729b1cf39fdd6ad204bf093e84441d2ff5419fb20cca77b7070b2R344

@0xyk3r
Copy link

0xyk3r commented Apr 17, 2024

The same problem happened to me, my project uses ImageIO in awt.

My temporary solution is to use the nativeCompile command(I use Gradle) to build once in any Linux with GraalVM environment, and then copy the generated *.so artifact to the created docker image.

This will work fine. But I think this is just a temporary solution and hope the problem can be solved soon.

@mpalourdio
Copy link

mpalourdio commented May 17, 2024

Hi !

Just been it by this. You can easily reproduce by cloning this repo, and run mvn clean -Pnative spring-boot:build-image

[INFO]     [creator]     Produced artifacts:
[INFO]     [creator]      /layers/paketo-buildpacks_native-image/native-image/com.mpalourdio.projects.flhacker.FlhackerApplicationKt (executable)
[INFO]     [creator]      /layers/paketo-buildpacks_native-image/native-image/libawt.so (jdk_library)
[INFO]     [creator]      /layers/paketo-buildpacks_native-image/native-image/libawt_headless.so (jdk_library)
[INFO]     [creator]      /layers/paketo-buildpacks_native-image/native-image/libawt_xawt.so (jdk_library)
[INFO]     [creator]      /layers/paketo-buildpacks_native-image/native-image/libfontmanager.so (jdk_library)
[INFO]     [creator]      /layers/paketo-buildpacks_native-image/native-image/libfreetype.so (jdk_library)
[INFO]     [creator]      /layers/paketo-buildpacks_native-image/native-image/libjava.so (jdk_library_shim)
[INFO]     [creator]      /layers/paketo-buildpacks_native-image/native-image/libjavajpeg.so (jdk_library)
[INFO]     [creator]      /layers/paketo-buildpacks_native-image/native-image/libjvm.so (jdk_library_shim)
[INFO]     [creator]      /layers/paketo-buildpacks_native-image/native-image/liblcms.so (jdk_library)
[INFO]     [creator]     ================================================================================
[INFO]     [creator]     Finished generating 'com.mpalourdio.projects.flhacker.FlhackerApplicationKt' in 2m 14s.
[INFO]     [creator]       Removing bytecode
[INFO]     [creator]       Process types:
[INFO]     [creator]         native-image: ./com.mpalourdio.projects.flhacker.FlhackerApplicationKt (direct)
[INFO]     [creator]         task:         ./com.mpalourdio.projects.flhacker.FlhackerApplicationKt (direct)
[INFO]     [creator]         web:          ./com.mpalourdio.projects.flhacker.FlhackerApplicationKt (direct)

@mpalourdio
Copy link

mpalourdio commented May 17, 2024

Maybe out of topic, but I have thought of working around this by trying to go away from mostly static image by adding :

<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--static --libc=musl</BP_NATIVE_IMAGE_BUILD_ARGUMENTS> as I do it at spring-boot-maven-plugin level, but it looks like this kind of build is not supported (yet ?). Could be nice as containers may not depend on the libc version of the host, which is IMO a pain point in containerization / orchestration where you should theoretically not have a clue of what the host has.

But it also seems that those arguments append to the existing one
Executing native-image --no-fallback -H:+StaticExecutableWithDynamicLibC --static --libc=musl [...]
=> (-H:+StaticExecutableWithDynamicLibC should not been here in this case)

Anyway, musl is neither present, nor configured

[creator]     [1/8] Initializing...                                            (0.0s @ 0.09GB)
[INFO]     [creator]     Error: Default native-compiler executable 'x86_64-linux-musl-gcc' not found via environment variable PATH
[INFO]     [creator]     Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain

This works mostly locally here even if I think I have been hit by a (maybe) bug : oracle/graal#8911

Happy to help testing things if needed!

Documentation for reference : https://www.graalvm.org/22.0/reference-manual/native-image/StaticImages/#preparation

@saugion
Copy link

saugion commented May 17, 2024

I had to switch to Quarkus to make it work, with Graal's mandrel version

@fniephaus
Copy link

@dmikusa any way you could take a look how this can be fixed? Copying any additional *.so files may be the easiest way, but you could also generate the artifact list.
The last time I tried Quarkus with buildpacks, it was mixing up a lot of things and actually used NIK, even though I tried to use Oracle GraalVM.

@mpalourdio
Copy link

mpalourdio commented May 25, 2024

@dmikusa any way you could take a look how this can be fixed? Copying any additional *.so files may be the easiest way

Yes, that's an easy way to do it, just copying all the .so files next to executable is just fine. If this could be fixed that would be awesome, because it blocks a lot of apps IMO (awt is pretty common in transitive libs for example).

@khauser
Copy link

khauser commented May 27, 2024

The same problem happened to me, my project uses ImageIO in awt.

My temporary solution is to use the nativeCompile command(I use Gradle) to build once in any Linux with GraalVM environment, and then copy the generated *.so artifact to the created docker image.

This will work fine. But I think this is just a temporary solution and hope the problem can be solved soon.

@0xyk3r: How would I do that?
I run ./gradlew nativeCompile on my WSL2 in Windows and I see the generated files under build/native/nativeCompile.
With ./gradlew bootBuildImage the image is generated. But now Im stuck.

@0xyk3r
Copy link

0xyk3r commented May 27, 2024

The same problem happened to me, my project uses ImageIO in awt.
My temporary solution is to use the nativeCompile command(I use Gradle) to build once in any Linux with GraalVM environment, and then copy the generated *.so artifact to the created docker image.
This will work fine. But I think this is just a temporary solution and hope the problem can be solved soon.

@0xyk3r: How would I do that? I run ./gradlew nativeCompile on my WSL2 in Windows and I see the generated files under build/native/nativeCompile. With ./gradlew bootBuildImage the image is generated. But now Im stuck.

@khauser You need to copy all the .so files from the directory build/native/nativeCompile into the docker image built with the bootBuildImage command.
You can use the docker cp command to copy the files to this generated image, or any other way you like.

@khauser
Copy link

khauser commented May 27, 2024

@0xyk3r Thanks! Do you know which folder to copy it to. From docker inspect I see "Entrypoint": ["/cnb/process/web"]. Would then be /cnb/process/ or is this the root folder?

@0xyk3r
Copy link

0xyk3r commented May 27, 2024

@0xyk3r Thanks! Do you know which folder to copy it to. From docker inspect I see "Entrypoint": ["/cnb/process/web"]. Would then be /cnb/process/ or is this the root folder?

@khauser /workspace You can see your executable binary here, copy the .so file here.

@khauser
Copy link

khauser commented May 27, 2024

Nice one @0xyk3r !

 for file in ./build/native/nativeCompile/*.so; do
  docker cp "$file" mycontainer:/workspace
 done
docker commit containerid mytestimagetag

And now I have a working image!

@mpalourdio
Copy link

mpalourdio commented Jul 10, 2024

@dmikusa Hi, I hate being that guy, but is there an opportunity that this could be looked at ?

@dmikusa
Copy link
Contributor

dmikusa commented Jul 10, 2024

Sorry, I do have this on my list, but there's just a lot of stuff going on and only a finite amount of time to work on things.

Including @paketo-buildpacks/java-maintainers for a wider audience, maybe one of them can jump in faster than me.

@dmikusa
Copy link
Contributor

dmikusa commented Jul 13, 2024

@fniephaus Follow up question for you. How does the native image binary locate the shared libraries?

I've been doing some testing and copying the "*.so" files to be in /workspace with the binary is easy. I've done that, but I still get a JNI error and failure (full output attached).

Fatal error reported via JNI: Could not allocate library name

Files all in /workspace.

Screenshot 2024-07-13 at 10 05 16 AM

When it runs, it'll execute /workspace/com.example.demo.DemoApplication

I've tried setting LD_LIBRARY_PATH like I'd typically do to have a binary locate shared libraries, but it doesn't seem to have an impact.

test.log

@fniephaus
Copy link

How does the native image binary locate the shared libraries?

The additional libs are supposed to stay in the same directory with the native executable. The lookup can be adjusted, for example via LD_LIBRARY_PATH, but that's not necessary by default.

The problem you are running into is in fact unrelated. Just because the shared libs are in the right location does not mean things will just work unfortunately. AWT heavily uses JNI, which requires registrations. To make that work, you need to run the tracing agent on the app, as hopefully mentioned in the recommendation section of your Native Image build.

Hope this helps!

@dmikusa
Copy link
Contributor

dmikusa commented Jul 13, 2024

Ah ha, ok. I was so focused on where they should be I missed that. Perfect! I'm making progress then, I'll keep plugging away at it, thanks!

@dmikusa
Copy link
Contributor

dmikusa commented Jul 14, 2024

I'm still stuck on the Fatal error reported via JNI: Could not allocate library name error with my test app, but if I understand things correctly that's just me and my test app.

I think the buildpack is doing the right things now. I've published a testing image to https://hub.docker.com/r/dmikusa/paketo-native-image/tags.

If you use the following buildpack/builder arguments with pack build, you can try it out...

pack build -b docker.io/paketobuildpacks/oracle -b docker.io/paketobuildpacks/ca-certificates -b docker.io/paketobuildpacks/syft -b docker.io/paketobuildpacks/executable-jar -b docker.io/paketobuildpacks/spring-boot -b docker.io/paketo-buildpacks/native-image -B paketobuildpacks/builder-jammy-buildpackless-tiny -e BP_NATIVE_IMAGE=true ...

For me, this builds and the image now has /workspace filled with the binary and any *.so files that were output by native-image. If folks could test and let me know if that helps, then I can get a PR up and merged so we can release this properly.

Thanks

@dmikusa
Copy link
Contributor

dmikusa commented Jul 14, 2024

I ended up getting the native-image build to work on a Linux VM. There was a slight difference when I ran the trace agent on the Linux VM, and after that, the built binary ran OK.

I tried building with buildpacks using that same configuration (JVM/native-image vendor+version, code commit), but it still didn't work. In the buildpacks produced app image, I still get the JNI failure. Interested to see if it works for other folks or if there maybe something else we need to do with the buildpack build here.

@mpalourdio
Copy link

mpalourdio commented Jul 14, 2024

Many thanks for giving this a try. I have changed my maven configuration like this, as I understand the spring-boot-maven-plugin documentation

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <image>
            <runImage>dmikusa/paketo-native-image:latest</runImage>
            <env>
                <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
            </env>
        </image>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>build-image-no-fork</goal>
            </goals>
        </execution>
    </executions>
</plugin>

I can see that it's indeed used

[INFO]  > Pulling builder image 'docker.io/paketobuildpacks/builder-jammy-tiny:latest' 100%
[INFO]  > Pulled builder image 'paketobuildpacks/builder-jammy-tiny@sha256:213a7122c90d4351584796c956c4213fc2e0b3e56e3a12bb2ecb015a0ae67422'
[INFO]  > Pulling run image 'docker.io/dmikusa/paketo-native-image:latest' 100%
[INFO]  > Pulled run image 'dmikusa/paketo-native-image@sha256:770a6fa0cc92a8124c7701f4d5c2d9d06d1d9c74d977aa1776059ea95d87f2ee'
[INFO]  > Executing lifecycle version v0.19.7
[INFO]  > Using build cache volume 'pack-cache-53f05ead5a31.build'

But a docker run leads to ERROR: failed to launch: direct exec: no such file or directory. I might do something wrong

@dmikusa
Copy link
Contributor

dmikusa commented Jul 14, 2024

Try this:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <image>
            <builder>paketobuildpacks/builder-jammy-buildpackless-tiny</builder>
            <buildpacks>
                <buildpack>docker.io/paketobuildpacks/oracle</buildpack>
                <buildpack>docker.io/paketobuildpacks/ca-certificates</buildpack>
                <buildpack>docker.io/paketobuildpacks/syft</buildpack>
                <buildpack>docker.io/paketobuildpacks/executable-jar</buildpack>
                <buildpack>docker.io/paketobuildpacks/spring-boot</buildpack>
                <buildpack>docker.io/dmikusa/paketo-native-image</buildpack>
            <env>
                <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
            </env>
        </image>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>build-image-no-fork</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The image I made is a buildpack image, not a runtime image.

@mpalourdio
Copy link

mpalourdio commented Jul 14, 2024

Oops ! Sorry for confusion.

I have tried your maven configuration, here is the error during the maven build process

[INFO] Building image 'docker.io/library/flhacker:0.0.1-SNAPSHOT'
[INFO] 
[INFO]  > Pulling builder image 'docker.io/paketobuildpacks/builder-jammy-buildpackless-tiny:latest' 100%
[INFO]  > Pulled builder image 'paketobuildpacks/builder-jammy-buildpackless-tiny@sha256:98a3c52134815d3745dde5e7626cb919739fe7f757443678f967c3246c9f45f0'
[INFO]  > Pulling run image 'docker.io/paketobuildpacks/run-jammy-tiny:latest' 100%
[INFO]  > Pulled run image 'paketobuildpacks/run-jammy-tiny@sha256:703d6c7b862e3056afd1e4dc29b59039082da337d9d862137186049e2a36e3ee'
[INFO]  > Pulling buildpack image 'docker.io/paketobuildpacks/oracle:latest' 100%
[INFO]  > Pulled buildpack image 'paketobuildpacks/oracle@sha256:5efc87d386bd5c57137cdf33ae1349236752f1311840d9ccd8a76b56c4cb2fb1'
[INFO]  > Pulling buildpack image 'docker.io/paketobuildpacks/ca-certificates:latest' 100%
[INFO]  > Pulled buildpack image 'paketobuildpacks/ca-certificates@sha256:5d3e8eb9c1dcb199e3143f26e64d06823af41ff3247fb95e00f8aea30d0efc47'
[INFO]  > Pulling buildpack image 'docker.io/paketobuildpacks/syft:latest' 100%
[INFO]  > Pulled buildpack image 'paketobuildpacks/syft@sha256:fe21acdc764f8b99219597e1ba6d81431c04cd33ad8cd7edc376ec663c1001b2'
[INFO]  > Pulling buildpack image 'docker.io/paketobuildpacks/executable-jar:latest' 100%
[INFO]  > Pulled buildpack image 'paketobuildpacks/executable-jar@sha256:43e68b6cc3d004812d4125fd7bd5189a24d9bb0df8e7e2a2e1980a57964f7144'
[INFO]  > Pulling buildpack image 'docker.io/paketobuildpacks/spring-boot:latest' 100%
[INFO]  > Pulled buildpack image 'paketobuildpacks/spring-boot@sha256:1549798611b894c9881581e5bf4e3b3f773fd72ff21c83fab787e5d80daf9fa5'
[INFO]  > Pulling buildpack image 'docker.io/paketo-buildpacks/native-image:latest' 100%
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  21.884 s
[INFO] Finished at: 2024-07-14T22:23:35+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.3.1:build-image-no-fork (default) on project flhacker: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.3.1:build-image-no-fork failed: Invalid buildpack reference 'docker.io/paketo-buildpacks/native-image' -> [Help 1]

Looks like as standard configuration, the plugin uses
<builder>paketobuildpacks/builder-jammy-tiny:latest</builder>

But even with this, the error remains the same as above.

Thanks again !

EDIT : forget this, there was a typo, ie paketo-buildpacks vs paketobuildpacks

@mpalourdio
Copy link

mpalourdio commented Jul 14, 2024

So this still fails for me with

Caused by: java.lang.UnsatisfiedLinkError: No awt in java.library.path at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:136)

But :

  • I see that the native image options enforce +StaticExecutableWithDynamicLibC. Which has never worked, at least for me. Bug open here. Do you know why this option is enforced ? I suppose this gives flexibility over glibc versions. Once again, I have never succeeded to make this option work :/ Poke @fniephaus
  • I can't, for the life of me, run bash to check inside the container if the .so are there. Noob error I suppose.
docker run -it --rm --entrypoint=/bin/bash flhacker:0.0.1-SNAPSHOT 
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/bin/bash": stat bin/bash: no such file or directory: unknown.

I have made a branch here if you want to give it a shot.

@dmikusa
Copy link
Contributor

dmikusa commented Jul 14, 2024

@mpalourdio Sorry about that. I had the wrong thing in there for native image, I just changed the comment above so it should be correct now.

@dmikusa
Copy link
Contributor

dmikusa commented Jul 14, 2024

I can't, for the life of me, run bash to check inside the container if the .so are there. Noob error I suppose.

You can run dive <app-image> on your app image and you can inspect the layers. There is a layer for the application data.

@mpalourdio
Copy link

I can't, for the life of me, run bash to check inside the container if the .so are there. Noob error I suppose.

You can run dive <app-image> on your app image and you can inspect the layers. There is a layer for the application data.

I was not aware of this tool. So there is no way to override the entrypoint with docker run ?

@dmikusa
Copy link
Contributor

dmikusa commented Jul 14, 2024

I was not aware of this tool. So there is no way to override the entrypoint with docker run ?

If you use the tiny image, it's painful because there is no shell or shell commands to run. You can always override the --entrypoint when you docker run, but there's just not much to actually execute in the tiny run image.

If you use the base Paketo image, then you can switch the entry point to bash and do that.

I used tiny in the example because it works on my M1 MBP. If you've got a amd64 system, you could use base easily. If you're on an M-series MBP like me then base will be a pain because it'll use amd64 emulation and take a really long time to build, if it ever finishes.

@mpalourdio
Copy link

mpalourdio commented Jul 14, 2024

@mpalourdio Sorry about that. I had the wrong thing in there for native image, I just changed the comment above so it should be correct now.

Wow, it just works now. Many thanks !!!!! And thanks for your patience !

@mpalourdio
Copy link

base Paketo image

Trying now with the base image. I'm on linux, amd64.

@dmikusa
Copy link
Contributor

dmikusa commented Jul 14, 2024

I was able to build your sample and run it.

> docker run flhacker:0.0.1-SNAPSHOT
Missing required option: f
usage: Specify the file path like below
 -f,--file <arg>   The audio file path which contains the artwork to print
No Reader associated with this extension:

I tried it with an audio file and got:

> docker run -v $PWD:/workspace/audio flhacker:0.0.1-SNAPSHOT -f /workspace/audio/Symphony\ No.6\ \(1st\ movement\).flac
null

Not sure if that's expected, but it didn't crash.

@mpalourdio
Copy link

mpalourdio commented Jul 14, 2024

Mhh, the null might be an edge case, but not a fail related to this topic, just a bug of mine ahaha.
Does the flac embed a artwork ? Mind sharing it ? I am curious.

Also, i have just tried the base image, all good for the entrypoint override :

$ docker run -it --rm --entrypoint=/bin/bash flhacker:0.0.1-SNAPSHOT 
cnb@5f1d10b24a74:/workspace$ ls -alF
total 81164
drwxr-xr-x 2 1001 cnb      4096 Jan  1  1980 ./
drwxr-xr-x 1 root root     4096 Jul 14 21:40 ../
-rwxr-xr-x 1 1001 cnb  78068928 Jan  1  1980 com.mpalourdio.projects.flhacker.FlhackerApplicationKt*
-rw-r--r-- 1 1001 cnb    809536 Jan  1  1980 libawt.so
-rw-r--r-- 1 1001 cnb     38488 Jan  1  1980 libawt_headless.so
-rw-r--r-- 1 1001 cnb    575400 Jan  1  1980 libawt_xawt.so
-rw-r--r-- 1 1001 cnb   2737336 Jan  1  1980 libfontmanager.so
-rwxr-xr-x 1 1001 cnb     14976 Jan  1  1980 libjava.so*
-rw-r--r-- 1 1001 cnb    239976 Jan  1  1980 libjavajpeg.so
-rwxr-xr-x 1 1001 cnb     14976 Jan  1  1980 libjvm.so*
-rw-r--r-- 1 1001 cnb    588888 Jan  1  1980 liblcms.so

@dmikusa
Copy link
Contributor

dmikusa commented Jul 14, 2024

@mpalourdio
Copy link

Indeed, this file does not contain any embedded artwork. But the "null" is not very graceful.

End of out-of-topic. All works here, and many thanks again for your awesome work and availability!

@dmikusa
Copy link
Contributor

dmikusa commented Jul 14, 2024

Ok, great. I pushed up a PR, I'll try to wrangle someone to review that this week & hopefully get things published. I'll keep this open until we've got the fix released.

@dmikusa
Copy link
Contributor

dmikusa commented Jul 15, 2024

Version 5.14.2 has the fix that I made.

@mpalourdio you can use that by changing <buildpack>docker.io/dmikusa/paketo-native-image</buildpack> to <buildpack>docker.io/paketobuildpacks/native-image</buildpack> in your pom.xml.

This should get picked up into the next release, which is tentatively scheduled for Friday so after Friday you can remove all the custom buildpack configuration, i.e. <buildpacks>...</buildpacks> block. The builder will have updated buildpacks by default.

@mpalourdio
Copy link

@dmikusa I can confirm that docker.io/paketobuildpacks/native-image works as expected !

Many thanks, and I will wait next week for the next release.

@mpalourdio
Copy link

Back from holidays. I can confirm all works as expected with the default spring-boot-maven-plugin configuration now! Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants