mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
chore(partnerctl): add GraalVM native-image setup and arm64 build tooling
This commit is contained in:
12
PartnerCtl/Dockerfile.native-arm64
Normal file
12
PartnerCtl/Dockerfile.native-arm64
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM --platform=linux/arm64 ghcr.io/graalvm/native-image-community:21
|
||||
|
||||
RUN microdnf install -y \
|
||||
maven \
|
||||
findutils \
|
||||
gzip \
|
||||
tar \
|
||||
which \
|
||||
file \
|
||||
&& microdnf clean all
|
||||
|
||||
WORKDIR /workspace
|
||||
@@ -15,8 +15,10 @@
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<picocli.version>4.7.7</picocli.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jline</groupId>
|
||||
@@ -26,8 +28,78 @@
|
||||
<dependency>
|
||||
<groupId>info.picocli</groupId>
|
||||
<artifactId>picocli</artifactId>
|
||||
<version>4.7.7</version>
|
||||
<version>${picocli.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>info.picocli</groupId>
|
||||
<artifactId>picocli-codegen</artifactId>
|
||||
<version>${picocli.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>kapt</id>
|
||||
<goals>
|
||||
<goal>kapt</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<sourceDir>src/main/java</sourceDir>
|
||||
</sourceDirs>
|
||||
<annotationProcessorPaths>
|
||||
<annotationProcessorPath>
|
||||
<groupId>info.picocli</groupId>
|
||||
<artifactId>picocli-codegen</artifactId>
|
||||
<version>${picocli.version}</version>
|
||||
</annotationProcessorPath>
|
||||
</annotationProcessorPaths>
|
||||
<annotationProcessorArgs>
|
||||
<project>partnerctl</project>
|
||||
</annotationProcessorArgs>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<sourceDir>src/main/java</sourceDir>
|
||||
</sourceDirs>
|
||||
<jvmTarget>21</jvmTarget>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.graalvm.buildtools</groupId>
|
||||
<artifactId>native-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<imageName>partnerctl</imageName>
|
||||
<mainClass>work.slhaf.partner.ctl.PartnerCtlKt</mainClass>
|
||||
<metadataRepository>
|
||||
<enabled>false</enabled>
|
||||
</metadataRepository>
|
||||
<buildArgs>
|
||||
<buildArg>--no-fallback</buildArg>
|
||||
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
27
PartnerCtl/scripts/build-native-arm64.sh
Normal file
27
PartnerCtl/scripts/build-native-arm64.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
MODULE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
REPO_DIR="$(cd "${MODULE_DIR}/.." && pwd)"
|
||||
IMAGE_NAME="${PARTNERCTL_ARM64_BUILDER_IMAGE:-partnerctl-native-arm64-builder:21}"
|
||||
DOCKERFILE="${MODULE_DIR}/Dockerfile.native-arm64"
|
||||
|
||||
if ! docker image inspect "${IMAGE_NAME}" >/dev/null 2>&1; then
|
||||
echo "[partnerctl] building reusable arm64 native builder image: ${IMAGE_NAME}"
|
||||
docker buildx build \
|
||||
--platform linux/arm64 \
|
||||
-f "${DOCKERFILE}" \
|
||||
-t "${IMAGE_NAME}" \
|
||||
--load \
|
||||
"${MODULE_DIR}"
|
||||
fi
|
||||
|
||||
echo "[partnerctl] building linux-aarch64 native executable"
|
||||
docker run --rm \
|
||||
--platform linux/arm64 \
|
||||
--entrypoint /bin/bash \
|
||||
-v "${REPO_DIR}":/workspace \
|
||||
-v "${HOME}/.m2":/root/.m2 \
|
||||
-w /workspace/PartnerCtl \
|
||||
"${IMAGE_NAME}" \
|
||||
-lc 'mvn -Pnative native:compile && file target/partnerctl'
|
||||
Reference in New Issue
Block a user