question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow packaging of static files alongside binary

See original GitHub issue

💡 Feature description

It would be nice if it was possible to use the include and exclude package configuration in serverless.yml to choose other files to bundle with the bootstrap binary. For example to include a .env file that is then read by the dotenv crate at runtime.

I am sure that there are other use cases for including files other than the binary but that is the one that sprang to mind.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

10reactions
nickspellcommented, Jun 8, 2019

An alternative solution to the static file packaging problem is to use AWS Lambda Layers. Just put your static files into some directory at the root of your project and create a layer from that.

Example:

myservice
├── static
│   ├── foo.json
├── src
├── serverless.yml

In your serverless.yml insert:

layers:
  mydata:
    path: static
    description: My static json data

In your function you can put the dependency on your layer as a title cased reference:

functions:
  myfunction:
    handler: #...
    layers: 
       - {Ref: MydataLambdaLayer}
     # .....

You can now access your files as if they are located in the “/opt” folder of your lambda, e.g.:

let file = File::open("/opt/foo.json")?;

This solution is quite useful especially when you want to share your static data between different lambdas.

2reactions
softpropscommented, Jun 4, 2020

Without more expertise in opencv I cant gaurantee this will work but to answer the question about using layers to package host dependencies, that’s almost the sole use of layers https://aws.amazon.com/blogs/aws/new-for-aws-lambda-use-any-programming-language-and-share-common-components/

That said this is likely an easier case for interpreted languages im not sure if you can package and dynamically link via env var with rust. I glanced through the opencv docs and there was some suggestions that you could

Read more comments on GitHub >

github_iconTop Results From Across the Web

The easiest way to embed static files into a binary file in your ...
The easiest way to embed static files into a binary file in your Golang app (no external dependencies). Just git clone and read...
Read more >
Embedding static files in a go binary using go embed
I have been using packages like pkgr and packr to make it easier to embed static files in go binaries. We'll explore the...
Read more >
Bundling static files in binary : r/rust - Reddit
In Golang, there are libraries that allow you to embed the static files of your project into a single binary (go.rice, packr, go-bindata)....
Read more >
How to serve static files from a compiled binary? #2005 - GitHub
I don't think you need to put anything IN the binary to achieve that, you can simply zip templates and static files together...
Read more >
Embedding static files in Go binaries | by Tiago Temporin
Released in version 1.16, the embed package gives us a new directive to help ... BIG binaries, which can be a bigger problem...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found