Skip to content

Commit 199f504

Browse files
committed
dockerfile and dev container working, and anchor build working
1 parent dfec9a3 commit 199f504

File tree

3 files changed

+43
-79
lines changed

3 files changed

+43
-79
lines changed

.devcontainer/Dockerfile

Lines changed: 36 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,48 @@
11
#
2-
# Docker image to generate deterministic, verifiable builds of Anchor programs.
2+
# Drift Protocol Dev Container
33
#
44

55
FROM --platform=linux/amd64 rust:1.70.0
66

77
ARG DEBIAN_FRONTEND=noninteractive
8-
98
ARG SOLANA_CLI="1.16.27"
109
ARG ANCHOR_CLI="0.29.0"
1110
ARG NODE_VERSION="20.18.1"
1211

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
7047

7148
WORKDIR /workdir

.devcontainer/devcontainer.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
2-
"name": "Drift Protocol Development",
2+
"name": "Drift Protocol Development (amd64, root)",
33
"build": {
44
"dockerfile": "Dockerfile",
55
"platform": "linux/amd64"
66
},
77
"workspaceFolder": "/workdir",
8-
"remoteUser": "vscode",
8+
"remoteUser": "root",
99
"mounts": [
1010
"source=${localWorkspaceFolder},target=/workdir,type=bind,consistency=cached",
1111
"source=drift-target,target=/workdir/target,type=volume,consistency=delegated"
1212
],
13-
"postCreateCommand": "sudo chown -R vscode:vscode /workdir/target 2>/dev/null || true && echo 'Dev container ready! You can now run: anchor build, anchor test, cargo build, etc.' && echo 'To run tests: bash test-scripts/run-anchor-tests.sh'",
13+
"postCreateCommand": "echo 'Dev container ready. Run: anchor build / anchor test / cargo build'",
1414
"customizations": {
1515
"vscode": {
1616
"extensions": [
@@ -27,17 +27,11 @@
2727
},
2828
"forwardPorts": [8899, 8900],
2929
"portsAttributes": {
30-
"8899": {
31-
"label": "Solana Test Validator",
32-
"onAutoForward": "notify"
33-
},
34-
"8900": {
35-
"label": "Solana Test Validator RPC",
36-
"onAutoForward": "notify"
37-
}
30+
"8899": { "label": "Solana Test Validator", "onAutoForward": "notify" },
31+
"8900": { "label": "Solana Test Validator RPC", "onAutoForward": "notify" }
3832
},
3933
"containerEnv": {
40-
"ANCHOR_WALLET": "/home/vscode/.config/solana/id.json",
34+
"ANCHOR_WALLET": "/root/.config/solana/id.json",
4135
"RUST_LOG": "solana_runtime::message_processor::stable_log=debug"
4236
}
43-
}
37+
}

sdk/src/idl/drift.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16245,13 +16245,6 @@
1624516245
"option": "publicKey"
1624616246
},
1624716247
"index": false
16248-
},
16249-
{
16250-
"name": "signer",
16251-
"type": {
16252-
"option": "publicKey"
16253-
},
16254-
"index": false
1625516248
}
1625616249
]
1625716250
},

0 commit comments

Comments
 (0)