feat: add goose

This commit is contained in:
Sun-ZhenXing
2026-01-02 22:06:24 +08:00
parent ab07facdb1
commit 25c618aa2e
17 changed files with 1241 additions and 150 deletions

64
builds/goose/.env.example Normal file
View File

@@ -0,0 +1,64 @@
# goose Configuration
# AI-powered developer agent by Block
# Global registry prefix (optional)
# Leave empty to pull from Docker Hub
GLOBAL_REGISTRY=
# goose version
# Default: latest
GOOSE_VERSION=1.18.0
# Timezone
# Default: UTC
TZ=UTC
# ============================================
# API Configuration
# ============================================
# OpenAI API Configuration
# Required if using OpenAI provider
OPENAI_API_KEY=
# Optional: Custom API base URL (e.g., for proxy or local deployment)
OPENAI_API_BASE=
# Anthropic API Configuration
# Required if using Anthropic provider
ANTHROPIC_API_KEY=
# Google API Configuration
# Required if using Google provider
GOOGLE_API_KEY=
# ============================================
# goose Configuration
# ============================================
# AI Provider
# Options: openai, anthropic, google
# Default: openai
GOOSE_PROVIDER=openai
# AI Model
# For OpenAI: gpt-4, gpt-4-turbo, gpt-3.5-turbo
# For Anthropic: claude-3-opus, claude-3-sonnet, claude-3-haiku
# For Google: gemini-pro
# Default: gpt-4
GOOSE_MODEL=gpt-4
# ============================================
# Resource Limits
# ============================================
# CPU limits
GOOSE_CPU_LIMIT=2.00
GOOSE_CPU_RESERVATION=0.50
# Memory limits
GOOSE_MEMORY_LIMIT=2G
GOOSE_MEMORY_RESERVATION=512M
# Logging limits
GOOSE_LOG_MAX_SIZE=100m
GOOSE_LOG_MAX_FILE=3

46
builds/goose/Dockerfile Normal file
View File

@@ -0,0 +1,46 @@
FROM debian:bookworm-slim@sha256:b1a741487078b369e78119849663d7f1a5341ef2768798f7b7406c4240f86aef
ARG GOOSE_VERSION=1.18.0
ARG TARGETARCH
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
libssl3 \
libdbus-1-3 \
libxcb1 \
curl \
bzip2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Download and install goose binary based on architecture
RUN ARCH=${TARGETARCH:-amd64} && \
case "${ARCH}" in \
amd64) GOOSE_ARCH="x86_64" ;; \
arm64) GOOSE_ARCH="aarch64" ;; \
*) echo "Unsupported architecture: ${ARCH}" && exit 1 ;; \
esac && \
curl -fsSL "https://github.com/block/goose/releases/download/v${GOOSE_VERSION}/goose-${GOOSE_ARCH}-unknown-linux-gnu.tar.bz2" \
-o /tmp/goose.tar.bz2 && \
tar -xjf /tmp/goose.tar.bz2 -C /usr/local/bin && \
chmod +x /usr/local/bin/goose && \
rm /tmp/goose.tar.bz2
# Create non-root user
RUN useradd -m -u 1000 -s /bin/bash goose && \
mkdir -p /home/goose/.config/goose && \
chown -R goose:goose /home/goose
# Set up environment
ENV PATH="/usr/local/bin:${PATH}"
ENV HOME="/home/goose"
# Switch to non-root user
USER goose
WORKDIR /home/goose
# Default to goose CLI
ENTRYPOINT ["/usr/local/bin/goose"]
CMD ["--help"]

195
builds/goose/README.md Normal file
View File

@@ -0,0 +1,195 @@
# goose
[中文文档](README.zh.md)
goose is an AI-powered developer agent created by Block. It helps developers with coding tasks through natural language interaction, offering intelligent code generation, debugging assistance, and project navigation.
## Features
- **AI-Powered Development**: Leverage advanced language models for coding assistance
- **Multiple AI Providers**: Support for OpenAI, Anthropic, and Google AI
- **Interactive CLI**: Engage with goose through an intuitive command-line interface
- **Project Understanding**: Analyze and understand your codebase context
- **Code Generation**: Generate code snippets and implementations
- **Debugging Help**: Assist with troubleshooting and error resolution
## Prerequisites
- Docker and Docker Compose installed
- An API key from one of the supported AI providers:
- OpenAI API key (for GPT models)
- Anthropic API key (for Claude models)
- Google API key (for Gemini models)
## Quick Start
1. Copy the example environment file:
```bash
cp .env.example .env
```
2. Edit `.env` and configure your API credentials:
```bash
# For OpenAI
OPENAI_API_KEY=your_openai_api_key_here
GOOSE_PROVIDER=openai
GOOSE_MODEL=gpt-4
# OR for Anthropic
ANTHROPIC_API_KEY=your_anthropic_api_key_here
GOOSE_PROVIDER=anthropic
GOOSE_MODEL=claude-3-sonnet
# OR for Google
GOOGLE_API_KEY=your_google_api_key_here
GOOSE_PROVIDER=google
GOOSE_MODEL=gemini-pro
```
3. Build the Docker image:
```bash
docker compose build
```
4. Run goose:
```bash
docker compose run --rm goose
```
## Usage Examples
### Interactive Session
Start an interactive session with goose:
```bash
docker compose run --rm goose session start
```
### Execute a Task
Run a specific task or query:
```bash
docker compose run --rm goose run "explain the main function in app.py"
```
### Get Help
View available commands:
```bash
docker compose run --rm goose --help
```
## Configuration
### Environment Variables
| Variable | Description | Default |
| -------------------- | --------------------------------------- | -------- |
| `GOOSE_VERSION` | goose Docker image version | `1.18.0` |
| `TZ` | Container timezone | `UTC` |
| `GOOSE_PROVIDER` | AI provider (openai, anthropic, google) | `openai` |
| `GOOSE_MODEL` | AI model to use | `gpt-4` |
| `OPENAI_API_KEY` | OpenAI API key | - |
| `OPENAI_API_BASE` | Custom OpenAI API base URL | - |
| `ANTHROPIC_API_KEY` | Anthropic API key | - |
| `GOOGLE_API_KEY` | Google API key | - |
| `GOOSE_CPU_LIMIT` | CPU limit | `2.00` |
| `GOOSE_MEMORY_LIMIT` | Memory limit | `2G` |
### Working with Your Project
Mount your project directory to work with your code:
```bash
docker compose run --rm -v $(pwd):/workspace goose
```
Or add it to the `docker-compose.yaml` volumes section:
```yaml
volumes:
- ./your-project:/workspace
- goose_config:/home/goose/.config/goose
```
## Persistent Configuration
Configuration and session data are stored in named volumes:
- `goose_config`: User configuration and preferences
- `goose_workspace`: Workspace files and project data
To reset configuration:
```bash
docker compose down -v
```
## Resource Limits
Default resource allocations:
- **CPU Limit**: 2.00 cores
- **CPU Reservation**: 0.50 cores
- **Memory Limit**: 2G
- **Memory Reservation**: 512M
Adjust these in `.env` based on your system capabilities.
## Security Considerations
1. **API Keys**: Never commit your `.env` file with API keys to version control
2. **Workspace Access**: goose has access to files in the mounted workspace directory
3. **Network**: The container runs without exposed ports by default
4. **User Privileges**: Runs as non-root user (UID 1000) for enhanced security
## Supported AI Models
### OpenAI
- `gpt-4` (recommended)
- `gpt-4-turbo`
- `gpt-3.5-turbo`
### Anthropic
- `claude-3-opus`
- `claude-3-sonnet` (recommended)
- `claude-3-haiku`
### Google
- `gemini-pro`
## Troubleshooting
### API Authentication Errors
Ensure your API key is correctly set in `.env` and matches your chosen provider.
### Out of Memory
If you encounter memory issues, increase `GOOSE_MEMORY_LIMIT` in `.env`.
### Build Failures
The initial build may take 15-30 minutes as it compiles goose from source. Ensure you have a stable internet connection.
## References
- [Official GitHub Repository](https://github.com/block/goose)
- [Documentation](https://block.github.io/goose/)
- [Contributing Guide](https://github.com/block/goose/blob/main/CONTRIBUTING.md)
## License
goose is released under the Apache-2.0 License. See the [official repository](https://github.com/block/goose) for details.
This Docker Compose configuration is provided as-is for convenience and follows the project's license terms.

195
builds/goose/README.zh.md Normal file
View File

@@ -0,0 +1,195 @@
# goose
[English Documentation](README.md)
goose 是由 Block 公司开发的 AI 驱动的开发者助手。它通过自然语言交互帮助开发者完成编码任务,提供智能代码生成、调试协助和项目导航功能。
## 功能特性
- **AI 驱动开发**:利用先进的语言模型提供编程协助
- **多 AI 提供商支持**:支持 OpenAI、Anthropic 和 Google AI
- **交互式 CLI**:通过直观的命令行界面与 goose 交互
- **项目理解**:分析和理解您的代码库上下文
- **代码生成**:生成代码片段和实现
- **调试帮助**:协助故障排查和错误解决
## 前置要求
- 已安装 Docker 和 Docker Compose
- 来自受支持的 AI 提供商之一的 API 密钥:
- OpenAI API 密钥(用于 GPT 模型)
- Anthropic API 密钥(用于 Claude 模型)
- Google API 密钥(用于 Gemini 模型)
## 快速开始
1. 复制示例环境文件:
```bash
cp .env.example .env
```
2. 编辑 `.env` 并配置您的 API 凭据:
```bash
# 使用 OpenAI
OPENAI_API_KEY=your_openai_api_key_here
GOOSE_PROVIDER=openai
GOOSE_MODEL=gpt-4
# 或使用 Anthropic
ANTHROPIC_API_KEY=your_anthropic_api_key_here
GOOSE_PROVIDER=anthropic
GOOSE_MODEL=claude-3-sonnet
# 或使用 Google
GOOGLE_API_KEY=your_google_api_key_here
GOOSE_PROVIDER=google
GOOSE_MODEL=gemini-pro
```
3. 构建 Docker 镜像:
```bash
docker compose build
```
4. 运行 goose
```bash
docker compose run --rm goose
```
## 使用示例
### 交互式会话
启动与 goose 的交互式会话:
```bash
docker compose run --rm goose session start
```
### 执行任务
运行特定任务或查询:
```bash
docker compose run --rm goose run "解释 app.py 中的主函数"
```
### 获取帮助
查看可用命令:
```bash
docker compose run --rm goose --help
```
## 配置说明
### 环境变量
| 变量 | 说明 | 默认值 |
| -------------------- | -------------------------------------- | -------- |
| `GOOSE_VERSION` | goose Docker 镜像版本 | `1.18.0` |
| `TZ` | 容器时区 | `UTC` |
| `GOOSE_PROVIDER` | AI 提供商openai、anthropic、google | `openai` |
| `GOOSE_MODEL` | 使用的 AI 模型 | `gpt-4` |
| `OPENAI_API_KEY` | OpenAI API 密钥 | - |
| `OPENAI_API_BASE` | 自定义 OpenAI API 基础 URL | - |
| `ANTHROPIC_API_KEY` | Anthropic API 密钥 | - |
| `GOOGLE_API_KEY` | Google API 密钥 | - |
| `GOOSE_CPU_LIMIT` | CPU 限制 | `2.00` |
| `GOOSE_MEMORY_LIMIT` | 内存限制 | `2G` |
### 使用您的项目
挂载您的项目目录以使用您的代码:
```bash
docker compose run --rm -v $(pwd):/workspace goose
```
或将其添加到 `docker-compose.yaml` 的 volumes 部分:
```yaml
volumes:
- ./your-project:/workspace
- goose_config:/home/goose/.config/goose
```
## 持久化配置
配置和会话数据存储在命名卷中:
- `goose_config`:用户配置和偏好设置
- `goose_workspace`:工作区文件和项目数据
重置配置:
```bash
docker compose down -v
```
## 资源限制
默认资源分配:
- **CPU 限制**2.00 核心
- **CPU 预留**0.50 核心
- **内存限制**2G
- **内存预留**512M
根据您的系统能力在 `.env` 中调整这些值。
## 安全注意事项
1. **API 密钥**:切勿将包含 API 密钥的 `.env` 文件提交到版本控制系统
2. **工作区访问**goose 可以访问挂载的工作区目录中的文件
3. **网络**:默认情况下容器不暴露端口
4. **用户权限**:以非 root 用户UID 1000运行以增强安全性
## 支持的 AI 模型
### OpenAI
- `gpt-4`(推荐)
- `gpt-4-turbo`
- `gpt-3.5-turbo`
### Anthropic
- `claude-3-opus`
- `claude-3-sonnet`(推荐)
- `claude-3-haiku`
### Google
- `gemini-pro`
## 故障排查
### API 认证错误
确保您的 API 密钥在 `.env` 中正确设置,并与您选择的提供商匹配。
### 内存不足
如果遇到内存问题,请在 `.env` 中增加 `GOOSE_MEMORY_LIMIT`。
### 构建失败
初始构建可能需要 15-30 分钟,因为它从源代码编译 goose。请确保您有稳定的互联网连接。
## 参考资料
- [官方 GitHub 仓库](https://github.com/block/goose)
- [文档](https://block.github.io/goose/)
- [贡献指南](https://github.com/block/goose/blob/main/CONTRIBUTING.md)
## 许可证
goose 在 Apache-2.0 许可证下发布。详情请参阅[官方仓库](https://github.com/block/goose)。
此 Docker Compose 配置按原样提供以方便使用,并遵循项目的许可条款。

View File

@@ -0,0 +1,54 @@
# Docker Compose Configuration for goose
# AI-powered developer agent by Block
# https://github.com/block/goose
x-defaults: &defaults
restart: unless-stopped
logging:
driver: json-file
options:
max-size: ${GOOSE_LOG_MAX_SIZE:-100m}
max-file: "${GOOSE_LOG_MAX_FILE:-3}"
services:
goose:
<<: *defaults
build:
context: .
dockerfile: Dockerfile
platforms:
- linux/amd64
- linux/arm64
args:
- GOOSE_VERSION=${GOOSE_VERSION:-1.18.0}
image: ${GLOBAL_REGISTRY:-}alexsuntop/goose:${GOOSE_VERSION:-1.18.0}
environment:
- TZ=${TZ:-UTC}
# OpenAI Configuration
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- OPENAI_API_BASE=${OPENAI_API_BASE:-}
# Anthropic Configuration
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
# Google Configuration
- GOOGLE_API_KEY=${GOOGLE_API_KEY:-}
# Additional environment variables
- GOOSE_PROVIDER=${GOOSE_PROVIDER:-openai}
- GOOSE_MODEL=${GOOSE_MODEL:-gpt-4}
volumes:
- goose_config:/home/goose/.config/goose
- goose_workspace:/workspace
working_dir: /workspace
stdin_open: true
tty: true
deploy:
resources:
limits:
cpus: ${GOOSE_CPU_LIMIT:-2.00}
memory: ${GOOSE_MEMORY_LIMIT:-2G}
reservations:
cpus: ${GOOSE_CPU_RESERVATION:-0.50}
memory: ${GOOSE_MEMORY_RESERVATION:-512M}
volumes:
goose_config:
goose_workspace: