Skip to content

Commit

Permalink
Merge pull request #617 from OffchainLabs/macos-docs
Browse files Browse the repository at this point in the history
Update documentation how to build nitro locally, add instructions for MacOS
  • Loading branch information
symbolpunk authored Sep 26, 2023
2 parents 5492e36 + b1a65fc commit 16240f8
Showing 1 changed file with 89 additions and 25 deletions.
114 changes: 89 additions & 25 deletions arbitrum-docs/node-running/how-tos/build-nitro-locally.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'How to build Nitro locally (Docker, Debian)'
sidebar_label: Build Nitro locally (Docker, Debian)
description: This how-to will help you build Nitro locally using Docker on Debian.
title: 'How to build Nitro locally (Debian, Ubuntu, MacOS)'
sidebar_label: Build Nitro locally (Debian, Ubuntu, MacOS)
description: This how-to provides step-by-step instructions for building Nitro locally using Docker on Debian, Ubuntu, or MacOS.
author: amsanghi
content-type: how-to
---
Expand All @@ -10,16 +10,42 @@ import PublicPreviewBannerPartial from '../../partials/_public-preview-banner-pa

<PublicPreviewBannerPartial />

This how-to is based on [Debian 11.7 (arm64)](https://cdimage.debian.org/cdimage/archive/11.7.0/arm64/iso-cd/debian-11.7.0-arm64-netinst.iso) and [Ubuntu 22.04 (amd64)](https://releases.ubuntu.com/22.04.2/ubuntu-22.04.2-desktop-amd64.iso).
This how-to assumes that you're running one of the following operating systems:

- [Debian 11.7 (arm64)](https://cdimage.debian.org/cdimage/archive/11.7.0/arm64/iso-cd/debian-11.7.0-arm64-netinst.iso)
- [Ubuntu 22.04 (amd64)](https://releases.ubuntu.com/22.04.2/ubuntu-22.04.2-desktop-amd64.iso)
- [MacOS Ventura 13.4](https://developer.apple.com/documentation/macos-release-notes/macos-13_4-release-notes).

### 1. Configure prerequisites

#### For Debian/Ubuntu

```bash
apt install git curl build-essential cmake npm golang clang make gotestsum wabt lld-13
npm install --global yarn
ln -s /usr/bin/wasm-ld-13 /usr/local/bin/wasm-ld
```

#### For MacOS

Install [Homebrew](https://brew.sh/) package manager and add it to your `PATH` environment variable:

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zprofile && source ~/.zprofile
```

(replace `~/.zprofile` with `~/.bash_profile` if you use bash instead of zsh).

Install essentials:

```bash
brew install git curl make cmake npm go gvm golangci-lint wabt llvm gotestsum
npm install --global yarn
sudo mkdir -p /usr/local/bin
sudo ln -s /opt/homebrew/opt/llvm/bin/wasm-ld /usr/local/bin/wasm-ld
```

### 2. Configure Nitro

```bash
Expand All @@ -30,54 +56,92 @@ git submodule update --init --recursive --force

### 3. Configure Node [16.19](https://github.com/nvm-sh/nvm)

#### For Debian/Ubuntu

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
source "$HOME/.bashrc"
nvm install 16.19
nvm use 16.19
```

### 4. Configure Rust [1.66.1](https://www.rust-lang.org/tools/install)
#### For MacOS

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 16.19
nvm use 16.19
```

### 4. Configure Rust [1.72.1](https://www.rust-lang.org/tools/install)

```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
rustup install 1.66.1
rustup default 1.66.1
rustup target add wasm32-unknown-unknown --toolchain 1.66.1
rustup target add wasm32-wasi --toolchain 1.66.1
rustup install 1.72.1
rustup default 1.72.1
rustup target add wasm32-unknown-unknown --toolchain 1.72.1
rustup target add wasm32-wasi --toolchain 1.72.1
cargo install cbindgen
```

### 5. Configure [Docker](https://docs.docker.com/engine/install/debian/)
### 5. Configure [Docker](https://docs.docker.com/engine/install)

#### For [Debian](https://docs.docker.com/engine/install/debian)/[Ubuntu](https://docs.docker.com/engine/install/ubuntu)

```bash
apt-get remove docker docker-engine docker.io containerd runc
apt-get update
apt-get install ca-certificates curl gnupg
mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
service docker start
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo service docker start
```

### 6. Configure Go [1.19.5](https://github.com/moovweb/gvm)
#### For [MacOS](https://docs.docker.com/desktop/install/mac-install/)

Depending on whether your Mac has an Intel processor or Apple silicon, download the corresponding disk image from [Docker](https://docs.docker.com/desktop/install/mac-install/), and move it into your Applications folder.

### 6. Configure Go [1.20](https://github.com/moovweb/gvm)

#### Install Bison

##### For Debian/Ubuntu

```bash
sudo apt-get install bison
```

##### For MacOS

```bash
brew install bison
```

#### Install and configure Go

```bash
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source "$HOME/.gvm/scripts/gvm"
apt-get install bison
gvm install go1.19.5
gvm use 1.19.5 --default
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2
gvm install go1.20
gvm use go1.20 --default
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2
```

If you use zsh, replace `bash` with `zsh`.

### 7. Start build

```bash
Expand Down

1 comment on commit 16240f8

@vercel
Copy link

@vercel vercel bot commented on 16240f8 Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.