I'm trying to use Rust for a lambda function running in AWS. To build the binary I'm using the following docker builder image.
FROM lambci/lambda:build-provided.al2
ARG RUST_VERSION=1.55.0
RUN yum install -y jq openssl-devel
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| CARGO_HOME=/cargo RUSTUP_HOME=/rustup sh -s -- -y --profile minimal --default-toolchain $RUST_VERSION --target x86_64-unknown-linux-gnu
ADD build.sh /usr/local/bin/
VOLUME ["/code"]
WORKDIR /code
RUN ["chmod", "+x", "/usr/local/bin/build.sh"]
ENTRYPOINT ["/usr/local/bin/build.sh"]
This compiles fine but when I invoke the lambda I get the error /var/task/bootstrap: /lib64/libc.so.6: version GLIBC_2.18' not found (required by /var/task/bootstrap)`
Was wondering if any one here has come across this issue before and might be able to tell me where I've gone wrong.
Once I managed to fix the issue relating to actually finding openssl it was able to build and deploy to a lambda, thank you Hyeonu for validating the musl approach was correct.
I wanted to comment as I ran into this same issue, albeit building from an AWS EC2 instance rather than Docker. This Link was very helpful, and I essentially followed it's approach:
added to Crates.toml: openssl = { version = "*", features = ["vendored"] }
Build process:
# install libssl binaries
sudo apt-get install pkg-config libssl-dev
# add unknown-linux-musl as a target
sudo apt-get install pkg-config musl-tools
rustup target add x86_64-unknown-linux-musl
# compile and zip
cargo build --target x86_64-unknown-linux-musl --release --bin my_cool_lambda
cp target/x86_64-unknown-linux-musl/release/my_cool_lambda bootstrap
zip lambda.zip bootstrap