-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (24 loc) · 1.07 KB
/
Dockerfile
File metadata and controls
32 lines (24 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Multi-stage build for AWS Lambda Rust deployment
# Build stage with Cargo Lambda pre-installed
FROM --platform=$BUILDPLATFORM ghcr.io/cargo-lambda/cargo-lambda:latest AS build
ARG TARGETPLATFORM
WORKDIR /build
# Copy only the files needed for build first (better caching)
COPY Cargo.toml Cargo.lock ./
COPY .cargo ./.cargo
COPY src ./src
# Determine the target architecture and build
RUN case ${TARGETPLATFORM:-linux/amd64} in \
"linux/amd64") RUST_ARCH=x86_64-unknown-linux-gnu ;; \
"linux/arm64") RUST_ARCH=aarch64-unknown-linux-gnu ;; \
*) RUST_ARCH=x86_64-unknown-linux-gnu ;; \
esac \
&& cargo lambda build --release --target ${RUST_ARCH}
# Runtime stage using AWS Lambda provided runtime
FROM public.ecr.aws/lambda/provided:al2023 AS runtime
# Copy the bootstrap file (Lambda expects this exact name)
COPY --from=build /build/target/lambda/community-liquidator-rs/bootstrap ${LAMBDA_RUNTIME_DIR}/bootstrap
# Optional: Copy any additional files needed at runtime
# COPY config ./config
# Set the handler name (matches the Lambda function handler)
CMD ["function.handler"]