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

Use external jars from templates-sdk #214

Merged
merged 3 commits into from
Jul 23, 2020
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
15 changes: 7 additions & 8 deletions template/java11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,28 @@ RUN gradle build
RUN find .

FROM openfaas/of-watchdog:0.7.6 as watchdog

FROM openjdk:11-jre-slim as ship
RUN apt-get update -qqy \
&& apt-get install -qqy \
--no-install-recommends \
unzip
RUN addgroup --system app \
&& adduser --system --ingroup app app

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

RUN addgroup --system app \
&& adduser --system --ingroup app app
COPY --from=builder /home/app/function/build/distributions/function-1.0.zip ./function-1.0.zip
user app
RUN unzip ./function-1.0.zip

WORKDIR /home/app/

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/function-1.0/function-1.0.jar:/home/app/function-1.0/lib/*"

ENV fprocess="java -XX:+UseContainerSupport com.openfaas.entrypoint.App"
EXPOSE 8080
Expand Down
19 changes: 7 additions & 12 deletions template/java11/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds/
*/

allprojects {
repositories {
jcenter()
}
}

subprojects {
// apply plugin: 'java'

version = '1.0'
}

// jar {
// manifest.attributes provider: 'gradle'
// }
repositories {
jcenter()

flatDir {
dirs 'libs'
}
}
52 changes: 0 additions & 52 deletions template/java11/entrypoint/build.gradle

This file was deleted.

Binary file not shown.

This file was deleted.

10 changes: 0 additions & 10 deletions template/java11/entrypoint/settings.gradle

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions template/java11/entrypoint/src/test/java/AppTest.java

This file was deleted.

43 changes: 34 additions & 9 deletions template/java11/function/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java Library project to get you started.
* For more details take a look at the Java Libraries chapter in the Gradle
* user guide available at https://docs.gradle.org/4.8.1/userguide/java_library_plugin.html
*/

plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
id 'distribution'
}

dependencies {
Expand All @@ -21,12 +14,44 @@ dependencies {
// Use JUnit test framework
testImplementation 'junit:junit:4.12'

compile project(':model')
compile 'com.openfaas:model:0.1.1'
compile 'com.openfaas:entrypoint:0.1.0'
}

// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()

flatDir {
dirs '../libs'
}
}

jar {
manifest {
attributes 'Implementation-Title': 'OpenFaaS Function',
'Implementation-Version': '1.0'
}
}


distributions {
main {
contents {
from jar
into('lib') {
from(project.configurations.runtime)
}
}
}
}

uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.openfaas.model.IRequest;
import com.openfaas.model.Response;

public class Handler implements com.openfaas.model.IHandler {
public class Handler extends com.openfaas.model.AbstractHandler {

public IResponse Handle(IRequest req) {
Response res = new Response();
Expand Down
5 changes: 2 additions & 3 deletions template/java11/function/src/test/java/HandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import static org.junit.Assert.*;

import com.openfaas.function.Handler;
import com.openfaas.model.IHandler;

public class HandlerTest {

@Test public void handlerIsNotNull() {
Handler handler = new Handler();
IHandler handler = new Handler();
assertTrue("Expected handler not to be null", handler != null);
}

}
30 changes: 0 additions & 30 deletions template/java11/model/build.gradle

This file was deleted.

Binary file not shown.

This file was deleted.

10 changes: 0 additions & 10 deletions template/java11/model/settings.gradle

This file was deleted.

This file was deleted.

Loading