Skip to content

Commit 81efe3e

Browse files
superboyiiishargonAnnaShaleva
authored
Add Dockerfile and Quick Start (#992)
* Add Dockerfile and Quick Start Signed-off-by: superboyiii <[email protected]> * improve * fix * improve * fix plugin path * Update src/Neo.CLI/Docker/Dockerfile Co-authored-by: Anna Shaleva <[email protected]> --------- Signed-off-by: superboyiii <[email protected]> Co-authored-by: Shargon <[email protected]> Co-authored-by: Anna Shaleva <[email protected]>
1 parent 31d9fcd commit 81efe3e

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed

src/Neo.CLI/Docker/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS Build
2+
RUN apt-get update && apt-get install -y \
3+
net-tools \
4+
telnet \
5+
bash-completion \
6+
wget \
7+
curl \
8+
lrzsz \
9+
zip \
10+
unzip \
11+
sqlite3 \
12+
libsqlite3-dev \
13+
libunwind8-dev \
14+
screen \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
WORKDIR /neo
18+
COPY prepare-node.sh .
19+
RUN chmod +x prepare-node.sh
20+
21+
ARG CLI_VERSION=v3.9.2
22+
ARG PLUGIN_VERSION=
23+
RUN if [ -z "$PLUGIN_VERSION" ]; then \
24+
./prepare-node.sh $CLI_VERSION; \
25+
else \
26+
./prepare-node.sh $CLI_VERSION $PLUGIN_VERSION; \
27+
fi
28+
29+
RUN sed -i 's/"BindAddress":[^,]*/"BindAddress": "0.0.0.0"/' neo-cli/Plugins/RpcServer/RpcServer.json
30+
COPY start.sh .
31+
RUN chmod -R +x ./neo-cli
32+
ENTRYPOINT ["sh", "./start.sh"]

src/Neo.CLI/Docker/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Neo CLI Docker Usage Examples
2+
3+
## Example 1: Install CLI v3.9.2 (with matching plugins)
4+
5+
```bash
6+
# Build the image (v3.9.2 is the default)
7+
docker build -t v3.9.2 .
8+
9+
# Run the container
10+
docker run -d -p 10332:10332 --name neo-node v3.9.2
11+
12+
# Enter the container and test
13+
docker exec -it neo-node bash
14+
curl -X POST http://localhost:10332 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"getblockcount","params":[],"id":1}'
15+
```
16+
17+
## Example 2: Install CLI v3.9.2 with Plugin v3.9.0
18+
19+
```bash
20+
# Build the image
21+
docker build -t v3.9.2-plugins-3.9.0 --build-arg PLUGIN_VERSION=v3.9.0 .
22+
23+
# Run the container
24+
docker run -d -p 10332:10332 --name neo-node v3.9.2-plugins-3.9.0
25+
26+
# Enter the container and test
27+
docker exec -it neo-node bash
28+
curl -X POST http://localhost:10332 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"getblockcount","params":[],"id":1}'
29+
```
30+
31+
## Example 3: Install CLI v3.10.0 (with matching plugins)
32+
33+
```bash
34+
# Build the image
35+
docker build -t v3.10.0 --build-arg CLI_VERSION=v3.10.0 .
36+
37+
# Run the container
38+
docker run -d -p 10332:10332 --name neo-node v3.10.0
39+
40+
# Enter the container and test
41+
docker exec -it neo-node bash
42+
curl -X POST http://localhost:10332 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"getblockcount","params":[],"id":1}'
43+
```
44+
45+
## Quick Test Command
46+
47+
Once inside the container, you can also use:
48+
```bash
49+
curl http://localhost:10332 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"getblockcount","params":[],"id":1}'
50+
```
51+
52+
This will return the current block count, confirming the CLI is running and responding to RPC calls.

src/Neo.CLI/Docker/prepare-node.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
echo "Downloading neo node $1"
2+
wget https://github.com/neo-project/neo-node/releases/download/$1/neo-cli-linux-x64.zip
3+
unzip neo-cli-linux-x64.zip
4+
5+
6+
if [ -z "$2" ]; then
7+
echo "Downloading plugins $1"
8+
wget https://github.com/neo-project/neo-node/releases/download/$1/ApplicationLogs.zip
9+
wget https://github.com/neo-project/neo-node/releases/download/$1/RpcServer.zip
10+
wget https://github.com/neo-project/neo-node/releases/download/$1/TokensTracker.zip
11+
else
12+
echo "Downloading plugins $2"
13+
wget https://github.com/neo-project/neo-node/releases/download/$2/ApplicationLogs.zip
14+
wget https://github.com/neo-project/neo-node/releases/download/$2/RpcServer.zip
15+
wget https://github.com/neo-project/neo-node/releases/download/$2/TokensTracker.zip
16+
fi
17+
18+
unzip -n ApplicationLogs.zip -d ./neo-cli/
19+
unzip -n RpcServer.zip -d ./neo-cli/
20+
unzip -n TokensTracker.zip -d ./neo-cli/
21+
22+
echo "Node Ready!"

src/Neo.CLI/Docker/start.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Start CLI in background, log output to neo.log
4+
screen -dmS neo bash -c "./neo-cli/neo-cli > neo.log 2>&1"
5+
6+
while [ ! -f neo.log ]; do
7+
sleep 0.5
8+
done
9+
10+
# Timely check log
11+
tail -f neo.log

0 commit comments

Comments
 (0)