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

Feat/more robust installer #787

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Conversation

PatrickAlphaC
Copy link
Member

Improved the install script for working with docker containers and CI/CD pipelines.

Changes

Here's a rationale for each change:

set -eo pipefail instead of just set -e:

Makes the script more robust by failing if any part of a pipeline fails, not just the last command. Helpful for catching errors in commands like curl or sh

Added BASE_DIR="${XDG_CONFIG_HOME:-$HOME}":

Follows XDG Base Directory Specification. You can see this that follows foundry's more recent improvements. It respects user preferences for config locations, instead of just dropping right into $HOME

Changed CYFRIN_DIR="$HOME/.cyfrin" to CYFRIN_DIR="${CYFRIN_DIR:-"$BASE_DIR/.cyfrin"}":

Allows users to customize installation directory via environment variable

Changed .zshrc to .zshenv and added ${ZDOTDIR-"$HOME"}:

.zshenv is loaded for all shell types (interactive, non-interactive, login, scripts), whereas .zshrc is only loaded for interactive shells, meaning it won't be loaded for scripts, Docker containers, or other non-interactive environments where PATH modifications might be needed.

Added ash shell support:

Matches Foundry's shell support

Added Fish shell-specific PATH modification:

Matches Foundry's shell support

Added immediate PATH export:

Makes the tool immediately available in current session so that we can use it in a docker environment where each shell is dropped between commands.

How to test

  1. Make sure you have docker installed and the daemon running
  2. Create a new directory and a Dockerfile file
  3. Place the following contents in it, this is the current way you'd setup your docker container with the current install script.
# Base debian build (latest).
FROM mcr.microsoft.com/vscode/devcontainers/base:debian

# Update packages.
RUN apt-get update

# Set the default shell to zsh
ENV SHELL=/usr/bin/zsh

# Running everything under zsh
SHELL ["/usr/bin/zsh", "-c"]

# Dropping privileges
USER vscode

# Install rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && source $HOME/.cargo/env

# Install cyfrinup - you'll see this fails
RUN curl -L https://raw.githubusercontent.com/Cyfrin/aderyn/dev/cyfrinup/install | zsh
RUN cyfrinup 
  1. Attempt to start up a docker container with cyfrinup/aderyn, it will fail
docker build -t cyfrin-dev .

This is the error:

 => ERROR [5/5] RUN cyfrinup                                                                                                     0.1s
------
 > [5/5] RUN cyfrinup:
0.070 zsh:1: command not found: cyfrinup
------
Dockerfile:21
--------------------
  19 |     # Install cyfrinup - you'll see this fails
  20 |     RUN curl -L https://raw.githubusercontent.com/Cyfrin/aderyn/dev/cyfrinup/install | zsh
  21 | >>> RUN cyfrinup 
--------------------
ERROR: failed to solve: process "/usr/bin/zsh -c cyfrinup" did not complete successfully: exit code: 127
  1. Update the install command by changing this line to use the install script in this branch
- RUN curl -L https://raw.githubusercontent.com/Cyfrin/aderyn/dev/cyfrinup/install | zsh
+ RUN curl -L https://raw.githubusercontent.com/Cyfrin/aderyn/refs/heads/feat/more-robust-installer/cyfrinup/install | zsh

It will work successfully.

Testing tear down

You'll have a new docker image in your docker daemon, you can remove it if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant