From c05aee101cc202ef04581a703cace6ddb9d8c2f5 Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Thu, 4 May 2017 17:40:04 +0100 Subject: [PATCH] FaaS does Cobol :-) --- .../BaseFunctions/cobol/Dockerfile | 15 ++++++++ sample-functions/BaseFunctions/cobol/build.sh | 4 ++ .../BaseFunctions/cobol/handler.cob | 38 +++++++++++++++++++ .../BaseFunctions/cobol/hello.cob | 6 +++ 4 files changed, 63 insertions(+) create mode 100644 sample-functions/BaseFunctions/cobol/Dockerfile create mode 100755 sample-functions/BaseFunctions/cobol/build.sh create mode 100644 sample-functions/BaseFunctions/cobol/handler.cob create mode 100644 sample-functions/BaseFunctions/cobol/hello.cob diff --git a/sample-functions/BaseFunctions/cobol/Dockerfile b/sample-functions/BaseFunctions/cobol/Dockerfile new file mode 100644 index 00000000..8c202f08 --- /dev/null +++ b/sample-functions/BaseFunctions/cobol/Dockerfile @@ -0,0 +1,15 @@ +FROM toricls/gnucobol:latest + +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.cob . +RUN cobc -x handler.cob +ENV fprocess="./handler" + +HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 + +CMD ["fwatchdog"] + diff --git a/sample-functions/BaseFunctions/cobol/build.sh b/sample-functions/BaseFunctions/cobol/build.sh new file mode 100755 index 00000000..e0fc9163 --- /dev/null +++ b/sample-functions/BaseFunctions/cobol/build.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "Building functions/base:cobol" +docker build -t functions/base:cobol . diff --git a/sample-functions/BaseFunctions/cobol/handler.cob b/sample-functions/BaseFunctions/cobol/handler.cob new file mode 100644 index 00000000..cf269b99 --- /dev/null +++ b/sample-functions/BaseFunctions/cobol/handler.cob @@ -0,0 +1,38 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. APP. + *> Example based upon http://stackoverflow.com/q/938760/1420197 + *> More on COBOL @ https://www.ibm.com/support/knowledgecenter/en/SS6SG3_3.4.0/com.ibm.entcobol.doc_3.4/tpbeg15.htm + ENVIRONMENT DIVISION. + INPUT-OUTPUT SECTION. + FILE-CONTROL. + SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL. + + DATA DIVISION. + FILE SECTION. + FD SYSIN. + 01 ln PIC X(64). + 88 EOF VALUE HIGH-VALUES. + + WORKING-STORAGE SECTION. + PROCEDURE DIVISION. + + DISPLAY "Request data: " + DISPLAY "------------" + + OPEN INPUT SYSIN + READ SYSIN + AT END SET EOF TO TRUE + END-READ + PERFORM UNTIL EOF + + + DISPLAY ln + + READ SYSIN + AT END SET EOF TO TRUE + END-READ + END-PERFORM + CLOSE SYSIN + + DISPLAY "------------" + STOP RUN. diff --git a/sample-functions/BaseFunctions/cobol/hello.cob b/sample-functions/BaseFunctions/cobol/hello.cob new file mode 100644 index 00000000..fb192719 --- /dev/null +++ b/sample-functions/BaseFunctions/cobol/hello.cob @@ -0,0 +1,6 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. HELLO-WORLD. + PROCEDURE DIVISION. + DISPLAY 'FaaS running COBOL in a container!'. + STOP RUN. +