Add Docker support: Dockerfile, docker-compose.yaml, and README updates
This commit is contained in:
34
Dockerfile
Normal file
34
Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
FROM golang:1.23-alpine AS builder
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
# Pull modules first for better layer cache.
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/laodingbot ./cmd/bot
|
||||||
|
|
||||||
|
FROM alpine:3.20
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
|
|
||||||
|
COPY --from=builder /out/laodingbot /app/laodingbot
|
||||||
|
|
||||||
|
# Keep default runtime assets in image; can be overridden by bind mounts.
|
||||||
|
COPY bot_context /app/bot_context
|
||||||
|
COPY skills /app/skills
|
||||||
|
COPY workspace/agent_runtime /app/workspace/agent_runtime
|
||||||
|
|
||||||
|
ENV MESSAGE_CHANNEL=webui
|
||||||
|
ENV WEBUI_LISTEN_ADDR=:8090
|
||||||
|
ENV AGENT_WORKSPACE_DIR=/app/workspace/agent_runtime
|
||||||
|
|
||||||
|
# Host can bind mount these directories for persistent/external runtime data.
|
||||||
|
VOLUME ["/app/workspace/agent_runtime"]
|
||||||
|
|
||||||
|
EXPOSE 8090
|
||||||
|
|
||||||
|
CMD ["/app/laodingbot"]
|
||||||
79
README.md
79
README.md
@@ -15,6 +15,7 @@ Now supports mutually exclusive message channels:
|
|||||||
|
|
||||||
- `telegram` (long polling)
|
- `telegram` (long polling)
|
||||||
- `feishu` (official SDK websocket long connection)
|
- `feishu` (official SDK websocket long connection)
|
||||||
|
- `webui` (HTTP + SSE, default `:8090`)
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
@@ -22,9 +23,10 @@ Now supports mutually exclusive message channels:
|
|||||||
- The app auto-loads `configs/env` (or `.env`) if present.
|
- The app auto-loads `configs/env` (or `.env`) if present.
|
||||||
- You can also set `CONFIG_ENV_FILE=/path/to/env`.
|
- You can also set `CONFIG_ENV_FILE=/path/to/env`.
|
||||||
- Process environment variables override file values.
|
- Process environment variables override file values.
|
||||||
2. Choose exactly one channel with `MESSAGE_CHANNEL=telegram|feishu`.
|
2. Choose exactly one channel with `MESSAGE_CHANNEL=telegram|feishu|webui`.
|
||||||
- If `telegram`: set `TELEGRAM_BOT_TOKEN`, keep `FEISHU_*` empty.
|
- If `telegram`: set `TELEGRAM_BOT_TOKEN`, keep `FEISHU_*` empty.
|
||||||
- If `feishu`: set `FEISHU_APP_ID` and `FEISHU_APP_SECRET`, keep `TELEGRAM_BOT_TOKEN` empty.
|
- If `feishu`: set `FEISHU_APP_ID` and `FEISHU_APP_SECRET`, keep `TELEGRAM_BOT_TOKEN` empty.
|
||||||
|
- If `webui`: set `WEBUI_LISTEN_ADDR` (default `:8090`).
|
||||||
3. Set log level with `LOG_LEVEL=debug|info|warn|error`.
|
3. Set log level with `LOG_LEVEL=debug|info|warn|error`.
|
||||||
- To inspect full skill/tool execution content and detailed ReAct step traces, use `LOG_LEVEL=debug`.
|
- To inspect full skill/tool execution content and detailed ReAct step traces, use `LOG_LEVEL=debug`.
|
||||||
4. Configure knowledge and reasoning:
|
4. Configure knowledge and reasoning:
|
||||||
@@ -65,6 +67,81 @@ go run ./cmd/bot
|
|||||||
- Skills directory default path: `skills/`
|
- Skills directory default path: `skills/`
|
||||||
- Skill format uses subdirectories: `skills/<skill_name>/skill.md`
|
- Skill format uses subdirectories: `skills/<skill_name>/skill.md`
|
||||||
|
|
||||||
|
## Docker Build And Run
|
||||||
|
|
||||||
|
### Required Files And Folders
|
||||||
|
|
||||||
|
Before building/running with Docker, ensure these exist:
|
||||||
|
|
||||||
|
- `Dockerfile`
|
||||||
|
- `docker-compose.yaml`
|
||||||
|
- `workspace/agent_runtime/configs/env`
|
||||||
|
- `workspace/agent_runtime/bot_context/soul.md`
|
||||||
|
- `workspace/agent_runtime/skills/`
|
||||||
|
- `workspace/agent_runtime/data/`
|
||||||
|
- `workspace/agent_runtime/workspace/`
|
||||||
|
|
||||||
|
Quick bootstrap command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p workspace/agent_runtime/{configs,bot_context,skills,data,workspace}
|
||||||
|
cp -n configs/env.sample workspace/agent_runtime/configs/env
|
||||||
|
cp -n bot_context/soul.md workspace/agent_runtime/bot_context/soul.md
|
||||||
|
cp -rn skills/* workspace/agent_runtime/skills/
|
||||||
|
```
|
||||||
|
|
||||||
|
Minimum env config in `workspace/agent_runtime/configs/env`:
|
||||||
|
|
||||||
|
```env
|
||||||
|
MESSAGE_CHANNEL=webui
|
||||||
|
WEBUI_LISTEN_ADDR=:8090
|
||||||
|
LLM_API_KEY=your_api_key
|
||||||
|
```
|
||||||
|
|
||||||
|
`docker-compose.yaml` already mounts `./workspace/agent_runtime` into the container, so host-side data is persistent.
|
||||||
|
|
||||||
|
### Build Docker Image
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -t laodingbot:latest .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run With Docker (Single Container)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -d \
|
||||||
|
--name laodingbot \
|
||||||
|
-p 8090:8090 \
|
||||||
|
--env-file ./workspace/agent_runtime/configs/env \
|
||||||
|
-e MESSAGE_CHANNEL=webui \
|
||||||
|
-e WEBUI_LISTEN_ADDR=:8090 \
|
||||||
|
-e AGENT_WORKSPACE_DIR=/app/workspace/agent_runtime \
|
||||||
|
-v "$(pwd)/workspace/agent_runtime:/app/workspace/agent_runtime" \
|
||||||
|
laodingbot:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run With Docker Compose
|
||||||
|
|
||||||
|
Build and start:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
View logs:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose logs -f laodingbot
|
||||||
|
```
|
||||||
|
|
||||||
|
Stop and remove:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
After startup, open WebUI at `http://localhost:8090`.
|
||||||
|
|
||||||
## Security Notes
|
## Security Notes
|
||||||
|
|
||||||
- `shell` only allows commands listed in `ALLOWED_COMMANDS`.
|
- `shell` only allows commands listed in `ALLOWED_COMMANDS`.
|
||||||
|
|||||||
18
docker-compose.yaml
Normal file
18
docker-compose.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
services:
|
||||||
|
laodingbot:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
image: laodingbot:latest
|
||||||
|
container_name: laodingbot
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8090:8090"
|
||||||
|
env_file:
|
||||||
|
- ./workspace/agent_runtime/configs/env
|
||||||
|
environment:
|
||||||
|
MESSAGE_CHANNEL: webui
|
||||||
|
WEBUI_LISTEN_ADDR: ":8090"
|
||||||
|
AGENT_WORKSPACE_DIR: /app/workspace/agent_runtime
|
||||||
|
volumes:
|
||||||
|
- ./workspace/agent_runtime:/app/workspace/agent_runtime
|
||||||
Reference in New Issue
Block a user