Skip to content

Commit b78f694

Browse files
committed
Update to use a shadow jar
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 26e8e43 commit b78f694

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

template/java11-vert-x/Dockerfile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
FROM openjdk:11-jdk-slim as builder
22

3-
ENV GRADLE_VER=6.1.1
43
RUN apt-get update -qqy \
54
&& apt-get install -qqy \
65
--no-install-recommends \
76
curl \
87
ca-certificates \
98
unzip
109

10+
ENV GRADLE_VER=7.3.3
1111
RUN mkdir -p /opt/ && cd /opt/ \
1212
&& echo "Downloading gradle.." \
1313
&& curl -sSfL "https://services.gradle.org/distributions/gradle-${GRADLE_VER}-bin.zip" -o gradle-$GRADLE_VER-bin.zip \
@@ -26,21 +26,15 @@ WORKDIR /home/app
2626
COPY . /home/app/
2727

2828
RUN gradle build
29-
RUN find .
3029

3130
FROM ghcr.io/openfaas/of-watchdog:0.9.3 as watchdog
3231
FROM openjdk:11-jre-slim as ship
33-
RUN apt-get update -qqy \
34-
&& apt-get install -qqy \
35-
--no-install-recommends \
36-
unzip
3732

3833
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
3934
RUN chmod +x /usr/bin/fwatchdog
4035

4136
WORKDIR /home/app
42-
COPY --from=builder /home/app/entrypoint/build/distributions/entrypoint-1.0.zip ./entrypoint-1.0.zip
43-
RUN unzip ./entrypoint-1.0.zip
37+
COPY --from=builder /home/app/entrypoint/build/libs/app.jar ./app.jar
4438

4539
RUN addgroup --system app \
4640
&& adduser --system --ingroup app app
@@ -52,9 +46,9 @@ USER app
5246

5347
ENV upstream_url="http://127.0.0.1:8082"
5448
ENV mode="http"
55-
ENV CLASSPATH="/home/app/entrypoint-1.0/lib/*"
49+
# ENV CLASSPATH="/home/app/entrypoint-1.0/lib/*"
5650

57-
ENV fprocess="java -XX:+UseContainerSupport -Dvertx.cacheDirBase=/tmp/.vertx-cache com.openfaas.entrypoint.App"
51+
ENV fprocess="java -XX:+UseContainerSupport -Dvertx.cacheDirBase=/tmp/.vertx-cache -jar app.jar"
5852
EXPOSE 8080
5953

6054
HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1

template/java11-vert-x/entrypoint/build.gradle

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,30 @@ plugins {
1313
// Apply the application plugin to add support for building an application
1414
id 'application'
1515

16+
id 'com.github.johnrengelman.shadow' version '7.1.2'
17+
1618
}
1719

1820
// Define the main class for the application
19-
mainClassName = 'App'
21+
mainClassName = 'com.openfaas.entrypoint.App'
2022

2123
dependencies {
2224
// Vert.x project
23-
compile 'io.vertx:vertx-web:3.5.4'
25+
implementation 'io.vertx:vertx-web:3.5.4'
2426

2527
// Use JUnit test framework
26-
testCompile 'junit:junit:4.12'
28+
testImplementation 'junit:junit:4.12'
2729

28-
compile project(':function')
30+
implementation project(':function')
2931
}
3032

31-
jar {
33+
shadowJar {
3234
manifest {
3335
attributes 'Implementation-Title': 'OpenFaaS Function',
34-
'Implementation-Version': version
36+
'Implementation-Version': version,
37+
'Main-Class': mainClassName
3538
}
39+
archiveFileName.set('app.jar')
3640
}
3741

3842
// In this section you declare where to find the dependencies of your project
@@ -42,10 +46,12 @@ repositories {
4246
jcenter()
4347
}
4448

45-
uploadArchives {
46-
repositories {
47-
flatDir {
48-
dirs 'repos'
49-
}
50-
}
51-
}
49+
// uploadArchives {
50+
// repositories {
51+
// flatDir {
52+
// dirs 'repos'
53+
// }
54+
// }
55+
// }
56+
57+
assemble.dependsOn(shadowJar)

template/java11-vert-x/function/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ plugins {
1313

1414
dependencies {
1515
// Vert.x project
16-
compile 'io.vertx:vertx-web:3.5.4'
16+
implementation 'io.vertx:vertx-web:3.5.4'
1717

1818
// Use JUnit test framework
1919
testImplementation 'junit:junit:4.12'

0 commit comments

Comments
 (0)