diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4792db7d3..f2e5d2132 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,13 +4,15 @@ # is released on GitHub. # -FROM rust:1.75 +# amd64: Solana 1.17 has no prebuilt aarch64-linux binaries. +FROM --platform=linux/amd64 rust:1.75 ARG DEBIAN_FRONTEND=noninteractive -ARG SOLANA_CLI="1.17.16" +# Keep in sync with Anchor.toml. +ARG SOLANA_CLI="1.17.34" ARG ANCHOR_CLI="0.29.0" -ARG NODE_VERSION="v18.16.0" +ARG NODE_VERSION="v20.18.0" ENV HOME="/root" ENV PATH="${HOME}/.cargo/bin:${PATH}" @@ -41,17 +43,21 @@ RUN . $NVM_DIR/nvm.sh && \ npm install -g yarn # Install Solana tools. -RUN sh -c "$(curl -sSfL https://release.solana.com/v${SOLANA_CLI}/install)" +RUN curl -sSfL "https://release.anza.xyz/v${SOLANA_CLI}/install" -o /tmp/solana-install.sh && \ + sh /tmp/solana-install.sh && \ + rm /tmp/solana-install.sh # Install anchor. -RUN cargo install --git https://github.com/coral-xyz/anchor avm --locked --force -RUN avm install ${ANCHOR_CLI} && avm use ${ANCHOR_CLI} +RUN cargo install --git https://github.com/coral-xyz/anchor --tag v${ANCHOR_CLI} anchor-cli --locked # set up keypair -RUN solana-keygen new --no-bip39-passphrase +RUN solana-keygen new --no-bip39-passphrase && \ + solana config set --url localhost + +# zsh +RUN apt-get update -qq && apt-get install -qq zsh && \ + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended && \ + chsh -s /usr/bin/zsh root WORKDIR /workdir -#be sure to add `/root/.avm/bin` to your PATH to be able to run the installed binaries -# install dependencies -RUN yarn \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index dae163bfb..13320e5c2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,3 +1,29 @@ { - "build": { "dockerfile": "Dockerfile" }, + "name": "MetaDAO Programs", + "build": { + "dockerfile": "Dockerfile", + "platform": "linux/amd64" + }, + "workspaceMount": "source=${localWorkspaceFolder},target=/workdir,type=bind,consistency=cached", + "workspaceFolder": "/workdir", + "remoteUser": "root", + "mounts": [ + "source=metadao-target,target=/workdir/target,type=volume,consistency=delegated" + ], + "customizations": { + "vscode": { + "extensions": [ + "rust-lang.rust-analyzer", + "tamasfe.even-better-toml" + ] + } + }, + "forwardPorts": [8899, 8900], + "portsAttributes": { + "8899": { "label": "Solana Test Validator" }, + "8900": { "label": "Solana Test Validator RPC" } + }, + "containerEnv": { + "ANCHOR_WALLET": "/root/.config/solana/id.json" + } } diff --git a/README.md b/README.md index d14e0bcc3..6a5690f6d 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,17 @@ Before you can build and test the programs, you'll need to install the following - **Node.js**: 16.x or higher (tested with v23.x) - **Yarn**: 1.22.22 or compatible +### Dev Container + +The repository ships a dev container with all of the above preinstalled. With Docker running, open the repo in VS Code / Zed / Cursor and choose "Reopen in Container", then: + +```bash +yarn install +anchor build +``` + +Note: the image is pinned to `linux/amd64`, so builds on Apple Silicon run under emulation and are slower than a native setup. + ### MacOS Setup #### 1. Clone the Repository