mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 03:56:37 +00:00
Light-weight examples for HelloWorld - for on reading an input/request.
This commit is contained in:
1
sample-functions/BaseFunctions/java/.gitignore
vendored
Normal file
1
sample-functions/BaseFunctions/java/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.class
|
16
sample-functions/BaseFunctions/java/Dockerfile
Normal file
16
sample-functions/BaseFunctions/java/Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
FROM openjdk:8u121-jdk-alpine
|
||||
|
||||
ADD https://github.com/alexellis/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin
|
||||
RUN chmod +x /usr/bin/fwatchdog
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
COPY Handler.java .
|
||||
RUN javac Handler.java
|
||||
|
||||
ENV fprocess="java Handler"
|
||||
|
||||
HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1
|
||||
|
||||
CMD ["fwatchdog"]
|
||||
|
30
sample-functions/BaseFunctions/java/Handler.java
Normal file
30
sample-functions/BaseFunctions/java/Handler.java
Normal file
@ -0,0 +1,30 @@
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class Handler {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
|
||||
String input = readStdin();
|
||||
System.out.print(input);
|
||||
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String readStdin() throws IOException {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
String input = "";
|
||||
while(true) {
|
||||
String line = br.readLine();
|
||||
if(line==null) {
|
||||
break;
|
||||
}
|
||||
input = input + line + "\n";
|
||||
}
|
||||
return input;
|
||||
}
|
||||
}
|
4
sample-functions/BaseFunctions/java/build.sh
Executable file
4
sample-functions/BaseFunctions/java/build.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Building functions/openjdk:8u121-jdk-alpine"
|
||||
docker build -t functions/openjdk:8u121-jdk-alpine .
|
Reference in New Issue
Block a user