Skip to content
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 solana inside docker container for servers that don't have cargo #116

Merged
merged 4 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
36 changes: 36 additions & 0 deletions dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM rust:1.63.0

# Add Google Protocol Buffers for Libra's metrics library.
ENV PROTOC_VERSION 3.8.0
ENV PROTOC_ZIP protoc-$PROTOC_VERSION-linux-x86_64.zip

RUN set -x \
&& apt update \
&& apt install -y \
clang \
cmake \
libudev-dev \
make \
unzip \
libssl-dev \
pkg-config \
zlib1g-dev \
make \
&& rustup component add rustfmt \
&& rustup component add clippy \
&& rustc --version \
&& cargo --version \
&& curl -OL https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP \
&& unzip -o $PROTOC_ZIP -d /usr/local bin/protoc \
&& unzip -o $PROTOC_ZIP -d /usr/local include/* \
&& rm -f $PROTOC_ZIP


# Uses docker buildkit to cache the image.
# /usr/local/cargo/git needed for crossbeam patch
WORKDIR /solana
COPY . .
RUN --mount=type=cache,mode=0777,target=/solana/target \
--mount=type=cache,mode=0777,target=/usr/local/cargo/registry \
--mount=type=cache,mode=0777,target=/usr/local/cargo/git \
cargo build --verbose --release --bin solana-validator && cp target/release/solana-validator ./solana-validator
20 changes: 20 additions & 0 deletions f
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env sh
# Builds jito-solana in a docker container.
# Useful for running on machines that might not have cargo installed but can run docker (Flatcar Linux).
set -eux

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"

DOCKER_BUILDKIT=1 docker build \
-t jitolabs/build-solana \
-f dev/Dockerfile . \
--progress=plain

# Creates a temporary container, copies solana-validator built inside container there and
# removes the temporary container.
docker rm temp || true
docker container create --name temp jitolabs/build-solana
mkdir -p $SCRIPT_DIR/docker-output
# Outputs the solana-validator binary to $SOLANA/docker-output/solana-validator
docker container cp temp:/solana/solana-validator $SCRIPT_DIR/docker-output/solana-validator
docker rm temp