mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
build: make docker builds faster with cargo-chef (#1432)
This commit is contained in:
33
Dockerfile
33
Dockerfile
@ -1,23 +1,34 @@
|
||||
# Use rust image as the builder base
|
||||
FROM rust:1.66.0-bullseye AS builder
|
||||
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
|
||||
WORKDIR app
|
||||
|
||||
# Builds a cargo-chef plan
|
||||
FROM chef AS planner
|
||||
COPY . .
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
FROM chef AS builder
|
||||
COPY --from=planner /app/recipe.json recipe.json
|
||||
|
||||
# Set the build profile to be release
|
||||
ARG BUILD_PROFILE=release
|
||||
ENV BUILD_PROFILE $BUILD_PROFILE
|
||||
|
||||
# Update and install dependencies
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get -y upgrade && apt-get install -y libclang-dev pkg-config
|
||||
|
||||
# Copy base folder into docker context
|
||||
COPY . reth
|
||||
# Builds dependencies
|
||||
RUN cargo chef cook --profile $BUILD_PROFILE --recipe-path recipe.json
|
||||
|
||||
# Build reth
|
||||
RUN cd reth && cargo build --all --locked --profile $BUILD_PROFILE
|
||||
# Build application
|
||||
COPY . .
|
||||
RUN cargo build --profile $BUILD_PROFILE --locked --bin reth
|
||||
|
||||
# Use Ubuntu as the release image
|
||||
FROM ubuntu
|
||||
FROM ubuntu AS runtime
|
||||
WORKDIR app
|
||||
|
||||
# Copy the built reth binary from the previous stage
|
||||
COPY --from=builder /reth/target/release/reth /usr/local/bin/reth
|
||||
# Copy reth over from the build stage
|
||||
COPY --from=builder /app/target/release/reth /usr/local/bin
|
||||
|
||||
CMD ["/usr/local/bin/reth"]
|
||||
EXPOSE 30303 30303/udp 9000 8545 8546
|
||||
ENTRYPOINT ["/usr/local/bin/reth", "node"]
|
||||
|
||||
Reference in New Issue
Block a user