cargo lambda 构建——arm64 不适用于 al2023

问题描述 投票:0回答:1

我正在尝试使用 Amazon Linux 2023(al2023) 为 Lambda 运行时构建 Rust,因此一切都在 Docker 上运行,如下所示

# Use cargo-lambda as the build environment
FROM ghcr.io/cargo-lambda/cargo-lambda:latest as builder

# Create app directory
WORKDIR /app

# Copy the Cargo.toml and Cargo.lock files
COPY . .

# Build the release version of your application
RUN cargo lambda build --arm64 --release

# Use the AWS Lambda provided base image for custom runtimes
FROM public.ecr.aws/lambda/provided:al2023

# Copy the compiled binary from the builder stage
COPY --from=builder /app/target/lambda/user/bootstrap ${LAMBDA_RUNTIME_DIR}

# Set the CMD to your handler
CMD ["bootstrap"]

docker 文件工作正常,我可以使用

docker run --rm -it -p 9000:8080 my-rust-lambda
运行它 但是当我调用端点时,我得到了
qemu-aarch64: Could not open '/lib/ld-linux-aarch64.so.1': No such file or directory

我想念什么?

rust aws-lambda rust-cargo arm64
1个回答
0
投票

新的 Dockerfile

# Use cargo-lambda as the build environment
FROM ghcr.io/cargo-lambda/cargo-lambda:latest as builder

# Create app directory
WORKDIR /app

# Copy the Cargo.toml and Cargo.lock files
COPY . .

# Build the release version of your application
RUN cargo lambda build --arm64 --release

# Use the AWS Lambda provided base image for custom runtimes
FROM public.ecr.aws/lambda/provided:al2023

# Copy the compiled binary from the builder stage
COPY --from=builder /app/target/lambda/user/bootstrap ${LAMBDA_RUNTIME_DIR}

# Set the CMD to your handler
CMD ["bootstrap"]
© www.soinside.com 2019 - 2024. All rights reserved.