|
1 | 1 | # |
2 | | -# Docker image to generate deterministic, verifiable builds of Anchor programs. |
| 2 | +# Drift Protocol Dev Container |
3 | 3 | # |
4 | 4 |
|
5 | 5 | FROM --platform=linux/amd64 rust:1.70.0 |
6 | 6 |
|
7 | 7 | ARG DEBIAN_FRONTEND=noninteractive |
8 | | - |
9 | 8 | ARG SOLANA_CLI="1.16.27" |
10 | 9 | ARG ANCHOR_CLI="0.29.0" |
11 | 10 | ARG NODE_VERSION="20.18.1" |
12 | 11 |
|
13 | | -# Create a non-root user |
14 | | -ARG USERNAME=vscode |
15 | | -ARG USER_UID=1000 |
16 | | -ARG USER_GID=$USER_UID |
17 | | - |
18 | | -RUN groupadd --gid $USER_GID $USERNAME \ |
19 | | - && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ |
20 | | - && apt-get update \ |
21 | | - && apt-get install -y sudo \ |
22 | | - && echo "$USERNAME ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \ |
23 | | - && chmod 0440 /etc/sudoers.d/$USERNAME |
24 | | - |
25 | | -ENV HOME="/home/$USERNAME" |
26 | | -ENV PATH="${HOME}/.cargo/bin:${PATH}" |
27 | | -ENV PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}" |
28 | | - |
29 | | -# Install base utilities |
30 | | -RUN mkdir -p /workdir && mkdir -p /tmp && \ |
31 | | - apt-get update -qq && apt-get upgrade -qq && apt-get install -qq \ |
32 | | - build-essential git curl wget jq pkg-config python3-pip xz-utils \ |
33 | | - libssl-dev libudev-dev |
34 | | - |
35 | | -# Install Rust (latest via rustup, ensures toolchain components are present) |
36 | | -RUN curl -fsSL https://sh.rustup.rs -o /tmp/rustup.sh && \ |
37 | | - sh /tmp/rustup.sh -y && \ |
38 | | - rustup component add rustfmt clippy && \ |
39 | | - rm /tmp/rustup.sh |
40 | | - |
41 | | -# Install Node.js (pinned) |
42 | | -RUN curl -fsSL https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz -o /tmp/node.tar.xz \ |
43 | | - && tar -xJf /tmp/node.tar.xz -C /usr/local --strip-components=1 \ |
44 | | - && rm /tmp/node.tar.xz \ |
45 | | - && corepack enable \ |
46 | | - && npm install -g ts-mocha typescript mocha |
47 | | - |
48 | | -RUN node -v && npm -v && yarn -v |
49 | | - |
50 | | -# Install Solana tools (x86_64 version) |
51 | | -RUN curl -sSfL https://github.com/solana-labs/solana/releases/download/v${SOLANA_CLI}/solana-release-x86_64-unknown-linux-gnu.tar.bz2 \ |
52 | | - | tar -xjC /tmp && \ |
53 | | - mv /tmp/solana-release/bin/* /usr/local/bin/ && \ |
54 | | - rm -rf /tmp/solana-release |
55 | | - |
56 | | -# Install Anchor |
57 | | -RUN cargo install --git https://github.com/coral-xyz/anchor --tag v${ANCHOR_CLI} anchor-cli --locked |
58 | | - |
59 | | -# Switch to the non-root user for the remaining setup |
60 | | -USER $USERNAME |
61 | | - |
62 | | -# Generate a default Solana keypair |
63 | | -RUN solana-keygen new --no-bip39-passphrase |
64 | | - |
65 | | -# Set up Solana config for local development |
66 | | -RUN solana config set --url localhost |
67 | | - |
68 | | -# Create necessary directories |
69 | | -RUN mkdir -p $HOME/.config/solana |
| 12 | +ENV HOME="/root" |
| 13 | +ENV PATH="/usr/local/cargo/bin:${PATH}" |
| 14 | +ENV PATH="/root/.local/share/solana/install/active_release/bin:${PATH}" |
| 15 | + |
| 16 | +RUN mkdir -p /workdir /tmp && \ |
| 17 | + apt-get update -qq && apt-get upgrade -qq && apt-get install -y --no-install-recommends \ |
| 18 | + build-essential git curl wget jq pkg-config python3-pip xz-utils ca-certificates \ |
| 19 | + libssl-dev libudev-dev bash && \ |
| 20 | + rm -rf /var/lib/apt/lists/* |
| 21 | + |
| 22 | +RUN rustup component add rustfmt clippy |
| 23 | + |
| 24 | +RUN curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" -o /tmp/node.tar.xz \ |
| 25 | + && tar -xJf /tmp/node.tar.xz -C /usr/local --strip-components=1 \ |
| 26 | + && rm /tmp/node.tar.xz \ |
| 27 | + && corepack enable \ |
| 28 | + && npm install -g ts-mocha typescript mocha \ |
| 29 | + && node -v && npm -v && yarn -v |
| 30 | + |
| 31 | +# Solana CLI (x86_64 build) |
| 32 | +RUN curl -sSfL "https://github.com/solana-labs/solana/releases/download/v${SOLANA_CLI}/solana-release-x86_64-unknown-linux-gnu.tar.bz2" \ |
| 33 | + | tar -xjC /tmp \ |
| 34 | + && mv /tmp/solana-release/bin/* /usr/local/bin/ \ |
| 35 | + && rm -rf /tmp/solana-release |
| 36 | + |
| 37 | +# Anchor CLI |
| 38 | +RUN cargo install --git https://github.com/coral-xyz/anchor --tag "v${ANCHOR_CLI}" anchor-cli --locked |
| 39 | + |
| 40 | +# Set up Solana key + config for root |
| 41 | +RUN solana-keygen new --no-bip39-passphrase --force \ |
| 42 | + && solana config set --url localhost |
| 43 | + |
| 44 | +RUN apt-get update && apt-get install -y zsh curl git \ |
| 45 | + && sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended \ |
| 46 | + && chsh -s /usr/bin/zsh vscode |
70 | 47 |
|
71 | 48 | WORKDIR /workdir |
0 commit comments