1+ # syntax=docker/dockerfile:1.10.0
2+ # check=error=true
3+ #
4+ # AUDITOR TRG DevContainer Dockerfile
5+ # This Dockerfile creates a specialized development environment for smart contract auditing
6+ # with focused tooling, Docker-in-Docker support, and comprehensive security analysis tools.
7+ #
8+ # Key features:
9+ # - Multi-stage build for Echidna binary
10+ # - Specialized audit tools (slither, mythril, crytic-compile)
11+ # - Foundry framework for testing and interaction
12+ # - Hardhat for development workflows
13+ # - Docker-in-Docker support for containerized tools
14+
15+ # Pull latest Echidna prebuilt image from Crytic
16+ # Echidna is a fuzzing tool for Ethereum smart contracts
17+ FROM --platform=linux/amd64 ghcr.io/crytic/echidna/echidna AS echidna
18+
19+ # Base image: Debian 12 (Bookworm) with VS Code DevContainer support
20+ # This provides a stable, development-focused base for auditing work
21+ FROM mcr.microsoft.com/vscode/devcontainers/base:bookworm
22+
23+ # Switch to root user temporarily for system package installation
24+ USER root
25+
26+ # Install essential system packages for development
27+ # These are the minimal packages needed for Web3 development tools
28+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
29+ bash-completion # Shell completion support \
30+ build-essential # Compilation tools (gcc, make, etc.) \
31+ curl # HTTP client for downloading tools \
32+ git # Version control system \
33+ jq # JSON processor for tool outputs \
34+ pkg-config # Package configuration helper \
35+ sudo # Privilege escalation (needed for some tools) \
36+ unzip # Archive extraction \
37+ vim # Text editor \
38+ wget # Alternative HTTP client \
39+ zsh # Advanced shell \
40+ && rm -rf /var/lib/apt/lists/*
41+
42+
43+
44+ # Install Python development dependencies
45+ # Required for Python-based security tools and package management
46+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
47+ python3-pip # Python package installer \
48+ libpython3-dev # Python development headers \
49+ python3-dev # Python development tools \
50+ python3-venv # Python virtual environment support \
51+ && rm -rf /var/lib/apt/lists/*
52+
53+ # Switch to vscode user for security (drop privileges)
54+ # This ensures all subsequent operations run as non-root user
55+ USER vscode
56+ WORKDIR /home/vscode
57+ ENV HOME=/home/vscode
58+
59+ # Install uv
60+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
61+
62+ # Update PATH environment for tool access
63+ # Configure paths for Python, Node.js, and other tools
64+ ENV UV_LOCAL_BIN=$HOME/.cargo/bin
65+ ENV USR_LOCAL_BIN=/usr/local/bin
66+ ENV LOCAL_BIN=${HOME}/.local/bin
67+ ENV PNPM_HOME=${HOME}/.local/share/pnpm
68+ ENV PATH=${PATH}:${USR_LOCAL_BIN}:${LOCAL_BIN}:${PNPM_HOME}:${UV_LOCAL_BIN}
69+
70+ # Install Python 3.12 with uv
71+ RUN uv python install 3.12
72+
73+ # Set the default shell to zsh for better development experience
74+ ENV SHELL=/usr/bin/zsh
75+
76+ # Running everything under zsh for consistency and features
77+ SHELL ["/usr/bin/zsh" , "-ic" ]
78+
79+ # Install Go programming language through asdf version manager
80+ # asdf provides consistent version management across different tools
81+ # Go is required for various Web3 tools and Foundry framework
82+ RUN git clone https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.15.0 && \
83+ echo '. $HOME/.asdf/asdf.sh' >> $HOME/.zshrc && \
84+ echo 'fpath=(${ASDF_DIR}/completions $fpath)' >> $HOME/.zshrc && \
85+ echo 'autoload -Uz compinit && compinit' >> $HOME/.zshrc && \
86+ . $HOME/.asdf/asdf.sh && \
87+ asdf plugin add golang && \
88+ asdf install golang latest && \
89+ asdf global golang latest
90+
91+ # Install Rust programming language
92+ # Required for various Web3 security tools and Foundry framework
93+ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && source $HOME/.cargo/env
94+
95+ # Switch to root user temporarily for Node.js installation
96+ USER root
97+
98+ # Install Node.js, npm, yarn, and pnpm through devcontainer features
99+ # These are essential for JavaScript/TypeScript Web3 development and Hardhat
100+ RUN curl -o- https://raw.githubusercontent.com/devcontainers/features/main/src/node/install.sh | bash
101+ RUN chown -R vscode:vscode ${HOME}/.npm
102+
103+ # Switch back to vscode user for security
104+ USER vscode
105+
106+ # Install Foundry framework for Ethereum development and testing
107+ # Foundry provides Forge (testing), Cast (interaction), and Anvil (local blockchain)
108+ # Essential for smart contract development and testing during audits
109+ RUN curl -L https://foundry.paradigm.xyz | zsh
110+ RUN foundryup
111+
112+ # Install Python-based security analysis tools for auditing
113+ # These tools provide comprehensive smart contract security analysis
114+ # Focused on core auditing tools: slither, mythril, crytic-compile
115+ RUN uv tool install slither-analyzer && \
116+ uv tool install mythril && \
117+ uv tool install crytic-compile
118+
119+ # Install Hardhat and Solhint for Ethereum development
120+ # Hardhat is a popular development environment, Solhint provides linting
121+ RUN pnpm install -g hardhat solhint
122+
123+ # Copy prebuilt Echidna binary from echidna stage to final image
124+ # This provides the prebuilt Echidna tool without rebuilding
125+ COPY --chown=vscode:vscode --from=echidna /usr/local/bin/echidna ${HOME}/.local/bin/echidna
126+ RUN chmod 755 ${HOME}/.local/bin/echidna
127+
128+ # Switch to non-root user for final setup
129+ USER vscode
130+
131+ # Set up user environment with Foundry path
132+ # Ensure Foundry tools are available in the user's shell
133+ RUN echo 'export PATH="/usr/local/foundry/bin:$PATH"' >> /home/vscode/.zshrc
134+
135+ # Switch to root for system cleanup
136+ USER root
137+
138+ # Clean up package cache and temporary files
139+ # This reduces image size and improves security
140+ RUN apt-get autoremove -y && apt-get clean -y
141+
142+ # Final switch to vscode user for development
143+ USER vscode
0 commit comments