-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrockcraft.yaml
58 lines (52 loc) · 1.79 KB
/
rockcraft.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: spring-petclinic-jlink
version: 0.0.1
summary: Basic Spring Petclinic
description: |
This image is Spring Petclinic sample
using openjdk-17-headless slices
base: bare
build-base: [email protected]
run-user: _daemon_
platforms:
amd64:
services:
test:
override: replace
summary: Service summary
command: /usr/bin/java -jar /jars/application.jar
startup: enabled
parts:
application:
plugin: nil
source: https://github.com/spring-projects/spring-petclinic.git
source-type: git
build-environment:
- JAVA_HOME: "/usr/lib/jvm/java-17-openjdk-${CRAFT_ARCH_BUILD_FOR}"
build-packages:
- openjdk-17-jdk-headless
override-build: |
./mvnw package
mkdir -p ${CRAFT_PART_INSTALL}/jars
cp ${CRAFT_PART_BUILD}/target/*-SNAPSHOT.jar ${CRAFT_PART_INSTALL}/jars/application.jar
cp ${CRAFT_PART_BUILD}/target/classes/META-INF/sbom/application.cdx.json ${CRAFT_PART_INSTALL}/jars/
craftctl default
runtime:
plugin: nil
build-packages:
- openjdk-17-jdk-headless
after:
- application
stage-packages:
- base-files_base
- openjdk-17-jre-headless_standard
override-build: |
craftctl default
install_root=${CRAFT_PART_INSTALL}/usr/lib/jvm/java-17-openjdk-${CRAFT_ARCH_BUILD_FOR}/
jar xvf ${CRAFT_STAGE}/jars/*.jar
deps=$(jdeps --module-path="./BOOT-INF/lib/*" --class-path="./BOOT-INF/lib/*" -q --recursive \
--ignore-missing-deps --print-module-deps --multi-release 17 ${CRAFT_STAGE}/jars/*.jar)
# rebuild Java image with jlink
rm -rf ${install_root} && jlink --add-modules ${deps} --output ${install_root}
# add Java shortcut
(cd ${CRAFT_PART_INSTALL} && \
ln -s --relative usr/lib/jvm/java-17-openjdk-${CRAFT_ARCH_BUILD_FOR}/bin/java usr/bin/java)