Skip to content

Commit 90d513b

Browse files
native build_spec.yaml fixed
1 parent 1b09a5a commit 90d513b

File tree

1 file changed

+26
-28
lines changed
  • app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/build_pipeline_specs

1 file changed

+26
-28
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
version: 0.1
2-
component: build
3-
timeoutInSeconds: 5000
4-
shell: bash
5-
env:
6-
exportedVariables:
7-
- buildId
8-
steps:
9-
- type: Command
10-
command: |
11-
buildId=`echo ${OCI_BUILD_RUN_ID} | rev | cut -c 1-6 | rev`
12-
echo "Build ID: $buildId"
13-
- type: Command
14-
command: |
15-
# This replaces the default open-jdk
16-
export GRAALVM_VERSION="21"
17-
export JAVA_VERSION="17"
18-
yum -y install graalvm${GRAALVM_VERSION}-ee-${JAVA_VERSION}-jdk;
19-
export JAVA_HOME=/usr/lib64/graalvm/graalvm${GRAALVM_VERSION}-ee-java${JAVA_VERSION};
20-
java -version
1+
FROM fnproject/fn-java-fdk-build:jdk17-1.0-latest as build-stage
2+
WORKDIR /function
3+
ENV MAVEN_OPTS -Dhttp.proxyHost= -Dhttp.proxyPort= -Dhttps.proxyHost= -Dhttps.proxyPort= -Dhttp.nonProxyHosts= -Dmaven.repo.local=/usr/share/maven/ref/repository
4+
ADD pom.xml /function/pom.xml
5+
RUN ["mvn", "package", "dependency:copy-dependencies", "-DincludeScope=runtime", "-DskipTests=true", "-Dmdep.prependGroupId=true", "-DoutputDirectory=target", "--fail-never"]
6+
ADD src /function/src
7+
RUN ["mvn", "package"]
218

22-
mvn clean install
23-
24-
docker build -f Dockerfile.native -t ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME} .
25-
docker tag ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:latest ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:$buildId
26-
outputArtifacts:
27-
- name: image-native
28-
type: DOCKER_IMAGE
29-
location: ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}
9+
FROM container-registry.oracle.com/graalvm/native-image:23-ol8 AS native
10+
WORKDIR /app
11+
COPY --from=build-stage /function/target .
12+
ADD reflection.json .
13+
14+
RUN native-image \
15+
-H:ReflectionConfigurationFiles=/app/reflection.json \
16+
-Ob \
17+
-H:Name=Hello \
18+
-cp "/app/Hellofunc-1.0-SNAPSHOT.jar:/app/*" \
19+
com.fnproject.fn.runtime.EntryPoint
20+
21+
FROM fnproject/fn-java-fdk:jre17-latest as fdk
22+
23+
FROM container-registry.oracle.com/os/oraclelinux:8-slim
24+
COPY --from=native /app/Hello .
25+
COPY --from=fdk /function/runtime/* ./
26+
ENTRYPOINT [ "./Hello" ]
27+
CMD [ "com.example.fn.HelloFunction::handleRequest", "-Djava.library.path=/lib"]

0 commit comments

Comments
 (0)