From 893df214e1d4bc9e4f52a0ddae8d1a7675081037 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sun, 11 May 2025 19:09:15 +0100 Subject: [PATCH] add jolt --- .github/workflows/check_jolt_image.yml | 36 +++++++++++++++++ docker/jolt/Dockerfile | 20 +++++++++ scripts/sdk_installers/install_jolt_sdk.sh | 47 ++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 .github/workflows/check_jolt_image.yml create mode 100644 docker/jolt/Dockerfile create mode 100644 scripts/sdk_installers/install_jolt_sdk.sh diff --git a/.github/workflows/check_jolt_image.yml b/.github/workflows/check_jolt_image.yml new file mode 100644 index 0000000..14d6a46 --- /dev/null +++ b/.github/workflows/check_jolt_image.yml @@ -0,0 +1,36 @@ +name: Check Jolt Docker Image + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + build_jolt_image: + name: Build Jolt Docker Image + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build dependent Docker base image + run: | + docker build \ + --file docker/base/Dockerfile.base \ + --tag ere-base:latest \ + . + + - name: Build Jolt Docker image + run: | + docker build \ + --file docker/jolt/Dockerfile \ + --tag ere-builder-jolt-check:latest \ + . \ No newline at end of file diff --git a/docker/jolt/Dockerfile b/docker/jolt/Dockerfile new file mode 100644 index 0000000..ee4a6a4 --- /dev/null +++ b/docker/jolt/Dockerfile @@ -0,0 +1,20 @@ +ARG BASE_IMAGE_TAG=latest +FROM ere-base:${BASE_IMAGE_TAG} + +# The ere-base image provides Rust, Cargo (with a default nightly), and common tools. +# We operate as root for SDK installation. + +# Copy the Jolt SDK (CLI) installer script from the workspace context +COPY scripts/sdk_installers/install_jolt_sdk.sh /tmp/install_jolt_sdk.sh +RUN chmod +x /tmp/install_jolt_sdk.sh + +# Run the Jolt CLI installation script. +# This script installs the 'jolt' binary to $CARGO_HOME/bin. +RUN /tmp/install_jolt_sdk.sh && rm /tmp/install_jolt_sdk.sh # Clean up the script + +# The jolt CLI is installed in $CARGO_HOME/bin, which is already in PATH from ere-base. + +# Verify jolt CLI is accessible. +RUN jolt --version + +CMD ["/bin/bash"] \ No newline at end of file diff --git a/scripts/sdk_installers/install_jolt_sdk.sh b/scripts/sdk_installers/install_jolt_sdk.sh new file mode 100644 index 0000000..a03075b --- /dev/null +++ b/scripts/sdk_installers/install_jolt_sdk.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +# --- Utility functions (duplicated) --- +# Checks if a tool is installed and available in PATH. +is_tool_installed() { + command -v "$1" &> /dev/null +} + +# Ensures a tool is installed. Exits with an error if not. +ensure_tool_installed() { + local tool_name="$1" + local purpose_message="$2" + if ! is_tool_installed "${tool_name}"; then + echo "Error: Required tool '${tool_name}' could not be found." >&2 + if [ -n "${purpose_message}" ]; then + echo " It is needed ${purpose_message}." >&2 + fi + echo " Please install it first and ensure it is in your PATH." >&2 + exit 1 + fi +} +# --- End of Utility functions --- + +echo "Installing Jolt CLI..." + +ensure_tool_installed "rustup" "to manage Rust toolchains (though Jolt uses default nightly)" +ensure_tool_installed "git" "to install Jolt from a git repository" +ensure_tool_installed "cargo" "to build and install Rust packages" + +# Install Jolt CLI using cargo install with +nightly +# This installs the 'jolt' binary directly to $HOME/.cargo/bin +# The ere-base image should have a compatible default nightly toolchain. +echo "Installing Jolt CLI from GitHub repository (a16z/jolt)..." +cargo +nightly install --git https://github.com/a16z/jolt --force --bins jolt + +# Verify Jolt installation +echo "Verifying Jolt CLI installation..." +if jolt --version; then + echo "Jolt CLI installation verified successfully." +else + echo "Error: 'jolt --version' failed. Jolt CLI might not have installed correctly." >&2 + echo " Ensure ${HOME}/.cargo/bin is in your PATH for new shells." >&2 + exit 1 +fi + +echo "Jolt CLI installation successful." \ No newline at end of file