Skip to content

Commit

Permalink
Update to use a shadow jar
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Mar 8, 2022
1 parent 26e8e43 commit b78f694
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
14 changes: 4 additions & 10 deletions template/java11-vert-x/Dockerfile
@@ -1,13 +1,13 @@
FROM openjdk:11-jdk-slim as builder

ENV GRADLE_VER=6.1.1
RUN apt-get update -qqy \
&& apt-get install -qqy \
--no-install-recommends \
curl \
ca-certificates \
unzip

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

RUN gradle build
RUN find .

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

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

WORKDIR /home/app
COPY --from=builder /home/app/entrypoint/build/distributions/entrypoint-1.0.zip ./entrypoint-1.0.zip
RUN unzip ./entrypoint-1.0.zip
COPY --from=builder /home/app/entrypoint/build/libs/app.jar ./app.jar

RUN addgroup --system app \
&& adduser --system --ingroup app app
Expand All @@ -52,9 +46,9 @@ USER app

ENV upstream_url="http://127.0.0.1:8082"
ENV mode="http"
ENV CLASSPATH="/home/app/entrypoint-1.0/lib/*"
# ENV CLASSPATH="/home/app/entrypoint-1.0/lib/*"

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

HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1
Expand Down
32 changes: 19 additions & 13 deletions template/java11-vert-x/entrypoint/build.gradle
Expand Up @@ -13,26 +13,30 @@ plugins {
// Apply the application plugin to add support for building an application
id 'application'

id 'com.github.johnrengelman.shadow' version '7.1.2'

}

// Define the main class for the application
mainClassName = 'App'
mainClassName = 'com.openfaas.entrypoint.App'

dependencies {
// Vert.x project
compile 'io.vertx:vertx-web:3.5.4'
implementation 'io.vertx:vertx-web:3.5.4'

// Use JUnit test framework
testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'

compile project(':function')
implementation project(':function')
}

jar {
shadowJar {
manifest {
attributes 'Implementation-Title': 'OpenFaaS Function',
'Implementation-Version': version
'Implementation-Version': version,
'Main-Class': mainClassName
}
archiveFileName.set('app.jar')
}

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

uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
// uploadArchives {
// repositories {
// flatDir {
// dirs 'repos'
// }
// }
// }

assemble.dependsOn(shadowJar)
2 changes: 1 addition & 1 deletion template/java11-vert-x/function/build.gradle
Expand Up @@ -13,7 +13,7 @@ plugins {

dependencies {
// Vert.x project
compile 'io.vertx:vertx-web:3.5.4'
implementation 'io.vertx:vertx-web:3.5.4'

// Use JUnit test framework
testImplementation 'junit:junit:4.12'
Expand Down

0 comments on commit b78f694

Please sign in to comment.