Sign inSign up

anyakichi/lambda-rust-builder

By anyakichi

•Updated about 1 year ago

Image
0

1.5K

anyakichi/lambda-rust-builder repository overview

⁠docker-lambda-rust-builder

Docker build environment for Rust Runtime for AWS Lambda

⁠How to use

$ mkdir workspace && cd workspace
$ docker run -it --rm \
    -v "$(pwd):/build" \
    -w "/build" \
    -h "$(basename "$(pwd)")" \
    anyakichi/lambda-rust-builder
[builder@workspace build]$ extract
[builder@workspace build]$ setup
[builder@workspace lambda-rust-sample]$ build
[builder@workspace lambda-rust-sample]$ package

You can use the din⁠ wrapper script for simplicity.

$ mkdir workspace && cd workspace
$ din anyakichi/lambda-rust-builder
[builder@workspace build]$ extract
[builder@workspace build]$ setup
[builder@workspace lambda-rust-sample]$ build
[builder@workspace lambda-rust-sample]$ package

If you want to share cargo caches with host environment, add extra options.

$ din -e CARGO_HOME=/cargo -v $HOME/.cargo:/cargo anyakichi/lambda-rust-builder
[builder@workspace build]$ build

By default, sample lambda program (https://github.com/anyakichi/lambda-rust-sample.git⁠) is downloaded and compiled, but you can override it:

$ din -e GIT_REPO=<your-repo> anyakichi/lambda-rust-builder

Or you can build your own Docker build environment with Dockerfile.

FROM anyakichi/lambda-rust-builder
ENV GIT_REPO=<your-repo>

⁠Sub commands

⁠extract

Download project repository using git clone.

⁠setup

Move to project repository.

⁠build

Build the binary.

⁠package

Create a zip file to upload to Lambda.

⁠run

Run the lambda function in Docker container.

If you use the run sub command, publish port 9001 to host environment.

$ din -p 9001:9001 anyakichi/lambda-rust-builder
[builder@workspace build]$ run

And access to this from host environment.

$ curl -d '{}' http://localhost:9001/2015-03-31/functions/myfunction/invocations
⁠(other commands)

And you can execute anything in the container.

Build debug binary:

[builder@workspace lambda-rust-sample]$ cargo build

Run lambda handler passing data from stdin:

[builder@workspace lambda-rust-sample]$ echo '{}' \
  | DOCKER_LAMBDA_USE_STDIN=1 /var/runtime/init -bootstrap "target/release/lambda-rust-sample"

⁠Direct mode

You can execute sub commands directly from din command.

$ din -p 9001:9001 anyakichi/lambda-rust-builder run

⁠See also

https://github.com/anyakichi/docker-buildenv⁠

Tag summary

Content type

Image

Digest

sha256:a65b4c073…

Size

524 MB

Last updated

about 1 year ago

docker pull anyakichi/lambda-rust-builder:al2-rustup