|
| 1 | +FROM ubuntu:22.04 |
| 2 | + |
| 3 | +ARG DEBIAN_FRONTEND=noninteractive |
| 4 | +ARG RUSTC_VERSION |
| 5 | +ARG NODE_VERSION |
| 6 | +ARG SOLANA_CLI |
| 7 | +ARG ANCHOR_CLI |
| 8 | + |
| 9 | +ENV HOME="/root" |
| 10 | +ENV PATH="${HOME}/.cargo/bin:${PATH}" |
| 11 | +ENV PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}" |
| 12 | +ENV PATH="${HOME}/.nvm/versions/node/${NODE_VERSION}/bin:${PATH}" |
| 13 | + |
| 14 | +# Install base utilities. |
| 15 | +RUN mkdir -p /workdir && mkdir -p /tmp && \ |
| 16 | + apt-get update -qq && apt-get upgrade -qq && apt-get install -qq \ |
| 17 | + build-essential git curl wget jq pkg-config python3-pip \ |
| 18 | + libssl-dev libudev-dev |
| 19 | + |
| 20 | +# Install rust. |
| 21 | +RUN curl "https://sh.rustup.rs" -sfo rustup.sh && \ |
| 22 | + sh rustup.sh --default-toolchain none -y && \ |
| 23 | + rustup install ${RUSTC_VERSION#v} && \ |
| 24 | + rustup default ${RUSTC_VERSION#v} && \ |
| 25 | + rustup component add rustfmt clippy |
| 26 | + |
| 27 | +# Install node / npm / yarn. |
| 28 | +RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | sh |
| 29 | +ENV NVM_DIR="${HOME}/.nvm" |
| 30 | +RUN . $NVM_DIR/nvm.sh && \ |
| 31 | + nvm install ${NODE_VERSION} && \ |
| 32 | + nvm use ${NODE_VERSION} && \ |
| 33 | + nvm alias default node && \ |
| 34 | + npm install -g yarn |
| 35 | + |
| 36 | +# Install Solana tools. |
| 37 | +RUN sh -c "$(curl -sSfL https://release.anza.xyz/${SOLANA_CLI}/install)" |
| 38 | + |
| 39 | +# Install anchor. |
| 40 | +RUN cargo install --git https://github.com/coral-xyz/anchor --tag ${ANCHOR_CLI} anchor-cli --locked |
| 41 | + |
| 42 | +# Build a dummy program to bootstrap the BPF SDK (doing this speeds up builds). |
| 43 | +RUN mkdir -p /tmp && cd tmp && anchor init dummy && cd dummy && anchor build |
| 44 | + |
| 45 | +# Set up the working directory |
| 46 | +WORKDIR /workdir |
| 47 | + |
| 48 | +# Copy the entrypoint script |
| 49 | +COPY entrypoint.sh /entrypoint.sh |
| 50 | +RUN chmod +x /entrypoint.sh |
| 51 | + |
| 52 | +# Define the entrypoint |
| 53 | +ENTRYPOINT ["/entrypoint.sh"] |
0 commit comments