buildpacks / samples

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

Replace exec.d script with env dir #181

Closed AidanDelaney closed 8 months ago

AidanDelaney commented 8 months ago

Set JAVA_HOME and LD_LIBRARY_PATH using evn.default and env.append. This removes some logic from the build script.

AidanDelaney commented 8 months ago

This works

$ pack build sample-app --path samples/apps/java-maven --builder cnbs/sample-builder:jammy --pull-policy=never
Warning: Ignoring the provided lifecycle image as the builder is trusted, running the creator in a single container using the provided builder
===> ANALYZING
Timer: Analyzer started at 2023-12-06T10:25:56Z
Image with name "sample-app" not found
Timer: Analyzer ran for 561.166µs and ended at 2023-12-06T10:25:56Z
===> DETECTING
Timer: Detector started at 2023-12-06T10:25:56Z
samples/java-maven 0.0.2
Timer: Detector ran for 68.107167ms and ended at 2023-12-06T10:25:56Z
===> RESTORING
Timer: Restorer started at 2023-12-06T10:25:56Z
Restoring metadata for "samples/java-maven:maven_m2" from cache
Restoring data for "samples/java-maven:maven_m2" from cache
Timer: Restorer ran for 222.349542ms and ended at 2023-12-06T10:25:56Z
===> BUILDING
Timer: Builder started at 2023-12-06T10:25:56Z
---> Java buildpack
---> Installing JDK
---> Running Maven Wrapper
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< io.buildpacks.example:sample >--------------------
[INFO] Building sample 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ sample ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ sample ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /workspace/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /workspace/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ sample ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ sample ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ sample ---
[INFO] Building jar: /workspace/target/sample-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.18.RELEASE:repackage (repackage) @ sample ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ sample ---
[INFO] Installing /workspace/target/sample-0.0.1-SNAPSHOT.jar to /home/cnb/.m2/repository/io/buildpacks/example/sample/0.0.1-SNAPSHOT/sample-0.0.1-SNAPSHOT.jar
[INFO] Installing /workspace/pom.xml to /home/cnb/.m2/repository/io/buildpacks/example/sample/0.0.1-SNAPSHOT/sample-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.222 s
[INFO] Finished at: 2023-12-06T10:26:06Z
[INFO] ------------------------------------------------------------------------
Timer: Builder ran for 9.658328921s and ended at 2023-12-06T10:26:06Z
===> EXPORTING
Warning: no analyzed metadata found at path '/layers/analyzed.toml'
Timer: Exporter started at 2023-12-06T10:26:06Z
Adding layer 'samples/java-maven:jdk'
Adding layer 'buildpacksio/lifecycle:launch.sbom'
Adding 1/1 app layer(s)
Adding layer 'buildpacksio/lifecycle:launcher'
Adding layer 'buildpacksio/lifecycle:config'
Adding layer 'buildpacksio/lifecycle:process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Setting default process type 'web'
Timer: Saving sample-app... started at 2023-12-06T10:26:07Z
*** Images (78c684200cf4):
      sample-app
Timer: Saving sample-app... ran for 1.590382793s and ended at 2023-12-06T10:26:09Z
Timer: Exporter ran for 2.919740043s and ended at 2023-12-06T10:26:09Z
Timer: Cache started at 2023-12-06T10:26:09Z
Adding cache layer 'samples/java-maven:jdk'
Timer: Cache ran for 160.322667ms and ended at 2023-12-06T10:26:09Z
Successfully built image sample-app
$ docker run --rm -p 8080:8080 sample-app
    |'-_ _-'|       ____          _  _      _                      _             _
    |   |   |      |  _ \        (_)| |    | |                    | |           (_)
     '-_|_-'       | |_) | _   _  _ | |  __| | _ __    __ _   ___ | | __ ___     _   ___
|'-_ _-'|'-_ _-'|  |  _ < | | | || || | / _` || '_ \  / _` | / __|| |/ // __|   | | / _ \
|   |   |   |   |  | |_) || |_| || || || (_| || |_) || (_| || (__ |   < \__ \ _ | || (_) |
 '-_|_-' '-_|_-'   |____/  \__,_||_||_| \__,_|| .__/  \__,_| \___||_|\_\|___/(_)|_| \___/
                                              | |
                                              |_|

:: Built with Spring Boot :: 2.1.18.RELEASE
....