From 46e0eac99d6f15743e6b944be759932d7b5a060f Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Fri, 12 Jul 2024 09:27:24 -0700 Subject: [PATCH] Use docker image and add make targets --- Makefile | 9 ++ contrib/localnet/docker-compose.yml | 4 +- contrib/localnet/solana/Dockerfile | 12 ++ contrib/localnet/solana/Dockerfile.solana | 134 ---------------------- 4 files changed, 24 insertions(+), 135 deletions(-) create mode 100644 contrib/localnet/solana/Dockerfile delete mode 100644 contrib/localnet/solana/Dockerfile.solana diff --git a/Makefile b/Makefile index c929aea7f8..4fdba4d882 100644 --- a/Makefile +++ b/Makefile @@ -230,6 +230,10 @@ install-zetae2e: go.sum @go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetae2e .PHONY: install-zetae2e +solana: + @echo "Building solana docker image" + $(DOCKER) build -t solana-local -f contrib/localnet/solana/Dockerfile contrib/localnet/solana/ + start-e2e-test: zetanode @echo "--> Starting e2e test" cd contrib/localnet/ && $(DOCKER) compose up -d @@ -254,6 +258,11 @@ start-stress-test: zetanode @echo "--> Starting stress test" cd contrib/localnet/ && $(DOCKER) compose --profile stress -f docker-compose.yml up -d +start-solana-test: zetanode solana + @echo "--> Starting solana test" + export E2E_ARGS="--test-solana" && \ + cd contrib/localnet/ && $(DOCKER) compose --profile solana -f docker-compose.yml up -d + ############################################################################### ### Upgrade Tests ### ############################################################################### diff --git a/contrib/localnet/docker-compose.yml b/contrib/localnet/docker-compose.yml index ed5ec34d01..6c87ee0aa9 100644 --- a/contrib/localnet/docker-compose.yml +++ b/contrib/localnet/docker-compose.yml @@ -184,6 +184,9 @@ services: image: solana-local:latest container_name: solana hostname: solana + profiles: + - solana + - all ports: - "8899:8899" networks: @@ -191,7 +194,6 @@ services: ipv4_address: 172.20.0.102 entrypoint: [ "/usr/bin/start-solana.sh" ] - eth: image: ethereum/client-go:v1.10.26 container_name: eth diff --git a/contrib/localnet/solana/Dockerfile b/contrib/localnet/solana/Dockerfile new file mode 100644 index 0000000000..fec6d8c75e --- /dev/null +++ b/contrib/localnet/solana/Dockerfile @@ -0,0 +1,12 @@ +FROM ghcr.io/zeta-chain/solana-docker:1.18.15 + +WORKDIR /data +COPY ./start-solana.sh /usr/bin/start-solana.sh +RUN chmod +x /usr/bin/start-solana.sh +COPY ./gateway.so . +COPY ./gateway-keypair.json . + + + +ENTRYPOINT [ "bash" ] +CMD [ "/usr/bin/start-solana.sh" ] \ No newline at end of file diff --git a/contrib/localnet/solana/Dockerfile.solana b/contrib/localnet/solana/Dockerfile.solana deleted file mode 100644 index a969706f11..0000000000 --- a/contrib/localnet/solana/Dockerfile.solana +++ /dev/null @@ -1,134 +0,0 @@ -# Dockerfile -# solana-docker-mac-m1 -# -# Created by Raphael Tang on 12/6/2023. -# Licensed 2023 under MIT. All rights reserved. - -# ________ ________ ___ ________ ________ ________ -# |\ ____\|\ __ \|\ \ |\ __ \|\ ___ \|\ __ \ -# \ \ \___|\ \ \|\ \ \ \ \ \ \|\ \ \ \\ \ \ \ \|\ \ -# \ \_____ \ \ \\\ \ \ \ \ \ __ \ \ \\ \ \ \ __ \ -# \|____|\ \ \ \\\ \ \ \____\ \ \ \ \ \ \\ \ \ \ \ \ \ -# ____\_\ \ \_______\ \_______\ \__\ \__\ \__\\ \__\ \__\ \__\ -# |\_________\|_______|\|_______|\|__|\|__|\|__| \|__|\|__|\|__| -# \|_________| -# -# This Dockerfile contains a definition for a container which builds Solana from source -# in the build process. It should work on other operating systems too, but don't quote me on that. - -# Set directory used for all build generated files -ARG CUBICLE=/root -# Set your solana version here -ARG SOLANA_VERSION=1.18.15 -# Set folder name for intermediary files during build step -ARG BUILD_OUTPUT_DIR=${CUBICLE}/solana-output - -FROM --platform=linux/arm64 debian:stable-slim as base - -SHELL [ "/bin/bash", "-c" ] - -RUN apt update && \ - apt-get install -y \ - curl wget neovim fish \ - pkg-config bzip2 \ - && \ - rm -rf /var/lib/apt/lists/* - -# Container for building the solana binaries -FROM base as builder -ARG CUBICLE -ARG SOLANA_VERSION -ARG BUILD_OUTPUT_DIR - -RUN apt update && \ - apt-get install -y \ - build-essential \ - libssl-dev libudev-dev clang \ - gcc zlib1g-dev llvm cmake make \ - libprotobuf-dev protobuf-compiler \ - perl libfindbin-libs-perl \ - && \ - rm -rf /var/lib/apt/lists/* - -# Fetch solana source code -WORKDIR ${CUBICLE} -RUN if [[ "${SOLANA_VERSION}" == "latest" ]] ;\ - then \ - wget -O solana.tar.gz \ - https://github.com/solana-labs/solana/archive/refs/heads/master.tar.gz ;\ - else \ - wget -O solana.tar.gz \ - https://github.com/solana-labs/solana/archive/refs/tags/v${SOLANA_VERSION}.tar.gz ;\ - fi -RUN mkdir solana && \ - tar --extract --verbose --gzip --file solana.tar.gz --strip-components=1 --directory solana - -# Setup rust with compatible version -RUN source solana/ci/rust-version.sh && \ - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain "$rust_stable" -ENV PATH=${CUBICLE}/.cargo/bin:$PATH - -# Build Solana binaries -WORKDIR ${CUBICLE}/solana -# FIXME: --validator-only is a temporary fix for -# [solana-labs/solana issue 31528](https://github.com/solana-labs/solana/issues/31528) -RUN ./scripts/cargo-install-all.sh "${BUILD_OUTPUT_DIR}" --validator-only -RUN cargo build --bin solana-test-validator --release -RUN cd "${BUILD_OUTPUT_DIR}/bin" && "${CUBICLE}/solana/fetch-spl.sh" -RUN cp -f scripts/run.sh "${BUILD_OUTPUT_DIR}/bin/run-cluster" -RUN cp -f fetch-spl.sh "${BUILD_OUTPUT_DIR}/bin/" -RUN cp -f target/release/solana-test-validator "${BUILD_OUTPUT_DIR}/bin/" - -# Final resulting multipurpose container -FROM base as final -ARG CUBICLE -ARG SOLANA_VERSION -ARG BUILD_OUTPUT_DIR - -COPY --from=builder ${BUILD_OUTPUT_DIR} /usr/ - -# RPC JSON -EXPOSE 8899/tcp -# RPC pubsub -EXPOSE 8900/tcp -# entrypoint -EXPOSE 8001/tcp -# (future) bank service -EXPOSE 8901/tcp -# bank service -EXPOSE 8902/tcp -# faucet -EXPOSE 9900/tcp -# tvu -EXPOSE 8000/udp -# gossip -EXPOSE 8001/udp -# tvu_forwards -EXPOSE 8002/udp -# tpu -EXPOSE 8003/udp -# tpu_forwards -EXPOSE 8004/udp -# retransmit -EXPOSE 8005/udp -# repair -EXPOSE 8006/udp -# serve_repair -EXPOSE 8007/udp -# broadcast -EXPOSE 8008/udp -# tpu_vote -EXPOSE 8009/udp - -RUN apt-get install -y bash - -WORKDIR /data -COPY ./start-solana.sh /usr/bin/start-solana.sh -RUN chmod +x /usr/bin/start-solana.sh -COPY ./gateway.so . -COPY ./gateway-keypair.json . - - - -ENTRYPOINT [ "bash" ] -CMD [ "/usr/bin/start-solana.sh" ] \ No newline at end of file