From ba443c270d25fc398339d2a92a58ffbb254c5af7 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sun, 11 May 2025 18:47:19 +0100 Subject: [PATCH] add pico --- .github/workflows/check_pico_image.yml | 36 +++++++++++++ docker/pico/Dockerfile | 23 +++++++++ scripts/sdk_installers/install_pico_sdk.sh | 60 ++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 .github/workflows/check_pico_image.yml create mode 100644 docker/pico/Dockerfile create mode 100755 scripts/sdk_installers/install_pico_sdk.sh diff --git a/.github/workflows/check_pico_image.yml b/.github/workflows/check_pico_image.yml new file mode 100644 index 0000000..a07efd1 --- /dev/null +++ b/.github/workflows/check_pico_image.yml @@ -0,0 +1,36 @@ +name: Check Pico Docker Image + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + build_pico_image: + name: Build Pico 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 Pico Docker image + run: | + docker build \ + --file docker/pico/Dockerfile \ + --tag ere-builder-pico-check:latest \ + . \ No newline at end of file diff --git a/docker/pico/Dockerfile b/docker/pico/Dockerfile new file mode 100644 index 0000000..bfedb1e --- /dev/null +++ b/docker/pico/Dockerfile @@ -0,0 +1,23 @@ +ARG BASE_IMAGE_TAG=latest +FROM ere-base:${BASE_IMAGE_TAG} + +# The ere-base image provides Rust, Cargo, and common tools. +# We operate as root for SDK installation. + +# Copy the Pico SDK installer script from the workspace context +COPY scripts/sdk_installers/install_pico_sdk.sh /tmp/install_pico_sdk.sh +RUN chmod +x /tmp/install_pico_sdk.sh + +# Run the Pico SDK installation script. +# This script installs the specific Rust toolchain (nightly-2024-11-27) +# and installs pico-cli (as cargo-pico). +# The CARGO_HOME from ere-base (e.g., /root/.cargo) will be used, and cargo-pico will be in its bin. +RUN /tmp/install_pico_sdk.sh && rm /tmp/install_pico_sdk.sh # Clean up the script + +# Define the Pico toolchain for convenience in subsequent commands if needed, though cargo pico should use it. +ENV PICO_TOOLCHAIN_VERSION="nightly-2024-11-27" + +# Verify Pico installation +RUN echo "Verifying Risc0 installation in Dockerfile (post-script)..." && cargo "+${PICO_TOOLCHAIN_VERSION}" pico --version + +CMD ["/bin/bash"] \ No newline at end of file diff --git a/scripts/sdk_installers/install_pico_sdk.sh b/scripts/sdk_installers/install_pico_sdk.sh new file mode 100755 index 0000000..c15acbd --- /dev/null +++ b/scripts/sdk_installers/install_pico_sdk.sh @@ -0,0 +1,60 @@ +#!/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 Brevis Pico Toolchain..." + +ensure_tool_installed "rustup" "to manage Rust toolchains" +ensure_tool_installed "git" "to install pico-cli from a git repository" +ensure_tool_installed "cargo" "to build and install Rust packages" + +PICO_TOOLCHAIN_VERSION="nightly-2024-11-27" + +# Install the specific nightly toolchain for Pico +echo "Installing Pico-specific Rust toolchain: ${PICO_TOOLCHAIN_VERSION}..." +rustup install "${PICO_TOOLCHAIN_VERSION}" +rustup component add rust-src --toolchain "${PICO_TOOLCHAIN_VERSION}" + +# Install pico-cli using the specified toolchain +# cargo-pico is a cargo subcommand, typically installed to $HOME/.cargo/bin +echo "Installing pico-cli from GitHub repository (brevis-network/pico)..." +cargo "+${PICO_TOOLCHAIN_VERSION}" install --git https://github.com/brevis-network/pico pico-cli + +# Verify pico-cli installation +echo "Verifying pico-cli installation..." +# The pico-cli is installed as `cargo-pico`, so it's invoked as `cargo pico` +if cargo "+${PICO_TOOLCHAIN_VERSION}" pico --version; then + echo "pico-cli (cargo pico) installation verified successfully." +else + echo "Error: 'cargo pico --version' failed. pico-cli might not have installed correctly." >&2 + echo " Ensure ${HOME}/.cargo/bin is in your PATH for new shells." >&2 + exit 1 +fi + +# TODO: Maybe remove this, We likely always will use `cargo pico` +echo "Brevis Pico Toolchain and pico-cli installation successful." +echo "The specified Rust toolchain (${PICO_TOOLCHAIN_VERSION}) is installed." +echo "pico-cli (as cargo-pico) is installed and should be available via 'cargo pico ...' using the above toolchain." +echo "For pico-cli to be globally available as 'cargo pico' without the +toolchain specifier," +echo "you might need to set ${PICO_TOOLCHAIN_VERSION} as your default toolchain for the project/directory or globally if desired," +echo "or ensure your project's rust-toolchain.toml specifies this version." \ No newline at end of file