-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfileTools
More file actions
67 lines (53 loc) · 2.63 KB
/
DockerfileTools
File metadata and controls
67 lines (53 loc) · 2.63 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
FROM lukemathwalker/cargo-chef:latest-rust-1.92 AS chef
WORKDIR /app
LABEL org.opencontainers.image.source=https://github.com/okx/xlayer-reth
LABEL org.opencontainers.image.licenses="MIT OR Apache-2.0"
RUN apt-get update && apt-get -y upgrade && apt-get install -y libclang-dev pkg-config
# Builds a cargo-chef plan
FROM chef AS planner
COPY . .
# Remove test-only workspace members that are excluded from the Docker context
RUN sed -i '/"crates\/tests"/d' Cargo.toml
RUN cargo chef prepare --recipe-path recipe.json --bin xlayer-reth-tools
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
ARG BUILD_PROFILE=release
ENV BUILD_PROFILE=$BUILD_PROFILE
ARG RUSTFLAGS=""
ENV RUSTFLAGS="$RUSTFLAGS"
ARG FEATURES=""
ENV FEATURES=$FEATURES
# Git metadata for vergen (optional - only used when .git is not available)
ARG VERGEN_GIT_SHA
ARG VERGEN_GIT_COMMIT_TIMESTAMP
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/app/target \
if [ -n "$VERGEN_GIT_SHA" ]; then export VERGEN_GIT_SHA="$VERGEN_GIT_SHA"; fi && \
if [ -n "$VERGEN_GIT_COMMIT_TIMESTAMP" ]; then export VERGEN_GIT_COMMIT_TIMESTAMP="$VERGEN_GIT_COMMIT_TIMESTAMP"; fi && \
cargo chef cook --profile $BUILD_PROFILE --features "$FEATURES" --recipe-path recipe.json --manifest-path /app/bin/tools/Cargo.toml
COPY . .
# Remove test-only workspace members that are excluded from the Docker context
RUN sed -i '/"crates\/tests"/d' Cargo.toml
RUN if [ -d .cargo/reth ]; then \
mv .cargo/reth /reth; \
else \
mkdir -p /reth; \
fi
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/app/target \
if [ -n "$VERGEN_GIT_SHA" ]; then export VERGEN_GIT_SHA="$VERGEN_GIT_SHA"; fi && \
if [ -n "$VERGEN_GIT_COMMIT_TIMESTAMP" ]; then export VERGEN_GIT_COMMIT_TIMESTAMP="$VERGEN_GIT_COMMIT_TIMESTAMP"; fi && \
cargo build --profile $BUILD_PROFILE --features "$FEATURES" --bin xlayer-reth-tools --manifest-path /app/bin/tools/Cargo.toml && \
OUTPUT_DIR=$(if [ "$BUILD_PROFILE" = "dev" ] || [ "$BUILD_PROFILE" = "test" ]; then echo debug; else echo "$BUILD_PROFILE"; fi) && \
cp /app/target/$OUTPUT_DIR/xlayer-reth-tools /app/xlayer-reth-tools
FROM ubuntu:24.04 AS runtime
RUN apt-get update && \
apt-get install -y ca-certificates libssl-dev pkg-config strace curl && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/xlayer-reth-tools /usr/local/bin/
RUN chmod +x /usr/local/bin/xlayer-reth-tools
COPY LICENSE* ./
ENTRYPOINT ["/usr/local/bin/xlayer-reth-tools"]