Skip to content
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

docker-only install experience #2875

Closed
alexghr opened this issue Oct 16, 2023 · 5 comments · Fixed by #3031
Closed

docker-only install experience #2875

alexghr opened this issue Oct 16, 2023 · 5 comments · Fixed by #3031
Assignees

Comments

@alexghr
Copy link
Contributor

alexghr commented Oct 16, 2023

In order to provide a seamless install experience to aztec-sandbox users we should consider offering a dockerized version of aztec-cli so that users can get up and running without having to install node/npm/yarn.

We'd have to deploy the aztec-cli to docker hub and create a wrapper script around it that starts a container and delegates commands to it. The wrapper will have to manage mount points in order to ensure compiling contracts works (and the compiled artifacts are available on the host computer). We'll also need to consider how to handle updates to the underlying cli image.

Needs #2644

@alexghr alexghr self-assigned this Oct 16, 2023
@PhilWindle
Copy link
Collaborator

Sounds good!

@rahul-kothari
Copy link
Contributor

rahul-kothari commented Oct 16, 2023

Do users need to do docker exec to run aztec-cli then? If so - add a script (like charlie suggested in the call)?

Also can make some of the pains referenced in #2870 go away

@alexghr
Copy link
Contributor Author

alexghr commented Oct 16, 2023

Do users need to do docker exec to run aztec-cli then? If so - add a script (like charlie suggested in the call)?

we'd provide a wrapper-script that manages the container for the user. The script would provide the same interface as the cli.

@charlielye
Copy link
Contributor

The dockerfile would specify entrypoint as aztec-cli, (globally installed in the container) meaning the wrapper script would then look something like:

#!/bin/sh
docker run -ti --rm -v <mount paths> aztecprotocol/aztec-sandbox $@

The only tricky thing here, is where to install the wrapper script. Even in unix there's no standard user bin folder, and requiring root or sudo to install it into /usr/bin or /usr/local/bin is a no go.

So our sandbox install script will need to do something like (a few gpt prompts later):

#!/bin/bash

# Define the binary's source path
BINARY_SRC_PATH="/path/to/your/binary"

# Define the target directory
TARGET_DIR="$HOME/.local/bin"

# Check if the target directory exists, if not create it
if [ ! -d "$TARGET_DIR" ]; then
    mkdir -p "$TARGET_DIR"
fi

# Copy the binary to the target directory
cp "$BINARY_SRC_PATH" "$TARGET_DIR"

# 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"
            exit 1
            ;;
    esac

    # Inform the user about the change and ask for confirmation
    echo "The directory $TARGET_DIR is not in your PATH."
    echo "We'd like to add it to your $SHELL_PROFILE to make the binary accessible."
    read -p "Do you want to proceed? (y/n) " -n 1 -r
    echo    # Move to a new line
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        # Add the target directory to the user's PATH in their profile
        echo "export PATH=\$PATH:$TARGET_DIR" >> "$SHELL_PROFILE"
        echo "Updated PATH in $SHELL_PROFILE"
    else
        echo "Skipped updating PATH. You might need to add $TARGET_DIR to your PATH manually to use the binary."
    fi
else
    echo "Installation complete!"
fi

@alexghr alexghr linked a pull request Oct 26, 2023 that will close this issue
4 tasks
alexghr added a commit that referenced this issue Oct 30, 2023
This PR dockerizes aztec-cli. It requires #2737 to be merged in first.

Fix #2875 

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [x] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [x] Every change is related to the PR description.
- [x] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
@alexghr
Copy link
Contributor Author

alexghr commented Oct 30, 2023

Docker image and script merged in but this still needs the install script. See https://github.com/AztecProtocol/sandbox-website/pull/24

@alexghr alexghr reopened this Oct 30, 2023
alexghr added a commit that referenced this issue Oct 30, 2023
In #3031 I forgot to push the CLI docker image to dockerhub. This fixes
that and also updates the name of the expected docker image in the bash
wrapper script to match.

Related #2875 

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [x] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [x] Every change is related to the PR description.
- [x] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
@alexghr alexghr closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants