Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update java11-vertx to use a shadow jar #286

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions template/java11-vert-x/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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