lushdog 7 月之前
父节点
当前提交
440ca22421
共有 5 个文件被更改,包括 43 次插入9 次删除
  1. 2 1
      .env.example
  2. 6 2
      Dockerfile
  3. 14 6
      README.md
  4. 7 0
      docker-compose.yml
  5. 14 0
      entrypoint.sh

+ 2 - 1
.env.example

@@ -1 +1,2 @@
-NODE_ID=6381996
+NODE_ID=6170122
+MAX_THREADS=4

+ 6 - 2
Dockerfile

@@ -3,7 +3,7 @@ FROM ubuntu:24.04
 WORKDIR /app
 
 RUN apt-get update && apt-get install -y \
-    curl \
+    curl screen \
     && rm -rf /var/lib/apt/lists/*
 
 RUN curl -s https://api.github.com/repos/nexus-xyz/nexus-cli/releases/latest | \
@@ -12,5 +12,9 @@ RUN curl -s https://api.github.com/repos/nexus-xyz/nexus-cli/releases/latest | \
     cut -d '"' -f 4 | \
     xargs -I {} curl -L -o nexus-network {} && \
     chmod +x nexus-network
+    
+COPY entrypoint.sh entrypoint.sh
 
-ENTRYPOINT ["/bin/bash", "-c", "./nexus-network start --node-id ${NODE_ID}"]
+RUN chmod +x entrypoint.sh
+
+ENTRYPOINT ["./entrypoint.sh"]

+ 14 - 6
README.md

@@ -7,18 +7,26 @@
 ### 方法: 使用 .env 文件
 
 1. 创建 `.env` 文件:
+
 ```bash
-cp .env.example > .env
+cp .env.example .env
 ```
 
 2. 使用 docker-compose 运行:
+
 ```bash
-docker-compose up -d
+docker compose up -d
 ```
 
 
-## 注意事项
+## 查看日志
+
+```bash
+docker compose exec nexus-network screen -r nexus
+```
+
+## 退出查看日志
 
-- 请将 `your-actual-node-id` 替换为你的实际节点 ID
-- `.env` 文件已被 `.gitignore` 忽略,不会被提交到版本控制
-- 数据会持久化保存在 Docker volume 中 
+```bash
+ctrl+A D
+```

+ 7 - 0
docker-compose.yml

@@ -10,3 +10,10 @@ services:
     volumes:
       - ./data:/root/.nexus
     restart: unless-stopped
+    tty: true
+    stdin_open: true
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "10m"
+        max-file: "3"

+ 14 - 0
entrypoint.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+export NODE_ID=${NODE_ID}
+export MAX_THREADS=${MAX_THREADS}
+
+echo "启动 nexus-network,节点ID: ${NODE_ID}"
+
+ls /app
+
+# 使用 script 命令记录终端会话
+screen -dmS nexus bash -c './nexus-network start --node-id ${NODE_ID} --max-threads ${MAX_THREADS}'
+
+# 让 docker 不退出
+tail -f /dev/null