Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Support explicitly specified artifacts e.g. fat JARs #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

enolan
Copy link
Contributor

@enolan enolan commented Mar 1, 2018

What did you implement:

Fixes #89.

How did you implement it:

We check whether the serverless.variables.service.package.artifact variable exists. If it does, it gets attached to every function object. When a function is invoked, if the artifact variable is set, the artifact is unpacked with the unzip shell command to a temporary directory .sls-simulate-unzipped. That directory is mounted into the docker container at /var/task. Otherwise the project root is mounted there.

How can we verify it:

You can pick any JVM Serverless project, whichever is easiest for you. Here's instructions for Scala/SBT

  • sls create -t aws-scala-sbt -p foo
  • Replace serverless.yml with this:
service: scala-template
provider:
  name: aws
  runtime: java8
package:
  artifact: target/scala-2.12/hello.jar
functions:
  hello:
    handler: hello.ApiGatewayHandler
    events:
      - http:
          path: hello
          method: get
plugins:
  - serverless-plugin-simulate
  • sbt assembly - You'll need to have SBT installed
  • sls simulate apigateway
  • in another terminal curl http://localhost:3000/hello

You should see this:

Serverless: Creating event
Serverless: Invoking hello
Serverless: Invoking function hello.ApiGatewayHandler
WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
START RequestId: 347d188f-702f-4838-82c5-620ad9367f17 Version: $LATEST
END RequestId: 347d188f-702f-4838-82c5-620ad9367f17
REPORT RequestId: 347d188f-702f-4838-82c5-620ad9367f17	Duration: 230.17 ms	Billed Duration: 300 ms	Memory Size: 1024 MB	Max Memory Used: 24 MB	

{"statusCode":200,"body":"Go Serverless v1.0! Your function executed successfully!","headers":{"x-custom-response-header":"my custom response header value"},"base64Encoded":true}
Serverless: Mapping response
GET /hello 200 1125.335 ms - 56

Without this PR you'll get the error from #89.

Todos:

  • Write tests
  • Write documentation - bugfixes don't need documentation
  • Fix linting errors
  • Provide verification config/commands/resources
  • Change ready for review message below

Is this ready for review?: YES

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

java.lang.ClassNotFoundException when trying to run a JVM project
2 participants