1+ # Use Alpine for a musl libc environment (for static linking)
2+ FROM rust:alpine as builder
13
2- # Use the official Rust image as base
3- FROM rust:1.81-slim-bullseye
4+ WORKDIR /app
45
5- # Create a working directory
6- WORKDIR /usr/src/app
6+ # Install build dependencies
7+ RUN apk add --no-cache musl-dev openssl-dev pkgconfig git build-base
78
8- # Install required system dependencies
9- RUN apt-get update && \
10- apt-get install -y pkg-config libssl-dev && \
11- rm -rf /var/lib/apt/lists/*
9+ # Copy the entire project
10+ COPY . .
1211
13- # Copy the Cargo.toml and Cargo.lock files
14- COPY Cargo.toml ./
12+ # Build with musl for static linking
13+ RUN rustup target add x86_64-unknown-linux-musl
14+ RUN cargo build --release --target x86_64-unknown-linux-musl
1515
16- # Copy the source code
17- COPY src/ ./src/
16+ # Use a minimal Alpine image for runtime
17+ FROM alpine:latest
1818
19- # Build the application
20- RUN cargo build --release
19+ WORKDIR /app
2120
22- # Command to run the application
23- CMD ["cargo" , "run" , "--release" ]
21+ # Install minimal runtime dependencies
22+ RUN apk add --no-cache ca-certificates
23+
24+ # Create logs directory
25+ RUN mkdir -p /app/logs
26+
27+ # Copy the statically linked binary from the builder stage
28+ COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/eigen_offchain /app/eigen_offchain
29+
30+ # Run the application with the FetchEvents command
31+ CMD ["/app/eigen_offchain" , "fetch-events" ]
0 commit comments