Skip to content

Commit

Permalink
Manually set up AWS env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehnix committed Nov 12, 2023
1 parent 6b6b570 commit 7f85d29
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 4 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,18 @@ _build-lambda-directly-optimized-arm:
#!/usr/bin/env bash
set -euxo pipefail
cd lambda-directly-optimized
mkdir -p arm
docker buildx build -f Dockerfile-arm --platform linux/arm64 -t lambda-directly-optimized:lambda-arm .
export TMP_IMAGE_ID=$(docker create --platform linux/arm64 lambda-directly:lambda-arm)
export TMP_IMAGE_ID=$(docker create --platform linux/arm64 lambda-directly-optimized:lambda-arm)
docker cp $TMP_IMAGE_ID:/dist/apollo-router-lambda/target/lambda/apollo-router-lambda/bootstrap arm/bootstrap
docker rm -v $TMP_IMAGE_ID
_build-lambda-directly-optimized-x86:
#!/usr/bin/env bash
set -euxo pipefail
cd lambda-directly-optimized
mkdir -p x86
docker buildx build -f Dockerfile-x86 --platform linux/amd64 -t lambda-directly-optimized:lambda-x86 .
export TMP_IMAGE_ID=$(docker create --platform linux/amd64 lambda-directly:lambda-x86)
export TMP_IMAGE_ID=$(docker create --platform linux/amd64 lambda-directly-optimized:lambda-x86)
docker cp $TMP_IMAGE_ID:/dist/apollo-router-lambda/target/lambda/apollo-router-lambda/bootstrap x86/bootstrap
docker rm -v $TMP_IMAGE_ID
10 changes: 9 additions & 1 deletion lambda-directly-optimized/Dockerfile-arm-graviton
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ WORKDIR /dist/apollo-router-lambda
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 RUSTFLAGS="-Ctarget-feature=+lse -Ctarget-cpu=neoverse-n1 -Zlocation-detail=none -Zthreads=8"; cargo lambda build --compiler cargo -Z build-std=std --target $TARGET --release; rm -r src; target/lambda/apollo-router-lambda/bootstrap
RUN export PATH="$HOME/.cargo/bin:$PATH"; \
export RUSTFLAGS="-Ctarget-feature=+lse -Ctarget-cpu=neoverse-n1 -Zlocation-detail=none -Zthreads=8"; \
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 --release; \
rm -r src; \
rm target/lambda/apollo-router-lambda/bootstrap

# Copy our actual application code and build this.
COPY src /dist/apollo-router-lambda/src
Expand Down
14 changes: 12 additions & 2 deletions lambda-directly-optimized/Dockerfile-x86
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,21 @@ WORKDIR /dist/apollo-router-lambda
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 RUSTFLAGS="-Zlocation-detail=none -Zthreads=8"; cargo lambda build --compiler cargo -Z build-std=std --target $TARGET --release; rm -r src; target/lambda/apollo-router-lambda/bootstrap
RUN export PATH="$HOME/.cargo/bin:$PATH"; \
export RUSTFLAGS="-Zlocation-detail=none -Zthreads=8"; \
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 --release; \
rm -r src; \
rm target/lambda/apollo-router-lambda/bootstrap

# Copy our actual application code and build this.
COPY src /dist/apollo-router-lambda/src

# 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"; export RUSTFLAGS="-Zlocation-detail=none -Zthreads=8"; cargo lambda build --compiler cargo -Z build-std=std --target $TARGET --release
RUN export PATH="$HOME/.cargo/bin:$PATH"; \
export RUSTFLAGS="-Zlocation-detail=none -Zthreads=8"; \
cargo lambda build --compiler cargo -Z build-std=std --target $TARGET --release

0 comments on commit 7f85d29

Please sign in to comment.