Skip to content

Commit d4087d4

Browse files
Merge pull request #329 from chengzhinei/main
feat: malachitebft dockerfile support arm docker
2 parents 61bd343 + 12da742 commit d4087d4

2 files changed

Lines changed: 27 additions & 12 deletions

File tree

.github/release/cl.Dockerfile

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
# Use Rust Nightly version base image
2-
FROM rustlang/rust:nightly
2+
#FROM rustlang/rust:nightly
3+
FROM --platform=$BUILDPLATFORM rustlang/rust:nightly AS builder
34

45
# Set working directory
56
WORKDIR /app
67

78
# Install necessary dependencies, including protoc
89
RUN apt-get update && apt-get install -y \
910
protobuf-compiler \
11+
gcc-aarch64-linux-gnu \
12+
libc6-dev-arm64-cross \
1013
&& rm -rf /var/lib/apt/lists/*
1114

1215
# Clone project code
1316
RUN git clone https://github.com/MetisProtocol/malaketh-layered.git .
1417

18+
RUN rustup target add aarch64-unknown-linux-gnu
19+
20+
ARG TARGETARCH
21+
1522
# Build the project
16-
RUN cargo build --release
23+
RUN if [ "$TARGETARCH" = "arm64" ]; then \
24+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc; \
25+
cargo build --release --target aarch64-unknown-linux-gnu; \
26+
else \
27+
cargo build --release; \
28+
fi
1729

1830
# Copy the generated binary to a new lightweight image
19-
#FROM debian:bullseye-slim
20-
#FROM debian:bookworm-slim
21-
#FROM ubuntu:22.04
2231
FROM ubuntu:24.04
2332

2433
# Install necessary dependencies
@@ -30,11 +39,18 @@ RUN apt-get update && apt-get install -y \
3039
# Set working directory
3140
WORKDIR /app
3241

33-
# Copy the generated binary from the previous build image
34-
COPY --from=0 /app/target/release/malachitebft-eth-app /app/
35-
#COPY --from=0 /app/target/release/malachitebft-eth-cli /app/
36-
#COPY --from=0 /app/target/release/malachitebft-eth-engine /app/
37-
COPY --from=0 /app/target/release/malachitebft-eth-utils /app/
42+
ARG TARGETARCH
43+
44+
RUN if [ "$TARGETARCH" = "arm64" ]; then \
45+
echo "aarch64-unknown-linux-gnu/" > /target-subdir.txt; \
46+
else \
47+
echo "" > /target-subdir.txt; \
48+
fi
49+
50+
RUN --mount=from=builder,source=/app/target,target=/builder-target \
51+
TARGET_SUBDIR=$(cat /target-subdir.txt) && \
52+
cp /builder-target/${TARGET_SUBDIR}release/malachitebft-eth-app /app/
53+
3854

3955
# Set environment variables
4056
ENV PATH="/app:${PATH}"
@@ -44,4 +60,3 @@ EXPOSE 8545 8551 9090 3000
4460

4561
# Run the application (assuming you want to run malachitebft-eth-app here)
4662
CMD ["malachitebft-eth-app"]
47-

.github/workflows/image.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ jobs:
8888
builder: ${{ steps.buildx.outputs.name }}
8989
context: .
9090
file: .github/release/cl.Dockerfile
91-
platforms: linux/amd64
91+
platforms: linux/amd64,linux/arm64
9292
tags: ${{ steps.meta.outputs.tags }}
9393
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)