buildpacks / samples

Samples for Cloud Native Buildpacks
Apache License 2.0
194 stars 145 forks source link

Java sample application failed to start #180

Closed jjbustamante closed 8 months ago

jjbustamante commented 9 months ago

Checking the latest execution of the CI workflows in CircleCI I noticed the sample java app is not starting. see here

Screenshot 2023-12-01 at 3 17 36 PM

I tried t o reproduced the error with the following steps:

  1. I built the application image using latest pack version 0.32.1
> pack build -B cnbs/sample-builder:jammy -p apps/java-maven circleci-sample
// log messages 
Successfully built image circleci-sample
  1. I tried to run application using the same docker command we are running on CircleCI
> docker run -d -p 8080:8080 circleci-sample
5d7aedf1fb00652e9a9ee4ff78050fe061d0100b7ad5580714b485c97b14213d
  1. The container is not running, so I checked the logs
    > docker ps
    CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
    >  docker logs 5d7aedf1fb00652e9a9ee4ff78050fe061d0100b7ad5580714b485c97b14213d
    ERROR: failed to launch: exec.d: failed to execute exec.d file at path '/layers/samples_java-maven/jdk/exec.d/jdk.sh': fork/exec /layers/samples_java-maven/jdk/exec.d/jdk.sh: exec format error

If I am not wrong the error fork/exec /layers/samples_java-maven/jdk/exec.d/jdk.sh: exec format error is thrown because the binary is not compatible with the host architecture.

AidanDelaney commented 8 months ago

I think we're using the wrong approach to set launch-time env vars. Rather than providing a jdk.sh file to run as an exec.d file, we should be writing the env vars to the env dir. The proposed change uses https://github.com/buildpacks/spec/blob/main/buildpack.md#environment-variable-modification-rules

Something like https://github.com/buildpacks/samples/pull/181 might work. We will also have to do the same in the kotlin-gradle example.

AidanDelaney commented 8 months ago

Fixed :)