-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: New install script and container wrappers. #3617
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.terraform | ||
.terraform* | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# The Aztec Installation Script | ||
|
||
``` | ||
bash -i <(curl -s install.aztec.network) | ||
``` | ||
|
||
That is all. | ||
|
||
This will install into `~/.aztec/bin` a collection of scripts to help running aztec containers, and will update | ||
a users `PATH` variable in their shell startup script so they can be found. | ||
|
||
- `aztec` - The infrastructure container. | ||
- `aztec-cli` - A command line tool for interacting with infrastructure. | ||
- `aztec-nargo` - A build of `nargo` from `noir` that is guaranteed to be version aligned. Provides compiler, lsp and more. | ||
- `aztec-sandbox` - A wrapper around docker-compose that launches services needed for sandbox testing. | ||
- `aztec-up` - A tool to upgrade the aztec toolchain to the latest, or specific versions. | ||
|
||
After installed, you can use `aztec-up` to upgrade or install specific versions. | ||
|
||
``` | ||
VERSION=master aztec-up | ||
``` | ||
|
||
This will install the container built from master branch. | ||
|
||
``` | ||
VERSION=v1.2.3 aztec-up | ||
``` | ||
|
||
This will install tagged release version 1.2.3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/usr/bin/env bash | ||
# The script starts a Docker container passing any commands and arguments to the command running inside the container. | ||
# It handles mounting paths into the container. | ||
# It handles networking comms back to the host. | ||
set -euo pipefail | ||
|
||
IMAGE=${1:-} | ||
shift | ||
|
||
VERSION=${VERSION:-"latest"} | ||
|
||
# Any host bindings we might send to the container. | ||
DOCKER_HOST_BINDS="" | ||
|
||
# Volumes to pass to the container. | ||
DOCKER_VOLUME="" | ||
|
||
if ! command -v docker &> /dev/null; then | ||
echo "No docker found." | ||
exit 1 | ||
fi | ||
|
||
# Colors. | ||
yellow="\033[33m" | ||
reset="\033[0m" | ||
|
||
# Set up host.docker.internal alias on Linux, just like it is on mac. | ||
UNAME=$(uname -s) | ||
if [ "$UNAME" == "Linux" ]; then | ||
if docker info 2>/dev/null | grep -q rootless; then | ||
# We're in rootless docker. Probe for the host ip and use that. | ||
ip=$(hostname -I | head | tr -d ' ') | ||
echo -e "${yellow}WARNING: Running within rootless docker. Using $ip as host ip. Ensure listening services are listening on this interface.${reset}" | ||
DOCKER_HOST_BINDS="$DOCKER_HOST_BINDS --add-host host.docker.internal:$ip" | ||
else | ||
DOCKER_HOST_BINDS="$DOCKER_HOST_BINDS --add-host host.docker.internal:host-gateway" | ||
fi | ||
fi | ||
|
||
# Build a list of mount points | ||
function add_mount() { | ||
DIR="${1:-}" | ||
|
||
# Grab its dirname if its a file. | ||
if [ -f "$DIR" ]; then | ||
DIR=$(dirname "$DIR") | ||
fi | ||
|
||
if [ ! -d "$DIR" ]; then | ||
return | ||
fi | ||
|
||
# Check if it's already been added. | ||
REALDIR=$(realpath $DIR) | ||
if [[ "$DOCKER_VOLUME" =~ "$REALDIR:" ]]; then | ||
return | ||
fi | ||
|
||
DOCKER_VOLUME="$DOCKER_VOLUME -v $REALDIR:$REALDIR" | ||
} | ||
|
||
# Always mount the CWD into the container. | ||
add_mount "$PWD" | ||
|
||
# Substitute any references to localhost with our host gateway. | ||
args=("$@") | ||
for i in "${!args[@]}"; do | ||
args[$i]=${args[$i]//localhost/host.docker.internal} | ||
done | ||
|
||
# Check if it's either a filename or a directory that exists outside the CWD. | ||
# If it is then mount inside the container. | ||
# NOTE: This won't work with assignement-style flags, e.g. --outdir=/foo | ||
for i in "${!args[@]}"; do | ||
arg=${args[$i]} | ||
if [[ -f "$arg" || -d "$arg" && $(realpath $arg) != ${PWD}* ]]; then | ||
add_mount "$arg" | ||
fi | ||
done | ||
|
||
DOCKER_ENV="" | ||
for env in ${ENV_VARS_TO_INJECT:-}; do | ||
# First substitute any reference to localhost with our host gateway. | ||
env=${env//localhost/host.docker.internal} | ||
# Inject into container. | ||
DOCKER_ENV+="-e $env:${!env:-} " | ||
done | ||
|
||
DOCKER_VOLUME="$DOCKER_VOLUME -v cache:/cache" | ||
|
||
docker run \ | ||
-ti \ | ||
--rm \ | ||
--user $(id -u):$(id -g) \ | ||
--workdir "$PWD" \ | ||
$DOCKER_HOST_BINDS \ | ||
$DOCKER_ENV \ | ||
$DOCKER_VOLUME \ | ||
$IMAGE:$VERSION ${args[@]:-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
$(dirname $0)/.aztec-run aztecprotocol/aztec-sandbox $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
# TODO: Make compile command always be wasm. Or put nargo in container. Or probe. | ||
# TODO: Make unbox fail if trying to unbox outside of the cwd. | ||
set -euo pipefail | ||
|
||
export ENV_VARS_TO_INJECT="PXE_URL PRIVATE_KEY DEBUG" | ||
export PXE_URL=${PXE_URL:-"http://host.docker.internal:8080"} | ||
|
||
$(dirname $0)/.aztec-run aztecprotocol/cli $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# Colors | ||
g="\033[32m" # Green | ||
y="\033[33m" # Yellow | ||
b="\033[34m" # Blue | ||
p="\033[35m" # Purple | ||
r="\033[0m" # Reset | ||
bold="\033[1m" | ||
|
||
# Function to replace characters and add color | ||
function print_colored() { | ||
local b=$'\033[34m' # Blue | ||
local y=$'\033[33m' # Yellow | ||
local r=$'\033[0m' # Reset | ||
echo "$1" | sed -E "s/(█+)/${b}\1${y}/g" | ||
} | ||
|
||
function title() { | ||
echo | ||
print_colored " █████╗ ███████╗████████╗███████╗ ██████╗" | ||
print_colored "██╔══██╗╚══███╔╝╚══██╔══╝██╔════╝██╔════╝" | ||
print_colored "███████║ ███╔╝ ██║ █████╗ ██║" | ||
print_colored "██╔══██║ ███╔╝ ██║ ██╔══╝ ██║" | ||
print_colored "██║ ██║███████╗ ██║ ███████╗╚██████╗" | ||
print_colored "╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝" | ||
echo -e "${r}" | ||
echo -e "Welcome to the ${bold}${b}Aztec${r} installer! Your journey into blockchain privacy begins... ${bold}${p}now${r}." | ||
echo -e "We presently leverage docker to simplify releases of our complex project." | ||
echo -e "Please ensure it's installed for your platform: https://docs.docker.com/engine/install" | ||
echo | ||
echo -e "This will install the following scripts and update your PATH if necessary:" | ||
echo -e " ${bold}${g}aztec${r} - launches various infrastructure subsystems (sequencer, prover, pxe, etc)." | ||
echo -e " ${bold}${g}aztec-cli${r} - a command line tool for interfacing and experimenting with infrastructure." | ||
echo -e " ${bold}${g}aztec-nargo${r} - aztec's build of nargo, the noir compiler toolchain." | ||
echo -e " ${bold}${g}aztec-sandbox${r} - a wrapper around docker-compose that launches services needed for sandbox testing." | ||
echo -e " ${bold}${g}aztec-up${r} - a tool to upgrade the aztec toolchain to the latest, or specific versions." | ||
echo | ||
read -p "Do you wish to continue? (y/n)" -n 1 -r | ||
echo | ||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then | ||
exit 0 | ||
fi | ||
} | ||
|
||
function info { | ||
echo -e "${g}$1${r}" | ||
} | ||
|
||
function warn { | ||
echo -e "${y}$1${r}" | ||
} | ||
|
||
AZTEC_PATH=$HOME/.aztec | ||
BIN_PATH=$AZTEC_PATH/bin | ||
|
||
# Define version if specified, otherwise set to "latest". | ||
VERSION=${VERSION:-"latest"} | ||
INSTALL_HOST=install.aztec.network.s3-website.eu-west-2.amazonaws.com | ||
|
||
[ -z "${SKIP_TITLE:-}" ] && title | ||
|
||
# Check if Docker is available. | ||
if ! command -v docker &>/dev/null; then | ||
warn "Docker is not installed. Please install Docker and try again." | ||
exit 1 | ||
fi | ||
|
||
# Check if Docker is running. | ||
if ! docker info &>/dev/null; then | ||
warn "Docker is not running. Please start Docker and try again." | ||
exit 1 | ||
fi | ||
|
||
if ! docker compose &>/dev/null && ! command -v docker-compose &>/dev/null; then | ||
warn "WARNING: 'docker compose' not supported and docker-compose not found." | ||
warn "Continuing installation, but aztec-sandbox will not work." | ||
fi | ||
|
||
# Create a "hidden" `$HOME/.aztec` dir, so as not to clutter the user's cwd. | ||
rm -f $BIN_PATH/* && mkdir -p $BIN_PATH | ||
|
||
# Download containers from dockerhub. Tag them as latest. | ||
function pull_container { | ||
docker pull aztecprotocol/$1:$VERSION | ||
|
||
# If not latest, retag to be latest so it runs from scripts. | ||
if [ $VERSION != "latest" ]; then | ||
docker tag aztecprotocol/$1:$VERSION aztecprotocol/$1:latest | ||
fi | ||
} | ||
|
||
info "Pulling aztec version $VERSION..." | ||
pull_container aztec-sandbox | ||
pull_container cli | ||
pull_container noir | ||
|
||
# Download the Docker Compose file. Used by aztec-start. | ||
curl -fsSL http://$INSTALL_HOST/docker-compose.yml -o $BIN_PATH/docker-compose.yml | ||
|
||
function install_bin { | ||
curl -fsSL http://$INSTALL_HOST/$1 -o $BIN_PATH/$1 | ||
chmod +x $BIN_PATH/$1 | ||
echo "Installed: $BIN_PATH/$1" | ||
} | ||
|
||
info "Installing scripts in $BIN_PATH..." | ||
install_bin .aztec-run | ||
install_bin aztec | ||
install_bin aztec-cli | ||
install_bin aztec-sandbox | ||
install_bin aztec-up | ||
install_bin aztec-nargo | ||
|
||
function update_path_env_var { | ||
TARGET_DIR="${1}" | ||
# Check if the target directory is in the user's PATH. | ||
if [[ ":$PATH:" != *":$TARGET_DIR:"* ]]; then | ||
# Determine the user's shell. | ||
SHELL_PROFILE="" | ||
case $SHELL in | ||
*/bash) | ||
SHELL_PROFILE="$HOME/.bashrc" | ||
;; | ||
*/zsh) | ||
SHELL_PROFILE="$HOME/.zshrc" | ||
;; | ||
# Add other shells as needed | ||
*) | ||
echo "Unsupported shell: $SHELL" | ||
return | ||
;; | ||
esac | ||
# Inform the user about the change and ask for confirmation | ||
warn "The directory $TARGET_DIR is not in your PATH." | ||
read -p "Add it to $SHELL_PROFILE to make the aztec binaries accessible? (y/n)" -n 1 -r | ||
echo | ||
if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
# Add the target directory to the user's PATH in their profile. | ||
echo "export PATH=\$PATH:$TARGET_DIR" >> "$SHELL_PROFILE" | ||
info "Done! Starting fresh shell..." | ||
$SHELL | ||
else | ||
warn "Skipped updating PATH. You might need to add $TARGET_DIR to your PATH manually to use the binary." | ||
fi | ||
fi | ||
} | ||
|
||
update_path_env_var $BIN_PATH | ||
|
||
info "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
$(dirname $0)/.aztec-run aztecprotocol/noir $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# Change working dir, so relative volume mounts are in the right place. | ||
cd ~/.aztec | ||
|
||
# Favour 'docker compose', falling back on docker-compose. | ||
CMD="docker compose" | ||
$CMD &>/dev/null || CMD="docker-compose" | ||
|
||
$CMD -f ~/.aztec/bin/docker-compose.yml up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
export SKIP_TITLE=1 | ||
bash -i <(curl -s http://install.aztec.network) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
version: '3' | ||
services: | ||
ethereum: | ||
image: ghcr.io/foundry-rs/foundry@sha256:29ba6e34379e79c342ec02d437beb7929c9e254261e8032b17e187be71a2609f | ||
entrypoint: > | ||
sh -c ' | ||
if [ -n "$FORK_BLOCK_NUMBER" ] && [ -n "$FORK_URL" ]; then | ||
exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 --silent --fork-url "$FORK_URL" --fork-block-number "$FORK_BLOCK_NUMBER" | ||
elif [ -n "$FORK_URL" ]; then | ||
exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 --silent --fork-url "$FORK_URL" | ||
else | ||
exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 --silent | ||
fi' | ||
ports: | ||
- '${SANDBOX_ANVIL_PORT:-8545}:8545' | ||
|
||
aztec: | ||
image: 'aztecprotocol/aztec-sandbox' | ||
ports: | ||
- '${SANDBOX_AZTEC_NODE_PORT:-8079}:8079' | ||
- '${SANDBOX_PXE_PORT:-8080}:8080' | ||
environment: | ||
DEBUG: # Loaded from the user shell if explicitly set | ||
HOST_WORKDIR: '${PWD}' # Loaded from the user shell to show log files absolute path in host | ||
ETHEREUM_HOST: http://ethereum:8545 | ||
CHAIN_ID: 31337 | ||
ARCHIVER_POLLING_INTERVAL_MS: 50 | ||
P2P_BLOCK_CHECK_INTERVAL_MS: 50 | ||
SEQ_TX_POLLING_INTERVAL_MS: 50 | ||
WS_BLOCK_CHECK_INTERVAL_MS: 50 | ||
PXE_BLOCK_POLLING_INTERVAL_MS: 50 | ||
ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 | ||
volumes: | ||
- ./log:/usr/src/yarn-project/aztec-sandbox/log:rw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
set -e | ||
|
||
BRANCH=$1 | ||
|
||
export TF_VAR_BRANCH=$BRANCH | ||
|
||
# Downloads and installs `terraform` if it's not installed. | ||
if [ ! -f /usr/local/bin/terraform ]; then | ||
cd $HOME | ||
TERRAFORM_VERSION=1.5.2 | ||
curl -sSL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o terraform.zip | ||
sudo apt install -y unzip | ||
unzip terraform.zip | ||
sudo mv terraform /usr/local/bin/ | ||
rm terraform.zip | ||
cd - | ||
fi | ||
|
||
echo "Initializing terraform" | ||
terraform init -input=false -backend-config="key=aztec-sandbox-website/$BRANCH" | ||
|
||
echo "Applying terraform config" | ||
terraform apply -input=false -auto-approve |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should mention
aztec-sandbox
too in this list?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!