Dockerfile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #
  2. # Docker image to generate deterministic, verifiable builds of Anchor programs.
  3. # This must be run *after* a given ANCHOR_CLI version is published and a git tag
  4. # is released on GitHub.
  5. #
  6. FROM ubuntu:22.04@sha256:1ec65b2719518e27d4d25f104d93f9fac60dc437f81452302406825c46fcc9cb
  7. ARG DEBIAN_FRONTEND=noninteractive
  8. ARG SOLANA_CLI
  9. ARG ANCHOR_CLI
  10. ARG NODE_VERSION="v20.18.0"
  11. ENV HOME="/root"
  12. ENV PATH="${HOME}/.cargo/bin:${PATH}"
  13. ENV PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}"
  14. ENV PATH="${HOME}/.nvm/versions/node/${NODE_VERSION}/bin:${PATH}"
  15. # Install base utilities.
  16. RUN mkdir -p /workdir && mkdir -p /tmp && \
  17. apt-get update -qq && apt-get upgrade -qq && apt-get install -qq \
  18. build-essential git curl wget jq pkg-config python3-pip \
  19. libssl-dev libudev-dev
  20. # Install rust.
  21. RUN curl "https://sh.rustup.rs" -sfo rustup.sh && \
  22. sh rustup.sh -y && \
  23. rustup component add rustfmt clippy
  24. # Install node / npm / yarn.
  25. RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
  26. ENV NVM_DIR="${HOME}/.nvm"
  27. RUN . $NVM_DIR/nvm.sh && \
  28. nvm install ${NODE_VERSION} && \
  29. nvm use ${NODE_VERSION} && \
  30. nvm alias default node && \
  31. npm install -g yarn
  32. # Install Solana tools.
  33. RUN sh -c "$(curl -sSfL https://release.anza.xyz/${SOLANA_CLI}/install)"
  34. # Install anchor.
  35. RUN cargo install --git https://github.com/coral-xyz/anchor --tag ${ANCHOR_CLI} anchor-cli --locked
  36. # Build a dummy program to bootstrap the BPF SDK (doing this speeds up builds).
  37. RUN mkdir -p /tmp && cd tmp && anchor init dummy && cd dummy && anchor build
  38. WORKDIR /workdir