From a174b71690f425a08fff76c1782b351c1a8021c5 Mon Sep 17 00:00:00 2001 From: Kirill Keker Date: Thu, 28 Mar 2024 12:29:28 +0200 Subject: [PATCH] Added retro programming languages --- manifest.json | 49 +++++++++++++++++++ s3-uploader/runtimes/ada/Dockerfile | 13 +++++ s3-uploader/runtimes/ada/build.sh | 19 +++++++ .../runtimes/ada/lambda/MaxdayLambda.ada | 6 +++ s3-uploader/runtimes/ada/lambda/bootstrap | 34 +++++++++++++ s3-uploader/runtimes/asm/Dockerfile | 13 +++++ s3-uploader/runtimes/asm/build.sh | 19 +++++++ s3-uploader/runtimes/asm/lambda/bootstrap | 34 +++++++++++++ .../runtimes/asm/lambda/lambda_aarch64.s | 19 +++++++ .../runtimes/asm/lambda/lambda_x86_64.s | 19 +++++++ s3-uploader/runtimes/cobol/Dockerfile | 24 +++++++++ s3-uploader/runtimes/cobol/build.sh | 19 +++++++ s3-uploader/runtimes/cobol/lambda/bootstrap | 36 ++++++++++++++ s3-uploader/runtimes/cobol/lambda/lambda.cob | 5 ++ s3-uploader/runtimes/fortran/Dockerfile | 16 ++++++ s3-uploader/runtimes/fortran/build.sh | 19 +++++++ s3-uploader/runtimes/fortran/lambda/bootstrap | 36 ++++++++++++++ .../runtimes/fortran/lambda/lambda.f90 | 3 ++ s3-uploader/runtimes/lisp/Dockerfile | 14 ++++++ s3-uploader/runtimes/lisp/build.sh | 19 +++++++ s3-uploader/runtimes/lisp/lambda/bootstrap | 34 +++++++++++++ s3-uploader/runtimes/lisp/lambda/lambda.lisp | 3 ++ s3-uploader/runtimes/oberon/Dockerfile | 23 +++++++++ s3-uploader/runtimes/oberon/build.sh | 19 +++++++ .../runtimes/oberon/lambda/MaxdayLambda.Mod | 8 +++ s3-uploader/runtimes/oberon/lambda/bootstrap | 36 ++++++++++++++ s3-uploader/runtimes/pascal/Dockerfile | 21 ++++++++ s3-uploader/runtimes/pascal/build.sh | 19 +++++++ s3-uploader/runtimes/pascal/lambda/bootstrap | 34 +++++++++++++ s3-uploader/runtimes/pascal/lambda/lambda.pas | 5 ++ s3-uploader/runtimes/pascal/unattended.exp | 9 ++++ 31 files changed, 627 insertions(+) create mode 100644 s3-uploader/runtimes/ada/Dockerfile create mode 100755 s3-uploader/runtimes/ada/build.sh create mode 100644 s3-uploader/runtimes/ada/lambda/MaxdayLambda.ada create mode 100755 s3-uploader/runtimes/ada/lambda/bootstrap create mode 100644 s3-uploader/runtimes/asm/Dockerfile create mode 100755 s3-uploader/runtimes/asm/build.sh create mode 100755 s3-uploader/runtimes/asm/lambda/bootstrap create mode 100644 s3-uploader/runtimes/asm/lambda/lambda_aarch64.s create mode 100644 s3-uploader/runtimes/asm/lambda/lambda_x86_64.s create mode 100644 s3-uploader/runtimes/cobol/Dockerfile create mode 100755 s3-uploader/runtimes/cobol/build.sh create mode 100755 s3-uploader/runtimes/cobol/lambda/bootstrap create mode 100644 s3-uploader/runtimes/cobol/lambda/lambda.cob create mode 100644 s3-uploader/runtimes/fortran/Dockerfile create mode 100755 s3-uploader/runtimes/fortran/build.sh create mode 100755 s3-uploader/runtimes/fortran/lambda/bootstrap create mode 100644 s3-uploader/runtimes/fortran/lambda/lambda.f90 create mode 100644 s3-uploader/runtimes/lisp/Dockerfile create mode 100755 s3-uploader/runtimes/lisp/build.sh create mode 100755 s3-uploader/runtimes/lisp/lambda/bootstrap create mode 100644 s3-uploader/runtimes/lisp/lambda/lambda.lisp create mode 100644 s3-uploader/runtimes/oberon/Dockerfile create mode 100755 s3-uploader/runtimes/oberon/build.sh create mode 100644 s3-uploader/runtimes/oberon/lambda/MaxdayLambda.Mod create mode 100755 s3-uploader/runtimes/oberon/lambda/bootstrap create mode 100644 s3-uploader/runtimes/pascal/Dockerfile create mode 100755 s3-uploader/runtimes/pascal/build.sh create mode 100755 s3-uploader/runtimes/pascal/lambda/bootstrap create mode 100644 s3-uploader/runtimes/pascal/lambda/lambda.pas create mode 100755 s3-uploader/runtimes/pascal/unattended.exp diff --git a/manifest.json b/manifest.json index 37b2c13658..f0e830d415 100644 --- a/manifest.json +++ b/manifest.json @@ -335,6 +335,55 @@ "image": { "baseImage": "public.ecr.aws/lambda/provided:al2023" } + }, + { + "displayName": "ada (gnat)", + "runtime": "provided.al2", + "handler": "handler", + "path": "ada", + "architectures": ["x86_64", "arm64"] + }, + { + "displayName": "assembler (binutils)", + "runtime": "provided.al2", + "handler": "handler", + "path": "asm", + "architectures": ["x86_64", "arm64"] + }, + { + "displayName": "cobol (cobc)", + "runtime": "provided.al2", + "handler": "handler", + "path": "cobol", + "architectures": ["x86_64", "arm64"] + }, + { + "displayName": "fortran (gfortran)", + "runtime": "provided.al2", + "handler": "handler", + "path": "fortran", + "architectures": ["x86_64", "arm64"] + }, + { + "displayName": "lisp (sbcl)", + "runtime": "provided.al2", + "handler": "handler", + "path": "lisp", + "architectures": ["x86_64", "arm64"] + }, + { + "displayName": "oberon (obnc)", + "runtime": "provided.al2", + "handler": "handler", + "path": "oberon", + "architectures": ["x86_64", "arm64"] + }, + { + "displayName": "pascal (fpc)", + "runtime": "provided.al2", + "handler": "handler", + "path": "pascal", + "architectures": ["x86_64", "arm64"] } ] } \ No newline at end of file diff --git a/s3-uploader/runtimes/ada/Dockerfile b/s3-uploader/runtimes/ada/Dockerfile new file mode 100644 index 0000000000..14a42ce168 --- /dev/null +++ b/s3-uploader/runtimes/ada/Dockerfile @@ -0,0 +1,13 @@ +FROM amazonlinux:2 AS builder +ENV APP_BASE_DIR=/tmp +WORKDIR $APP_BASE_DIR +RUN yum install gcc-gnat zip -y +COPY lambda lambda +WORKDIR $APP_BASE_DIR/lambda +RUN gnatmake MaxdayLambda.ada +RUN rm -f MaxdayLambda.* +RUN zip -r $APP_BASE_DIR/code.zip . + +FROM scratch +COPY --from=builder /tmp/code.zip /code.zip +ENTRYPOINT ["/code.zip"] \ No newline at end of file diff --git a/s3-uploader/runtimes/ada/build.sh b/s3-uploader/runtimes/ada/build.sh new file mode 100755 index 0000000000..3480d0e679 --- /dev/null +++ b/s3-uploader/runtimes/ada/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +DIR_NAME="./runtimes/$1" + +if [ $2 = "x86_64" ]; then + ARCH="linux/amd64" +elif [ $2 = "arm64" ]; then + ARCH="linux/arm64/v8" +else + echo "The process architecture $2 is set incorrectly. The value can only be either x86_64 or arm64." + exit 1 +fi + +rm ${DIR_NAME}/code_${2}.zip 2> /dev/null + +docker build ${DIR_NAME} --platform ${ARCH} -t maxday/ada_${2} +dockerId=$(docker create maxday/ada_${2}) + +docker cp $dockerId:/code.zip ${DIR_NAME}/code_${2}.zip \ No newline at end of file diff --git a/s3-uploader/runtimes/ada/lambda/MaxdayLambda.ada b/s3-uploader/runtimes/ada/lambda/MaxdayLambda.ada new file mode 100644 index 0000000000..8dbf171711 --- /dev/null +++ b/s3-uploader/runtimes/ada/lambda/MaxdayLambda.ada @@ -0,0 +1,6 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure MaxdayLambda is +begin + Put_Line ("Hello from Ada!"); +end MaxdayLambda; diff --git a/s3-uploader/runtimes/ada/lambda/bootstrap b/s3-uploader/runtimes/ada/lambda/bootstrap new file mode 100755 index 0000000000..d308b918b6 --- /dev/null +++ b/s3-uploader/runtimes/ada/lambda/bootstrap @@ -0,0 +1,34 @@ +#!/bin/sh + +set -euo pipefail + +# Processing Loop +while true +do + echo "handler: $_HANDLER" + HEADERS="$(mktemp)" + # Get an event. The HTTP request will block until one is received + EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next") + echo "event data: $EVENT_DATA" + + # Extract request ID by scraping response headers received above + REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) + echo "request id: $REQUEST_ID" + + # Execute the handler function from the script + echo "ls -lh $(pwd) (current working dir)" + echo "$(ls -lh .)" + #RESPONSE=$($_HANDLER) + RESPONSE=$(/var/task/MaxdayLambda) + + # Necessary API Gateway response format + JSON_RESPONSE=' + { + "isBase64Encoded": false, + "statusCode": 200, + "body": "'"$RESPONSE"'" + }' + + # Send the response + curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "${JSON_RESPONSE}" +done \ No newline at end of file diff --git a/s3-uploader/runtimes/asm/Dockerfile b/s3-uploader/runtimes/asm/Dockerfile new file mode 100644 index 0000000000..708a594ae0 --- /dev/null +++ b/s3-uploader/runtimes/asm/Dockerfile @@ -0,0 +1,13 @@ +FROM amazonlinux:2 AS builder +ENV APP_BASE_DIR=/tmp +WORKDIR $APP_BASE_DIR +RUN yum install binutils zip -y +COPY lambda lambda +WORKDIR $APP_BASE_DIR/lambda +RUN as -o lambda_$(uname -m).o lambda_$(uname -m).s && ld -o lambda lambda_$(uname -m).o +RUN rm -f lambda_* +RUN zip -r $APP_BASE_DIR/code.zip . + +FROM scratch +COPY --from=builder /tmp/code.zip /code.zip +ENTRYPOINT ["/code.zip"] \ No newline at end of file diff --git a/s3-uploader/runtimes/asm/build.sh b/s3-uploader/runtimes/asm/build.sh new file mode 100755 index 0000000000..5223f9c963 --- /dev/null +++ b/s3-uploader/runtimes/asm/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +DIR_NAME="./runtimes/$1" + +if [ $2 = "x86_64" ]; then + ARCH="linux/amd64" +elif [ $2 = "arm64" ]; then + ARCH="linux/arm64/v8" +else + echo "The process architecture $2 is set incorrectly. The value can only be either x86_64 or arm64." + exit 1 +fi + +rm ${DIR_NAME}/code_${2}.zip 2> /dev/null + +docker build ${DIR_NAME} --platform ${ARCH} -t maxday/asm_${2} +dockerId=$(docker create maxday/asm_${2}) + +docker cp $dockerId:/code.zip ${DIR_NAME}/code_${2}.zip \ No newline at end of file diff --git a/s3-uploader/runtimes/asm/lambda/bootstrap b/s3-uploader/runtimes/asm/lambda/bootstrap new file mode 100755 index 0000000000..85eba29c24 --- /dev/null +++ b/s3-uploader/runtimes/asm/lambda/bootstrap @@ -0,0 +1,34 @@ +#!/bin/sh + +set -euo pipefail + +# Processing Loop +while true +do + echo "handler: $_HANDLER" + HEADERS="$(mktemp)" + # Get an event. The HTTP request will block until one is received + EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next") + echo "event data: $EVENT_DATA" + + # Extract request ID by scraping response headers received above + REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) + echo "request id: $REQUEST_ID" + + # Execute the handler function from the script + echo "ls -lh $(pwd) (current working dir)" + echo "$(ls -lh .)" + #RESPONSE=$($_HANDLER) + RESPONSE=$(/var/task/lambda) + + # Necessary API Gateway response format + JSON_RESPONSE=' + { + "isBase64Encoded": false, + "statusCode": 200, + "body": "'"$RESPONSE"'" + }' + + # Send the response + curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "${JSON_RESPONSE}" +done \ No newline at end of file diff --git a/s3-uploader/runtimes/asm/lambda/lambda_aarch64.s b/s3-uploader/runtimes/asm/lambda/lambda_aarch64.s new file mode 100644 index 0000000000..4672dcc50d --- /dev/null +++ b/s3-uploader/runtimes/asm/lambda/lambda_aarch64.s @@ -0,0 +1,19 @@ +.data +hello: + .ascii "Hello from Assembler!\n" + +len = . - hello + +.text +.global _start + +_start: + mov x0, 1 // file descriptor: stdout + ldr x1, =hello // pointer to message + ldr x2, =len // message length + mov x8, 64 // syscall: write + svc 0 // make syscall + + mov x0, 0 // status: 0 + mov x8, 93 // syscall: exit + svc 0 // make syscall diff --git a/s3-uploader/runtimes/asm/lambda/lambda_x86_64.s b/s3-uploader/runtimes/asm/lambda/lambda_x86_64.s new file mode 100644 index 0000000000..587cc4d965 --- /dev/null +++ b/s3-uploader/runtimes/asm/lambda/lambda_x86_64.s @@ -0,0 +1,19 @@ +.data +hello: + .string "Hello from Assembler!" + +.text +.global _start + +_start: + # write our string to stdout + mov $1, %rax # syscall: write + mov $1, %rdi # file descriptor: stdout + mov $hello, %rsi # pointer to message + mov $21, %rdx # message length + syscall + + # exit + mov $60, %rax # syscall: exit + xor %rdi, %rdi # status: 0 + syscall diff --git a/s3-uploader/runtimes/cobol/Dockerfile b/s3-uploader/runtimes/cobol/Dockerfile new file mode 100644 index 0000000000..7e66207a1c --- /dev/null +++ b/s3-uploader/runtimes/cobol/Dockerfile @@ -0,0 +1,24 @@ +FROM amazonlinux:2 AS builder +ARG GNUCOBOL_VER=3.2 +ENV APP_BASE_DIR=/tmp +WORKDIR $APP_BASE_DIR +RUN yum install tar gzip make gcc gmp-devel zip -y +RUN curl -o gnucobol.tgz "https://nav.dl.sourceforge.net/project/gnucobol/gnucobol/${GNUCOBOL_VER}/gnucobol-${GNUCOBOL_VER}.tar.gz" +RUN mkdir gnucobol && tar -xvvzf gnucobol.tgz --strip-components 1 -C gnucobol && rm -f gnucobol.tgz +WORKDIR "${APP_BASE_DIR}/gnucobol" +RUN ./configure --without-db +RUN make && make install +WORKDIR $APP_BASE_DIR +RUN rm -rf gnucobol +COPY lambda lambda +WORKDIR $APP_BASE_DIR/lambda +RUN mkdir lib && cp /usr/local/lib/libcob.so.4 lib +RUN cobc -x lambda.cob +RUN rm -f lambda.cob +### Only for debug +#ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APP_BASE_DIR/lambda/lib +RUN zip -r $APP_BASE_DIR/code.zip . + +FROM scratch +COPY --from=builder /tmp/code.zip /code.zip +ENTRYPOINT ["/code.zip"] \ No newline at end of file diff --git a/s3-uploader/runtimes/cobol/build.sh b/s3-uploader/runtimes/cobol/build.sh new file mode 100755 index 0000000000..0e56d2d992 --- /dev/null +++ b/s3-uploader/runtimes/cobol/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +DIR_NAME="./runtimes/$1" + +if [ $2 = "x86_64" ]; then + ARCH="linux/amd64" +elif [ $2 = "arm64" ]; then + ARCH="linux/arm64/v8" +else + echo "The process architecture $2 is set incorrectly. The value can only be either x86_64 or arm64." + exit 1 +fi + +rm ${DIR_NAME}/code_${2}.zip 2> /dev/null + +docker build ${DIR_NAME} --platform ${ARCH} -t maxday/cobol_${2} +dockerId=$(docker create maxday/cobol_${2}) + +docker cp $dockerId:/code.zip ${DIR_NAME}/code_${2}.zip \ No newline at end of file diff --git a/s3-uploader/runtimes/cobol/lambda/bootstrap b/s3-uploader/runtimes/cobol/lambda/bootstrap new file mode 100755 index 0000000000..cfa07d386f --- /dev/null +++ b/s3-uploader/runtimes/cobol/lambda/bootstrap @@ -0,0 +1,36 @@ +#!/bin/sh + +set -euo pipefail + +# Processing Loop +while true +do + echo "handler: $_HANDLER" + HEADERS="$(mktemp)" + # Get an event. The HTTP request will block until one is received + EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next") + echo "event data: $EVENT_DATA" + + # Extract request ID by scraping response headers received above + REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) + echo "request id: $REQUEST_ID" + + # Execute the handler function from the script + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LAMBDA_TASK_ROOT/lib + echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" + echo "ls -lh $(pwd) (current working dir)" + echo "$(ls -lh .)" + #RESPONSE=$($_HANDLER) + RESPONSE=$(/var/task/lambda) + + # Necessary API Gateway response format + JSON_RESPONSE=' + { + "isBase64Encoded": false, + "statusCode": 200, + "body": "'"$RESPONSE"'" + }' + + # Send the response + curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "${JSON_RESPONSE}" +done \ No newline at end of file diff --git a/s3-uploader/runtimes/cobol/lambda/lambda.cob b/s3-uploader/runtimes/cobol/lambda/lambda.cob new file mode 100644 index 0000000000..b5e74c9426 --- /dev/null +++ b/s3-uploader/runtimes/cobol/lambda/lambda.cob @@ -0,0 +1,5 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. maxdaylambda. + PROCEDURE DIVISION. + DISPLAY "Hello from COBOL!". + STOP RUN. \ No newline at end of file diff --git a/s3-uploader/runtimes/fortran/Dockerfile b/s3-uploader/runtimes/fortran/Dockerfile new file mode 100644 index 0000000000..e26ba2713f --- /dev/null +++ b/s3-uploader/runtimes/fortran/Dockerfile @@ -0,0 +1,16 @@ +FROM amazonlinux:2 AS builder +ENV APP_BASE_DIR=/tmp +WORKDIR $APP_BASE_DIR +RUN yum install gcc-gfortran zip -y +COPY lambda lambda +WORKDIR $APP_BASE_DIR/lambda +RUN gfortran lambda.f90 -o lambda +RUN rm -f lambda.f90 +RUN mkdir lib && cp /usr/lib64/libgfortran.so.4 lib +### Only for debug +#ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APP_BASE_DIR/lambda/lib +RUN zip -r $APP_BASE_DIR/code.zip . + +FROM scratch +COPY --from=builder /tmp/code.zip /code.zip +ENTRYPOINT ["/code.zip"] \ No newline at end of file diff --git a/s3-uploader/runtimes/fortran/build.sh b/s3-uploader/runtimes/fortran/build.sh new file mode 100755 index 0000000000..c8113dea8e --- /dev/null +++ b/s3-uploader/runtimes/fortran/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +DIR_NAME="./runtimes/$1" + +if [ $2 = "x86_64" ]; then + ARCH="linux/amd64" +elif [ $2 = "arm64" ]; then + ARCH="linux/arm64/v8" +else + echo "The process architecture $2 is set incorrectly. The value can only be either x86_64 or arm64." + exit 1 +fi + +rm ${DIR_NAME}/code_${2}.zip 2> /dev/null + +docker build ${DIR_NAME} --platform ${ARCH} -t maxday/fortran_${2} +dockerId=$(docker create maxday/fortran_${2}) + +docker cp $dockerId:/code.zip ${DIR_NAME}/code_${2}.zip \ No newline at end of file diff --git a/s3-uploader/runtimes/fortran/lambda/bootstrap b/s3-uploader/runtimes/fortran/lambda/bootstrap new file mode 100755 index 0000000000..cfa07d386f --- /dev/null +++ b/s3-uploader/runtimes/fortran/lambda/bootstrap @@ -0,0 +1,36 @@ +#!/bin/sh + +set -euo pipefail + +# Processing Loop +while true +do + echo "handler: $_HANDLER" + HEADERS="$(mktemp)" + # Get an event. The HTTP request will block until one is received + EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next") + echo "event data: $EVENT_DATA" + + # Extract request ID by scraping response headers received above + REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) + echo "request id: $REQUEST_ID" + + # Execute the handler function from the script + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LAMBDA_TASK_ROOT/lib + echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" + echo "ls -lh $(pwd) (current working dir)" + echo "$(ls -lh .)" + #RESPONSE=$($_HANDLER) + RESPONSE=$(/var/task/lambda) + + # Necessary API Gateway response format + JSON_RESPONSE=' + { + "isBase64Encoded": false, + "statusCode": 200, + "body": "'"$RESPONSE"'" + }' + + # Send the response + curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "${JSON_RESPONSE}" +done \ No newline at end of file diff --git a/s3-uploader/runtimes/fortran/lambda/lambda.f90 b/s3-uploader/runtimes/fortran/lambda/lambda.f90 new file mode 100644 index 0000000000..af92c4c2a9 --- /dev/null +++ b/s3-uploader/runtimes/fortran/lambda/lambda.f90 @@ -0,0 +1,3 @@ +program maxdaylambda + print *, 'Hello from FORTRAN!' +end program maxdaylambda \ No newline at end of file diff --git a/s3-uploader/runtimes/lisp/Dockerfile b/s3-uploader/runtimes/lisp/Dockerfile new file mode 100644 index 0000000000..81beee2fc9 --- /dev/null +++ b/s3-uploader/runtimes/lisp/Dockerfile @@ -0,0 +1,14 @@ +FROM amazonlinux:2 AS builder +ENV APP_BASE_DIR=/tmp +WORKDIR $APP_BASE_DIR +RUN amazon-linux-extras install epel -y +RUN yum install sbcl zip -y +COPY lambda lambda +WORKDIR $APP_BASE_DIR/lambda +RUN sbcl --non-interactive --load lambda.lisp --eval '(sb-ext:save-lisp-and-die "lambda" :toplevel (function main) :executable t)' +RUN rm -f lambda.lisp +RUN zip -r $APP_BASE_DIR/code.zip . + +FROM scratch +COPY --from=builder /tmp/code.zip /code.zip +ENTRYPOINT ["/code.zip"] \ No newline at end of file diff --git a/s3-uploader/runtimes/lisp/build.sh b/s3-uploader/runtimes/lisp/build.sh new file mode 100755 index 0000000000..de72d18718 --- /dev/null +++ b/s3-uploader/runtimes/lisp/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +DIR_NAME="./runtimes/$1" + +if [ $2 = "x86_64" ]; then + ARCH="linux/amd64" +elif [ $2 = "arm64" ]; then + ARCH="linux/arm64/v8" +else + echo "The process architecture $2 is set incorrectly. The value can only be either x86_64 or arm64." + exit 1 +fi + +rm ${DIR_NAME}/code_${2}.zip 2> /dev/null + +docker build ${DIR_NAME} --platform ${ARCH} -t maxday/lisp_${2} +dockerId=$(docker create maxday/lisp_${2}) + +docker cp $dockerId:/code.zip ${DIR_NAME}/code_${2}.zip \ No newline at end of file diff --git a/s3-uploader/runtimes/lisp/lambda/bootstrap b/s3-uploader/runtimes/lisp/lambda/bootstrap new file mode 100755 index 0000000000..85eba29c24 --- /dev/null +++ b/s3-uploader/runtimes/lisp/lambda/bootstrap @@ -0,0 +1,34 @@ +#!/bin/sh + +set -euo pipefail + +# Processing Loop +while true +do + echo "handler: $_HANDLER" + HEADERS="$(mktemp)" + # Get an event. The HTTP request will block until one is received + EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next") + echo "event data: $EVENT_DATA" + + # Extract request ID by scraping response headers received above + REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) + echo "request id: $REQUEST_ID" + + # Execute the handler function from the script + echo "ls -lh $(pwd) (current working dir)" + echo "$(ls -lh .)" + #RESPONSE=$($_HANDLER) + RESPONSE=$(/var/task/lambda) + + # Necessary API Gateway response format + JSON_RESPONSE=' + { + "isBase64Encoded": false, + "statusCode": 200, + "body": "'"$RESPONSE"'" + }' + + # Send the response + curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "${JSON_RESPONSE}" +done \ No newline at end of file diff --git a/s3-uploader/runtimes/lisp/lambda/lambda.lisp b/s3-uploader/runtimes/lisp/lambda/lambda.lisp new file mode 100644 index 0000000000..6447af3f3c --- /dev/null +++ b/s3-uploader/runtimes/lisp/lambda/lambda.lisp @@ -0,0 +1,3 @@ +;; lambda.lisp +(defun main () + (format t "Hello from Lisp!~%")) \ No newline at end of file diff --git a/s3-uploader/runtimes/oberon/Dockerfile b/s3-uploader/runtimes/oberon/Dockerfile new file mode 100644 index 0000000000..a84b2ff227 --- /dev/null +++ b/s3-uploader/runtimes/oberon/Dockerfile @@ -0,0 +1,23 @@ +FROM amazonlinux:2 AS builder +ARG OBNC_VER=0.16.1 +ENV APP_BASE_DIR=/tmp +WORKDIR $APP_BASE_DIR +RUN yum install gc-devel gcc tar gzip SDL-devel zip -y +RUN curl -o obnc.tgz "https://miasap.se/obnc/downloads/obnc_${OBNC_VER}.tar.gz" +RUN mkdir obnc && tar -xvvzf obnc.tgz --strip-components 1 -C obnc && rm -f obnc.tgz +WORKDIR "${APP_BASE_DIR}/obnc" +RUN ./build && ./install +WORKDIR $APP_BASE_DIR +RUN rm -rf obnc +COPY lambda lambda +WORKDIR $APP_BASE_DIR/lambda +RUN mkdir lib && cp /usr/lib64/libgc.so.1 lib && cp /usr/lib64/libatomic_ops.so.1 lib +RUN obnc MaxdayLambda.Mod +RUN rm -f MaxdayLambda.Mod && rm -rf .obnc +### Only for debug +#ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APP_BASE_DIR/lambda/lib +RUN zip -r $APP_BASE_DIR/code.zip . + +FROM scratch +COPY --from=builder /tmp/code.zip /code.zip +ENTRYPOINT ["/code.zip"] \ No newline at end of file diff --git a/s3-uploader/runtimes/oberon/build.sh b/s3-uploader/runtimes/oberon/build.sh new file mode 100755 index 0000000000..dc66e6cd6a --- /dev/null +++ b/s3-uploader/runtimes/oberon/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +DIR_NAME="./runtimes/$1" + +if [ $2 = "x86_64" ]; then + ARCH="linux/amd64" +elif [ $2 = "arm64" ]; then + ARCH="linux/arm64/v8" +else + echo "The process architecture $2 is set incorrectly. The value can only be either x86_64 or arm64." + exit 1 +fi + +rm ${DIR_NAME}/code_${2}.zip 2> /dev/null + +docker build ${DIR_NAME} --platform ${ARCH} -t maxday/oberon_${2} +dockerId=$(docker create maxday/oberon_${2}) + +docker cp $dockerId:/code.zip ${DIR_NAME}/code_${2}.zip \ No newline at end of file diff --git a/s3-uploader/runtimes/oberon/lambda/MaxdayLambda.Mod b/s3-uploader/runtimes/oberon/lambda/MaxdayLambda.Mod new file mode 100644 index 0000000000..1aeeb867d1 --- /dev/null +++ b/s3-uploader/runtimes/oberon/lambda/MaxdayLambda.Mod @@ -0,0 +1,8 @@ +MODULE MaxdayLambda; + +IMPORT Out; + +BEGIN + Out.String("Hello from Oberon!"); + Out.Ln; +END MaxdayLambda. diff --git a/s3-uploader/runtimes/oberon/lambda/bootstrap b/s3-uploader/runtimes/oberon/lambda/bootstrap new file mode 100755 index 0000000000..aee37aa4c4 --- /dev/null +++ b/s3-uploader/runtimes/oberon/lambda/bootstrap @@ -0,0 +1,36 @@ +#!/bin/sh + +set -euo pipefail + +# Processing Loop +while true +do + echo "handler: $_HANDLER" + HEADERS="$(mktemp)" + # Get an event. The HTTP request will block until one is received + EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next") + echo "event data: $EVENT_DATA" + + # Extract request ID by scraping response headers received above + REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) + echo "request id: $REQUEST_ID" + + # Execute the handler function from the script + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LAMBDA_TASK_ROOT/lib + echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" + echo "ls -lh $(pwd) (current working dir)" + echo "$(ls -lh .)" + #RESPONSE=$($_HANDLER) + RESPONSE=$(/var/task/MaxdayLambda) + + # Necessary API Gateway response format + JSON_RESPONSE=' + { + "isBase64Encoded": false, + "statusCode": 200, + "body": "'"$RESPONSE"'" + }' + + # Send the response + curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "${JSON_RESPONSE}" +done \ No newline at end of file diff --git a/s3-uploader/runtimes/pascal/Dockerfile b/s3-uploader/runtimes/pascal/Dockerfile new file mode 100644 index 0000000000..a064af9035 --- /dev/null +++ b/s3-uploader/runtimes/pascal/Dockerfile @@ -0,0 +1,21 @@ +FROM amazonlinux:2 AS builder +ARG FPC_VER=3.2.2 +ENV APP_BASE_DIR=/tmp +WORKDIR $APP_BASE_DIR +RUN yum install tar gzip zip binutils expect -y +RUN curl -o fpc.tar "https://altushost-swe.dl.sourceforge.net/project/freepascal/Linux/${FPC_VER}/fpc-${FPC_VER}.$(uname -m)-linux.tar" +RUN mkdir fpc && tar -xvvf fpc.tar --strip-components 1 -C fpc && rm -f fpc.tar +WORKDIR "${APP_BASE_DIR}/fpc" +COPY unattended.exp . +RUN ./unattended.exp +WORKDIR $APP_BASE_DIR +RUN rm -rf fpc +COPY lambda lambda +WORKDIR $APP_BASE_DIR/lambda +RUN fpc lambda.pas +RUN rm -f lambda.* +RUN zip -r $APP_BASE_DIR/code.zip . + +FROM scratch +COPY --from=builder /tmp/code.zip /code.zip +ENTRYPOINT ["/code.zip"] \ No newline at end of file diff --git a/s3-uploader/runtimes/pascal/build.sh b/s3-uploader/runtimes/pascal/build.sh new file mode 100755 index 0000000000..08c7d83af5 --- /dev/null +++ b/s3-uploader/runtimes/pascal/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +DIR_NAME="./runtimes/$1" + +if [ $2 = "x86_64" ]; then + ARCH="linux/amd64" +elif [ $2 = "arm64" ]; then + ARCH="linux/arm64/v8" +else + echo "The process architecture $2 is set incorrectly. The value can only be either x86_64 or arm64." + exit 1 +fi + +rm ${DIR_NAME}/code_${2}.zip 2> /dev/null + +docker build ${DIR_NAME} --platform ${ARCH} -t maxday/pascal_${2} +dockerId=$(docker create maxday/pascal_${2}) + +docker cp $dockerId:/code.zip ${DIR_NAME}/code_${2}.zip \ No newline at end of file diff --git a/s3-uploader/runtimes/pascal/lambda/bootstrap b/s3-uploader/runtimes/pascal/lambda/bootstrap new file mode 100755 index 0000000000..85eba29c24 --- /dev/null +++ b/s3-uploader/runtimes/pascal/lambda/bootstrap @@ -0,0 +1,34 @@ +#!/bin/sh + +set -euo pipefail + +# Processing Loop +while true +do + echo "handler: $_HANDLER" + HEADERS="$(mktemp)" + # Get an event. The HTTP request will block until one is received + EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next") + echo "event data: $EVENT_DATA" + + # Extract request ID by scraping response headers received above + REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) + echo "request id: $REQUEST_ID" + + # Execute the handler function from the script + echo "ls -lh $(pwd) (current working dir)" + echo "$(ls -lh .)" + #RESPONSE=$($_HANDLER) + RESPONSE=$(/var/task/lambda) + + # Necessary API Gateway response format + JSON_RESPONSE=' + { + "isBase64Encoded": false, + "statusCode": 200, + "body": "'"$RESPONSE"'" + }' + + # Send the response + curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "${JSON_RESPONSE}" +done \ No newline at end of file diff --git a/s3-uploader/runtimes/pascal/lambda/lambda.pas b/s3-uploader/runtimes/pascal/lambda/lambda.pas new file mode 100644 index 0000000000..a50a198d0f --- /dev/null +++ b/s3-uploader/runtimes/pascal/lambda/lambda.pas @@ -0,0 +1,5 @@ +program MaxdayLambda; + +begin + writeln('Hello from Pascal!'); +end. \ No newline at end of file diff --git a/s3-uploader/runtimes/pascal/unattended.exp b/s3-uploader/runtimes/pascal/unattended.exp new file mode 100755 index 0000000000..3550f204db --- /dev/null +++ b/s3-uploader/runtimes/pascal/unattended.exp @@ -0,0 +1,9 @@ +#!/usr/bin/expect +spawn ./install.sh +expect "Install prefix" +send "\r" +expect "Install documentation" +send "n \r" +expect "Install demos" +send "n \r" +expect eof \ No newline at end of file