-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 file contains 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 file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
FROM public.ecr.aws/lambda/provided:al2-arm64 as builder | ||
# We need nightly to be able to use build-std. Alternatively, use 1.72.0. | ||
ARG RUST_VERSION=nightly-2023-11-12 | ||
ARG TARGET=aarch64-unknown-linux-gnu | ||
|
||
RUN yum install -y jq openssl-devel gcc wget tar gzip unzip \ | ||
&& yum group install -y "Development Tools" | ||
|
||
# Install a recent cmake. | ||
RUN wget https://github.com/Kitware/CMake/releases/download/v3.5.1/cmake-3.5.1.tar.gz \ | ||
&& tar -xvf cmake-3.5.1.tar.gz \ | ||
&& cd cmake-3.5.1 \ | ||
&& ./bootstrap \ | ||
&& make \ | ||
&& make install | ||
|
||
# Install profobuf (used by apollo-router). | ||
RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-aarch_64.zip \ | ||
&& unzip protoc-3.15.8-linux-aarch_64.zip -d .\ | ||
# Protobuf expects its "include" directory to be in the same directory as the binary. | ||
&& mv bin/protoc /usr/local/bin/protoc \ | ||
&& mv include /usr/local/bin/include | ||
|
||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ | ||
| sh -s -- -y --profile minimal --default-toolchain $RUST_VERSION; \ | ||
export PATH="$HOME/.cargo/bin:$PATH"; rustup component add rust-src --toolchain $RUST_VERSION | ||
|
||
# Fetch the cargo-lambda binary. | ||
RUN curl -LO https://github.com/cargo-lambda/cargo-lambda/releases/download/v0.22.0/cargo-lambda-v0.22.0.aarch64-unknown-linux-musl.tar.gz \ | ||
&& tar -xvf cargo-lambda-v0.22.0.aarch64-unknown-linux-musl.tar.gz \ | ||
&& chmod +x cargo-lambda \ | ||
&& mv cargo-lambda $HOME/.cargo/bin/cargo-lambda | ||
|
||
WORKDIR /dist/apollo-router-lambda | ||
|
||
# Build all of our dependencies. | ||
COPY Cargo.toml /dist/apollo-router-lambda/Cargo.toml | ||
COPY Cargo.lock /dist/apollo-router-lambda/Cargo.lock | ||
COPY scaffold.rs /dist/apollo-router-lambda/src/main.rs | ||
RUN export PATH="$HOME/.cargo/bin:$PATH"; \ | ||
export AWS_LAMBDA_FUNCTION_NAME="_"; \ | ||
export AWS_LAMBDA_FUNCTION_VERSION=1; \ | ||
export AWS_LAMBDA_FUNCTION_MEMORY_SIZE=1024; \ | ||
export AWS_LAMBDA_RUNTIME_API=http://[::]:9000/.rt; \ | ||
cargo lambda build --compiler cargo -Z build-std=std --target $TARGET --profile release-speed; \ | ||
rm -r src; \ | ||
# Delete the previously generated build artifacts. | ||
rm -r target/$TARGET/release/deps/apollo_router_lambda*; \ | ||
rm target/lambda/apollo-router-lambda/bootstrap | ||
|
||
# Copy our actual application code and build this. | ||
COPY src/main.rs /dist/apollo-router-lambda/src/main.rs | ||
|
||
# Build our lambda bootstrap binary. The release artifact can be found at: | ||
# /dist/apollo-router-lambda/target/lambda/apollo-router-lambda/bootstrap | ||
RUN export PATH="$HOME/.cargo/bin:$PATH"; \ | ||
cargo lambda build --compiler cargo -Z build-std=std --target $TARGET --profile release-speed |
This file contains 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