Last active
September 1, 2021 17:47
-
-
Save ceejbot/748cc7aaac61f5b31594c0642cadd625 to your computer and use it in GitHub Desktop.
fast notes on how to build and test rust lambdas in local dev on a mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this goes into your ~/.cargo/config file | |
[target.x86_64-unknown-linux-musl] | |
linker = "x86_64-linux-musl-gcc" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# install the musl-cross build environment | |
brew install filosottile/musl-cross/musl-cross | |
# symlink | |
ln -s /usr/local/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc | |
# install the target toolchain | |
rustup target add x86_64-unknown-linux-musl | |
# build the lambda | |
cargo build --target x86_64-unknown-linux-musl | |
# start a docker container replicating the "provided" lambda runtime | |
# put your lambda into `bootstrap` | |
mkdir -p /tmp/lambda && \ | |
cp target/x86_64-unknown-linux-musl/debug/your-lambda /tmp/lambda/bootstrap && \ | |
docker run -i -e DOCKER_LAMBDA_USE_STDIN=1 \ | |
--rm \ | |
-v /tmp/lambda:/var/task \ | |
lambci/lambda:provided | |
# send your json blob input to STDIN somehow (paste or script output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment