# Multi-stage build for AWS Lambda
# This Dockerfile creates an optimized container image for DataFold Lambda functions
# Stage 1: Builder
FROM rust:1.75-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Create a new empty shell project
RUN USER=root cargo new --bin lambda_ingestion
WORKDIR /lambda_ingestion
# Copy manifests
COPY Cargo.toml Cargo.lock ./
# Build only dependencies to cache them
RUN cargo build --release --features lambda
# Remove the placeholder source
RUN rm src/*.rs
# Copy actual source code
COPY src ./src
COPY examples ./examples
# Build the actual binary
RUN cargo build --release --features lambda --example lambda_s3_ingestion
# Stage 2: Runtime
FROM public.ecr.aws/lambda/provided:al2
# Copy the binary from builder
COPY --from=builder /lambda_ingestion/target/release/examples/lambda_s3_ingestion ${LAMBDA_RUNTIME_DIR}/bootstrap
# Set the handler (required but not used for custom runtime)
CMD ["bootstrap"]