Skip to content

Commit a7e357e

Browse files
authored
Merge pull request #166 from tzezula/native-image-afux
[164] Support http-stream protocol in substrate/native java.
2 parents 050c2cc + 29f11d3 commit a7e357e

8 files changed

Lines changed: 47 additions & 11 deletions

File tree

build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ mvn -B deploy -DaltDeploymentRepository=localStagingDir::default::file://${REP
4545
)
4646

4747
(
48+
workdir=$(pwd)/runtime
4849
cd images/build-native
49-
./docker-build.sh
50+
./docker-build.sh ${workdir}
5051
)
5152

5253

images/build-native/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN set -x \
66
&& apt-get -y install gcc g++ git make openjdk-8-doc openjdk-8-source python zlib1g-dev \
77
&& rm -rf /var/lib/apt/lists/*
88

9-
ENV JVMCI_VERSION 0.47
9+
ENV JVMCI_VERSION 0.49
1010

1111
WORKDIR /build
1212

@@ -20,7 +20,7 @@ RUN set -x \
2020
&& cp -r $(/build/mx/mx --primary-suite graal-jvmci-8 jdkhome) /build/jvmcijdk8
2121

2222
RUN git clone https://github.com/oracle/graal.git \
23-
&& git -C graal checkout dca98069dc57c458b8bcb3392cf9e66316dd37b6
23+
&& git -C graal checkout vm-1.0.0-rc9
2424
WORKDIR /build/graal/vm
2525
RUN export JAVA_HOME=/build/jvmcijdk8 \
2626
&& /build/mx/mx --dy /substratevm --force-bash-launchers=true --disable-polyglot --disable-libpolyglot build
@@ -38,6 +38,7 @@ RUN set -x \
3838
&& apt-get -y install gcc zlib1g-dev
3939

4040
COPY --from=build /build/graal/vm/latest_graalvm/graalvm /usr/local/graalvm
41+
COPY src/main/c/libfnunixsocket.so /function/runtime/lib/
4142

4243

4344
ENV GRAALVM_HOME=/usr/local/graalvm
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/bin/sh
2+
if [ -z "$1" ]
3+
then
4+
echo "Needs runtime folder as an argument"
5+
exit 1
6+
fi
27
native_version=$(cat native.version)
38
set -e
49

@@ -7,6 +12,10 @@ if docker pull ${native_image} ; then
712
echo ${native_image} already exists, skipping native build
813
exit 0
914
fi
10-
11-
docker build -t "fnproject/fn-java-native:${native_version}" .
15+
workdir=${1}
16+
dockerfiledir=$(pwd)
17+
(
18+
cd ${workdir}
19+
docker build -f ${dockerfiledir}/Dockerfile -t "fnproject/fn-java-native:${native_version}" .
20+
)
1221
echo "fnproject/fn-java-native:${native_version}" > native_build.image

images/build-native/native.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0
1+
0.2.0

images/init-native/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ LABEL maintainer="tomas.zezula@oracle.com"
1212
WORKDIR /function
1313
COPY --from=build /function/target/*.jar target/
1414
COPY --from=build /function/src/main/conf/reflection.json reflection.json
15+
COPY --from=build /function/src/main/conf/jni.json jni.json
1516
RUN /usr/local/graalvm/bin/native-image \
1617
--static \
18+
--delay-class-initialization-to-runtime=com.fnproject.fn.runtime.ntv.UnixSocketNative \
1719
-H:Name=func \
1820
-H:+ReportUnsupportedElementsAtRuntime \
1921
-H:ReflectionConfigurationFiles=reflection.json \
22+
-H:JNIConfigurationFiles=jni.json \
2023
-classpath "target/*"\
2124
com.fnproject.fn.runtime.EntryPoint
2225

2326

24-
FROM scratch
27+
FROM busybox:glibc
2528
LABEL maintainer="tomas.zezula@oracle.com"
2629
WORKDIR /function
2730
COPY --from=build-native-image /function/func func
31+
COPY --from=build-native-image /function/runtime/lib/* .
2832
ENTRYPOINT ["./func", "-XX:MaximumHeapSizePercent=80"]
2933
CMD [ "com.example.fn.HelloFunction::handleRequest" ]

images/init-native/func.init.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
runtime: docker
2-
format: http
2+
format: http-stream
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"name" : "com.fnproject.fn.runtime.ntv.UnixSocketNative",
4+
"methods" : [
5+
{ "name" : "socket" },
6+
{ "name" : "bind" },
7+
{ "name" : "connect" },
8+
{ "name" : "listen" },
9+
{ "name" : "accept" },
10+
{ "name" : "recv" },
11+
{ "name" : "send" },
12+
{ "name" : "close" },
13+
{ "name" : "setSendTimeout" },
14+
{ "name" : "getSendTimeout" },
15+
{ "name" : "setRecvTimeout" },
16+
{ "name" : "getRecvTimeout" },
17+
{ "name" : "setSendBufSize" },
18+
{ "name" : "setRecvBufSize" },
19+
{ "name" : "shutdown"}
20+
]
21+
}
22+
]
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
21
[
32
{
43
"name" : "com.example.fn.HelloFunction",
54
"methods" : [
6-
{ "name" : "handleRequest" },
7-
{ "name" : "<init>"}
5+
{ "name" : "handleRequest" },
6+
{ "name" : "<init>" }
87
]
98
}
109
]

0 commit comments

Comments
 (0)