swift-server / swift-aws-lambda-runtime

Swift implementation of AWS Lambda Runtime
Apache License 2.0
1.12k stars 100 forks source link

[plugin] Use LAMBDA_USE_LOCAL_DEPS env var in local builds with docker #325

Closed sebsto closed 1 month ago

sebsto commented 1 month ago

Use the newly introduced LAMBDA_USE_LOCAL_DEPS environment variable inside Docker to allow to build Swift Lambda function using the local copy of the runtime

Motivation:

When developing and testing ideas on the Swift AWS Lambda Runtime, we often need to build code for deployment. The local and CI build systems have been modified to allow to reference the local filesystem version of the library, instead of the remote one on Git. It uses the LAMBDA_USE_LOCAL_DEPS to make the difference. The examples' Package.swift have been updated by https://github.com/swift-server/swift-aws-lambda-runtime/pull/292

Modifications:

This PR, adds a check in the archiver plugin to mount ../.. in the docker container rather than . when building with local dependencies. This allows to refer to the local copy of the Swift AWS Lambda runtime library from within docker.

Result:

LAMBDA_USE_LOCAL_DEPS=true swift package archive --disable-sandbox 

...

  Build complete! (5.28s)
-------------------------------------------------------------------------
archiving "MyLambda"
-------------------------------------------------------------------------
1 archive created
  * MyLambda at /Users/stormacq/<redacted>/swift-aws-lambda-runtime/Examples/Echo/.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/MyLambda/MyLambda.zip
sebsto commented 1 month ago

@tomerd WDYT ?

tomerd commented 1 month ago

lgtm

sebsto commented 1 month ago

@tomerd feel free to approve when you have time - thanks

sebsto commented 1 month ago

@tomerd can you approve and trigger a set of test? Thanks

tomerd commented 1 month ago

@swift-server-bot add to allowlist