-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (35 loc) · 1.14 KB
/
Dockerfile
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
# Apache Maven docker image used for maven build
FROM maven:3.5.3-jdk-8 AS build-jar
# Add project sources
ADD src app/src/
ADD pom.xml app/
# Set workdir
WORKDIR /app
# Execute maven build
RUN mvn -DskipTests package dependency:copy-dependencies
# GraalVM docker image used for AoT compilation
FROM panga/graalvm-ce:latest as build-aot
# Copy application jars from build-jar stage
COPY --from=build-jar /app/target/*.jar /app/
COPY --from=build-jar /app/target/dependency/*.jar /app/
# Add reflection.json from function folder
ADD reflection.json /app/
# Execute native-image tool and custom settings
RUN native-image \
--no-server \
--static \
-H:Name=app/fn \
-H:ReflectionConfigurationFiles=app/reflection.json \
-H:+ReportUnsupportedElementsAtRuntime \
-cp "app/*" \
com.fnproject.fn.runtime.EntryPoint
# Create new image from scratch
FROM scratch
# Set workdir
WORKDIR /app
# Copy generated native executable from build-aot stage
COPY --from=build-aot /app/fn /app/fn
# Set entrypoint to native executable
ENTRYPOINT [ "./fn" ]
# Set command to function entrypoint
CMD [ "org.mvnsearch.fn.HelloFunction::handleRequest" ]