Skip to content

Commit 51e2e27

Browse files
committed
update dockerfile
2 parents 025eaf3 + 55b530d commit 51e2e27

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

.devcontainer/Dockerfile

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#
22
# 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.
53
#
64

75
FROM --platform=linux/amd64 rust:1.70.0
@@ -10,7 +8,7 @@ ARG DEBIAN_FRONTEND=noninteractive
108

119
ARG SOLANA_CLI="1.16.27"
1210
ARG ANCHOR_CLI="0.29.0"
13-
ARG NODE_VERSION="20.19.5"
11+
ARG NODE_VERSION="20.18.1"
1412

1513
# Create a non-root user
1614
ARG USERNAME=vscode
@@ -21,44 +19,47 @@ RUN groupadd --gid $USER_GID $USERNAME \
2119
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
2220
&& apt-get update \
2321
&& apt-get install -y sudo \
24-
&& apt-get install -y bash \
25-
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
22+
&& echo "$USERNAME ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \
2623
&& chmod 0440 /etc/sudoers.d/$USERNAME
2724

2825
ENV HOME="/home/$USERNAME"
2926
ENV PATH="${HOME}/.cargo/bin:${PATH}"
3027
ENV PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}"
3128

32-
# Install base utilities.
29+
# Install base utilities
3330
RUN mkdir -p /workdir && mkdir -p /tmp && \
3431
apt-get update -qq && apt-get upgrade -qq && apt-get install -qq \
35-
build-essential git curl wget jq pkg-config python3-pip \
32+
build-essential git curl wget jq pkg-config python3-pip xz-utils \
3633
libssl-dev libudev-dev
3734

38-
# libssl1.1 is not needed for newer versions
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
3940

40-
# Install rust.
41-
RUN curl "https://sh.rustup.rs" -sfo rustup.sh && \
42-
sh rustup.sh -y && \
43-
rustup component add rustfmt clippy
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
4447

45-
# Install node / npm / yarn.
46-
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - \
47-
&& apt-get install -y nodejs \
48-
&& apt-get install -y npm \
49-
&& npm install -g yarn ts-mocha typescript mocha
48+
RUN node -v && npm -v && yarn -v
5049

51-
# Install Solana tools (x86_64 version).
52-
RUN curl -sSfL https://github.com/solana-labs/solana/releases/download/v${SOLANA_CLI}/solana-release-x86_64-unknown-linux-gnu.tar.bz2 | tar -xjC /tmp && \
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 && \
5353
mv /tmp/solana-release/bin/* /usr/local/bin/ && \
5454
rm -rf /tmp/solana-release
5555

56-
# Install anchor.
56+
# Install Anchor
5757
RUN cargo install --git https://github.com/coral-xyz/anchor --tag v${ANCHOR_CLI} anchor-cli --locked
5858

5959
# Switch to the non-root user for the remaining setup
6060
USER $USERNAME
6161

62+
# Generate a default Solana keypair
6263
RUN solana-keygen new --no-bip39-passphrase
6364

6465
# Set up Solana config for local development
@@ -67,4 +68,4 @@ RUN solana config set --url localhost
6768
# Create necessary directories
6869
RUN mkdir -p $HOME/.config/solana
6970

70-
WORKDIR /workdir
71+
WORKDIR /workdir

0 commit comments

Comments
 (0)