Skip to content

Commit

Permalink
Initial version of the template
Browse files Browse the repository at this point in the history
  • Loading branch information
pfreitag committed Nov 28, 2018
1 parent 0341b8d commit 92096c1
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
jars/*.jar
.gradle
31 changes: 31 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'java'

archivesBaseName = 'fuseless-template'

repositories {
mavenCentral()
}

dependencies {
compile (
'com.amazonaws.serverless:aws-serverless-java-container-core:1.2',
'javax.servlet.jsp:javax.servlet.jsp-api:2.3.1',
'javax.el:javax.el-api:3.0.0',
'com.amazonaws:aws-lambda-java-core:1.2.0',
'com.amazonaws:aws-lambda-java-log4j:1.0.0',
'org.slf4j:slf4j-log4j12:1.7.25'
)
compile fileTree(dir: 'jars', include: '*.jar')
}

task buildZip(type: Zip) {
from compileJava
from processResources
from 'cfml/'
into('lib') {
from configurations.runtime
}

}

build.dependsOn buildZip
21 changes: 21 additions & 0 deletions cfml/app/Application.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
component {

this.name="cfmlServerless";
this.sessionManagement=false;
this.clientManagement=false;
this.setClientCookies=false;

public function onRequest(string path) {
include arguments.path;
}

public function getLambdaContext() {
//see https://docs.aws.amazon.com/lambda/latest/dg/java-context-object.html
return getPageContext().getRequest().getAttribute("lambdaContext");
}

public void function logger(string msg) {
getLambdaContext().getLogger().log(arguments.msg);
}

}
3 changes: 3 additions & 0 deletions cfml/app/dump.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<cfdump var="#server.lucee#" label="server.lucee Dump">
<cfdump var="#getLambdaContext()#" label="getLambdaContext()">

30 changes: 30 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

if [[ !$LUCEE_VERSION ]]; then
LUCEE_VERSION=5.3.1.87-RC
fi

if [[ !$FUSELESS_VERSION ]]; then
FUSELESS_VERSION="0.0.6"
fi

if [ -f "jars/lucee-light-$LUCEE_VERSION.jar" ]; then
echo "lucee-light-$LUCEE_VERSION.jar already in jars folder, skipping download"
else
#download lucee jar
echo "Downloading lucee-light-$LUCEE_VERSION.jar"
curl --location -o jars/lucee-light-$LUCEE_VERSION.jar https://cdn.lucee.org/lucee-light-$LUCEE_VERSION.jar
fi


if [ -f "jars/foundeo-fuseless-$FUSELESS_VERSION.jar" ]; then
echo "foundeo-fuseless-$FUSELESS_VERSION.jar already in jars folder, skipping download"
else
#download lucee jar
echo "Downloading foundeo-fuseless-$FUSELESS_VERSION.jar"
curl --location -o jars/foundeo-fuseless-$FUSELESS_VERSION.jar https://github.com/foundeo/fuseless/releases/download/v$FUSELESS_VERSION/foundeo-fuseless-$FUSELESS_VERSION.jar
fi

echo ""
echo "Jars are in place, next make sure you have gradle installed: https://gradle.org/install/"

10 changes: 10 additions & 0 deletions jars/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
In this folder there should be at least two jar files:

- lucee-version.jar [download](https://download.lucee.org/)

- foundeo-fuseless-version.jar [download](https://github.com/foundeo/fuseless/releases/latest)

You can run the `init.sh` script if you are on mac or linux and it will download the jars for you.

You can add additional jars and they will be automatically added to the distribution. Or better yet modify the `../build.gradle` file to add your dependencies.

4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# FuseLess Template

A Template for building CFML powered AWS Lambda Functions.

24 changes: 24 additions & 0 deletions template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31

Resources:
FuselessTemplate:
Type: AWS::Serverless::Function
Properties:
Handler: com.foundeo.fuseless.StreamLambdaHandler
CodeUri: ./build/distributions/fuseless-template.zip
Runtime: java8
Timeout: 10
MemorySize: 256
Events:
GetResource:
Type: Api
Properties:
Path: /{proxy+}
Method: any
Environment:
Variables:
FELIX_CACHE_BUFSIZE: 16384



0 comments on commit 92096c1

Please sign in to comment.