Skip to content

Commit

Permalink
New version of devcontainer in the making.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattaereal committed Jan 16, 2025
1 parent 0659b1b commit a2c74a2
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 73 deletions.
49 changes: 0 additions & 49 deletions .devcontainer/Dockerfile

This file was deleted.

52 changes: 28 additions & 24 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// https://github.com/devcontainers/images/tree/main/src/base-alpine
// "image": "mcr.microsoft.com/devcontainers/base:debian",
"build": {
"dockerfile": "Dockerfile"
"dockerfile": "../Dockerfile"
},
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
Expand All @@ -18,37 +18,41 @@
// Configure properties specific to VS Code.
"vscode": {
"extensions": [
"NomicFoundation.hardhat-solidity",
"tintinweb.solidity-visual-auditor",
// check out https://marketplace.visualstudio.com/items?itemName=tintinweb.ethereum-security-bundle for more information
"tintinweb.ethereum-security-bundle",
// this includes:
// juanblanco.solidity
// tintinweb.solidity-visual-auditor
// tintinweb.solidity-metrics
// tintinweb.vscode-solidity-flattener
// tintinweb.vscode-vyper
// tintinweb.vscode-LLL
// streetsidesoftware.code-spell-checker
// gimenete.github-linker
// ryu1kn.partial-diff
// tintinweb.vscode-inline-bookmarks
// eamodio.gitlens
"tintinweb.vscode-ethover",
"trailofbits.weaudit",
"tintinweb.solidity-metrics"
"tintinweb.vscode-inline-bookmarks",
"tintinweb.vscode-solidity-language",
"tintinweb.graphviz-interactive-preview",
"NomicFoundation.hardhat-solidity",
"Olympixai.olympix",
"trailofbits.contract-explorer",
// this goes with panoramix
"tintinweb.vscode-decompiler",


],
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": { "zsh": { "path": "/usr/bin/zsh" } }
}
}
},


// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [3000],

// Use 'portsAttributes' to set default properties for specific forwarded ports.
// More info: https://containers.dev/implementors/json_reference/#port-attributes
// "portsAttributes": {
// "3000": {
// "label": "Hello Remote World",
// "onAutoForward": "notify"
// }
// },

// Use 'postCreateCommand' to run commands after the container is created.
// We're using a gist, but you can also reference the raw install-tool from your repo.
// Unless you mount the scripts folder as
"postCreateCommand": "echo Welcome to The Red Guild's dev-container. If you'd like to build your own, you can check out an article we have created for you at our blog under https://blog.theredguild.org/where-do-you-run-your-code;zsh"

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
// "postCreateCommand": ""
"postAttachCommand": "zsh"
}

110 changes: 110 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# syntax=docker/dockerfile:1.8
# check=error=true

## Multi-stage build!
# Pull prebuilt Echidna binary
FROM --platform=linux/amd64 ghcr.io/crytic/echidna/echidna:latest AS echidna

# Base debian build (latest).
FROM mcr.microsoft.com/vscode/devcontainers/base:debian

# Switch to root (the default might be root anyway)
USER root

# Super basic stuff to get everything started
RUN apt-get update -y && apt-get install -y \
zsh python3-pip pipx curl git sudo

# The base container usually has a “vscode” user. If not, create one here.
RUN echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Switch to vscode (drop privs)
USER vscode
WORKDIR /home/vscode

# Set PATH with .local/bin included.
ENV HOME=/home/vscode
ENV PATH=${PATH}:${HOME}/.local/bin
RUN pipx ensurepath

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

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


# Install golang's latest version through asdf
RUN git clone https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.15.0 \
&& echo '. $HOME/.asdf/asdf.sh' >> $HOME/.zshrc \
&& echo 'fpath=(${ASDF_DIR}/completions $fpath)' >> $HOME/.zshrc \
&& echo 'autoload -Uz compinit && compinit' >> $HOME/.zshrc \
&& . $HOME/.asdf/asdf.sh \
&& asdf plugin add golang \
&& asdf install golang latest \
&& asdf global golang latest

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

# # Install nvm, yarn, npm, pnpm
RUN curl -o- https://raw.githubusercontent.com/devcontainers/features/main/src/node/install.sh | sudo bash

# # Install solc-select
## Install one solc release from each branch and select the latest version as the default
RUN pipx install solc-select && solc-select install 0.4.26 0.5.17 0.6.12 0.7.6 0.8.10 latest && solc-select use latest

# Python installations
## Install slither analyzer, crytic-compile, vyper, mythx, panoramix, slider-lsp (needed for contract explorer), napalm-toolbox
RUN pipx install slither-analyzer \
&& pipx install crytic-compile \
&& pipx install vyper \
&& pipx install mythx-cli \
&& pipx install panoramix-decompiler \
## needed for the contract explorer
&& pipx install slither-lsp \
&& pipx install napalm-toolbox


# RUN pip install napalm-core

# Fetch and install setups
## install ityfuzz
RUN curl -L https://ity.fuzz.land/ | bash
RUN ityfuzzup

## Foundry framework
RUN curl -L https://foundry.paradigm.xyz | zsh
RUN foundryup

## install aderyn
RUN curl -L https://raw.githubusercontent.com/Cyfrin/aderyn/dev/cyfrinup/install | bash
RUN cyfrinup

# Git clone, compile kind of installations
## Install Medusa
RUN git clone https://github.com/crytic/medusa.git ${HOME}/medusa && \
cd ${HOME}/medusa && \
export LATEST_TAG="$(git describe --tags | sed 's/-[0-9]\+-g\w\+$//')" && \
git checkout "$LATEST_TAG" && \
go build -trimpath -o=${HOME}/.local/bin/medusa -ldflags="-s -w" && \
chmod 755 ${HOME}/.local/bin/medusa

# Copy prebuilt Echidna binary
COPY --chown=vscode:vscode --from=echidna /usr/local/bin/echidna ${HOME}/.local/bin/echidna
RUN chmod 755 ${HOME}/.local/bin/echidna

# Clone useful repositories
RUN git clone --depth 1 https://github.com/crytic/building-secure-contracts.git


# # # Clean up
USER root
RUN apt-get autoremove -y && apt-get clean -y

# Configure MOTD
COPY --link --chown=root:root motd /etc/motd
RUN echo '\ncat /etc/motd\n' >> ~/.zshrc

USER vscode

18 changes: 18 additions & 0 deletions motd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
__ __ _
\ \ / /__| | ___ ___ _ __ ___ ___
\ \ /\ / / _ \ |/ __/ _ \| '_ ` _ \ / _ \
\ V V / __/ | (_| (_) | | | | | | __/
__ \_/\_/ \___|_|\___\___/|_| |_| |_|\___|
\ \ / /_ _ _ __ __| | ___ _ __ ___ _ __
\ \ /\ / / _` | '_ \ / _` |/ _ \ '__/ _ \ '__|
\ V V / (_| | | | | (_| | __/ | | __/ |
\_/\_/ \__,_|_| |_|\__,_|\___|_| \___|_|

This is a devcontainer!
Built by The Red Guild 🪷

This devcontainer was created as an exploration, it's another layer of defense
to your daily shenaningans. We hope this help people protect themselves
and the repos they interact with. Say hi @theredguild!, don't be a stranger.
Further reading: https://blog.theredguild.org/where-do-you-run-your-code

0 comments on commit a2c74a2

Please sign in to comment.