diff --git a/app-dev/devops-and-containers/functions/java-helloworld-AI-with-local-dev-and-oci-functions/files/Dockerfile.native b/app-dev/devops-and-containers/functions/java-helloworld-AI-with-local-dev-and-oci-functions/files/Dockerfile.native index 3a9a8c3d5..44d4967d9 100644 --- a/app-dev/devops-and-containers/functions/java-helloworld-AI-with-local-dev-and-oci-functions/files/Dockerfile.native +++ b/app-dev/devops-and-containers/functions/java-helloworld-AI-with-local-dev-and-oci-functions/files/Dockerfile.native @@ -1,14 +1,21 @@ +FROM fnproject/fn-java-fdk-build:jdk17-1.0-latest as build-stage +WORKDIR /function +ENV MAVEN_OPTS -Dhttp.proxyHost= -Dhttp.proxyPort= -Dhttps.proxyHost= -Dhttps.proxyPort= -Dhttp.nonProxyHosts= -Dmaven.repo.local=/usr/share/maven/ref/repository +ADD pom.xml /function/pom.xml +RUN ["mvn", "package", "dependency:copy-dependencies", "-DincludeScope=runtime", "-DskipTests=true", "-Dmdep.prependGroupId=true", "-DoutputDirectory=target", "--fail-never"] +ADD src /function/src +RUN ["mvn", "package"] + FROM container-registry.oracle.com/graalvm/native-image:23-ol8 AS native WORKDIR /app - -COPY target . +COPY --from=build-stage /function/target . ADD reflection.json . RUN native-image \ -H:ReflectionConfigurationFiles=/app/reflection.json \ -Ob \ -H:Name=Hello \ - -cp "/app/Hellofunc-1.0-SNAPSHOT.jar:/app/lib/*" \ + -cp "/app/Hellofunc-1.0-SNAPSHOT.jar:/app/*" \ com.fnproject.fn.runtime.EntryPoint FROM fnproject/fn-java-fdk:jre17-1.0.198 as fdk diff --git a/app-dev/devops-and-containers/functions/java-helloworld-AI-with-local-dev-and-oci-functions/files/build_spec_native.yaml b/app-dev/devops-and-containers/functions/java-helloworld-AI-with-local-dev-and-oci-functions/files/build_spec_native.yaml index 687c767c1..eb936c36f 100644 --- a/app-dev/devops-and-containers/functions/java-helloworld-AI-with-local-dev-and-oci-functions/files/build_spec_native.yaml +++ b/app-dev/devops-and-containers/functions/java-helloworld-AI-with-local-dev-and-oci-functions/files/build_spec_native.yaml @@ -12,15 +12,6 @@ steps: echo "Build ID: $buildId" - type: Command command: | - # This replaces the default open-jdk - export GRAALVM_VERSION="21" - export JAVA_VERSION="17" - yum -y install graalvm${GRAALVM_VERSION}-ee-${JAVA_VERSION}-jdk; - export JAVA_HOME=/usr/lib64/graalvm/graalvm${GRAALVM_VERSION}-ee-java${JAVA_VERSION}; - java -version - - mvn clean install - docker build -f Dockerfile.native -t ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME} . docker tag ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:latest ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:$buildId outputArtifacts: