-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: drive binary build script #2031
base: feat/reproducibleBuilds
Are you sure you want to change the base?
Changes from all commits
c96519f
5d3b487
8f06714
a892dd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Use the official Rust image based on Debian Bullseye 1.76-bullseye | ||
FROM rust@sha256:607b5e64b8d51f78ac5a37984e64f6493e9a7f90b605fa068be86ff035f48141 | ||
|
||
# Install necessary packages | ||
RUN apt-get update && apt-get install -y \ | ||
clang \ | ||
cmake \ | ||
git \ | ||
wget \ | ||
bash \ | ||
unzip \ | ||
&& if [[ "$TARGETARCH" == "arm64" ]] ; then apt-get install -y gcc-aarch64-linux-gnu; fi \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Add Rust target | ||
RUN if [[ "$TARGETARCH" == "arm64" ]] ; then RUST_TARGET=aarch64-unknown-linux-gnu; else RUST_TARGET=x86_64-unknown-linux-gnu; fi; \ | ||
rustup target add ${RUST_TARGET} | ||
|
||
# Install protoc - protobuf compiler | ||
ARG PROTOC_VERSION="25.2" | ||
RUN if [[ "$TARGETARCH" == "arm64" ]] ; then export PROTOC_ARCH=aarch_64; else export PROTOC_ARCH=x86_64; fi; \ | ||
curl -Ls https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip \ | ||
-o /tmp/protoc.zip && \ | ||
unzip -qd /opt/protoc /tmp/protoc.zip && \ | ||
rm /tmp/protoc.zip && \ | ||
ln -s /opt/protoc/bin/protoc /usr/bin/ | ||
|
||
# Set the working directory inside the container | ||
WORKDIR /app | ||
Comment on lines
+1
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is duplicative of this file no? https://github.com/dashpay/platform/blob/392934b6d881fb94f2ca8233f131fa3e12c31afb/packages/rs-drive-abci/Dockerfile.repro There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, this is replacement |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
FULL_PATH=$(realpath "$0") | ||
DIR_PATH=$(dirname "$FULL_PATH") | ||
ROOT_PATH=$(dirname "$DIR_PATH") | ||
|
||
IMAGE_NAME="rust-build-env" | ||
|
||
# Function to build the Docker image if it doesn't exist | ||
build_docker_image() { | ||
echo "Building Docker image $IMAGE_NAME..." | ||
docker buildx build -t $IMAGE_NAME \ | ||
-f "$ROOT_PATH/Dockerfile.rust-build" \ | ||
--platform linux/amd64,linux/arm64 \ | ||
--load \ | ||
"$ROOT_PATH" | ||
} | ||
|
||
# Function to build and strip the binary for a specific target | ||
build() { | ||
local target=$1 | ||
local output_name=$2 | ||
local arch=$3 | ||
|
||
echo "Building Drive for target ${target}..." | ||
docker run --rm \ | ||
-v "$ROOT_PATH:/app" \ | ||
-w /app \ | ||
-u "$(id -u):$(id -g)" \ | ||
--platform "$arch" \ | ||
"$IMAGE_NAME" \ | ||
cargo build --release \ | ||
--locked \ | ||
--target "$target" \ | ||
-p drive-abci | ||
|
||
echo "Renaming output binary to ${output_name}..." | ||
mv "$ROOT_PATH/target/$target/release/drive-abci" "$ROOT_PATH/$output_name" | ||
|
||
echo "Creating tar.gz archive for $output_name..." | ||
tar -czf "$ROOT_PATH/$output_name.tar.gz" "$ROOT_PATH/$output_name" | ||
} | ||
|
||
# Main script | ||
main() { | ||
build_docker_image | ||
|
||
# Build for x86_64 | ||
build x86_64-unknown-linux-gnu drive-abci-linux-gnu-x86_64 linux/amd64 | ||
|
||
# Build for aarch64 | ||
build aarch64-unknown-linux-gnu drive-abci-linux-gnu-aarch64 linux/arm64 | ||
|
||
echo "Release process completed successfully." | ||
} | ||
|
||
main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
justify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are recovering panics in Drive ABCI
https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html