展示 HN:在 Docker 中运行任何语言的 LLM,无需预构建容器
Show HN: Run LLMs in Docker for any language without prebuilding containers

原始链接: https://github.com/mheap/agent-en-place

## Agent-en-Place:按需AI编码环境 Agent-en-Place 通过自动构建和运行带有正确开发工具版本的 Docker 容器,简化了使用 Copilot 和 OpenAI 的 Codex 等 AI 编码工具。它会检测项目配置文件(如 `.tool-versions`、`mise.toml` 以及特定于语言的版本文件)中所需的工具(Node.js、Python、Ruby、Go 等)。 该工具随后基于 Debian 12-slim 构建一个 Docker 镜像,包含 `mise` 用于运行时管理以及检测到的工具。用户通过 shell 函数 (`vibe `) 访问这些环境,该函数会在容器*内部*启动所选的 AI 工具。 主要功能包括自动版本检测、Docker 镜像缓存以及对多个 AI 提供商的支持。`--debug` 和 `--rebuild` 等选项有助于故障排除和自定义,而 `--dockerfile` 允许检查生成的 Dockerfile。它需要 Docker、Go 1.21+,以及对于 Copilot,`gh` CLI。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 展示 HN:在 Docker 中运行任何语言的 LLM,无需预构建容器 (github.com/mheap) 7 分,作者 mheap 2 小时前 | 隐藏 | 过去 | 收藏 | 讨论 我一直在寻找一种安全运行 LLM 的方法,而无需批准每个命令。有很多项目在 Docker 中运行代理,但它们并不总是包含我需要的依赖项。然后我意识到,我已经使用 mise 定义项目依赖项了。如果我们能通过读取 mise 配置为任何项目动态构建容器呢? 我已经使用 agent-en-place 几周了,效果很好!我很想听听大家的想法。 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系方式 搜索:
相关文章

原文

Build on-demand Docker containers for projects + agentic coding using mise.

  • Docker (installed and running)
  • Go 1.21+ (for building from source)
  • Bash or Zsh shell
  • gh CLI (required for GitHub Copilot provider only)
brew install mheap/tap/agent-en-place
git clone https://github.com/mheap/agent-en-place
cd agent-en-place
go build
# Move binary to your PATH
mv agent-en-place /usr/local/bin/

Download the latest release for your platform from GitHub Releases.

Define a function in your .bashrc / .zshrc / other shell config file

function vibe() { bash -lc "$(agent-en-place $1)" }

Then in any directory, run vibe <provider>

The tool will:

  1. Detect tool versions from your project's configuration files
  2. Build a Docker image with those tools (or reuse cached image)
  3. Generate and execute a docker run command
  4. Launch the selected AI coding tool in the container

agent-en-place automatically detects tool versions from multiple configuration file formats:

.tool-versions (asdf/mise format)

node 20.11.0
python 3.12.0
ruby 3.3.0

mise.toml (mise native format)

[tools]
node = "20.11.0"
python = "3.12.0"

The tool also recognizes language-specific version files:

File Language Example
.nvmrc Node.js 20.11.0
.node-version Node.js 20.11.0
.python-version Python 3.12.0
.ruby-version Ruby 3.3.0
Gemfile Ruby ruby "3.3.0"
.go-version Go 1.21.0
.java-version Java 17
.sdkmanrc Java java=17.0.2
.crystal-version Crystal 1.10.0
.exenv-version Elixir 1.15.0
.yvmrc Yarn 1.22.19

Note: Node.js is automatically included if not specified, as it's required by all supported AI coding tools.

Currently supported providers:

  • Package: @openai/codex
  • Command: codex --dangerously-bypass-approvals-and-sandbox
  • Requirements: None
  • Configuration: Stored in ~/.codex
  • Package: opencode-ai
  • Command: opencode
  • Requirements: None
  • Configuration: Stored in ~/.config/opencode/ and ~/.local/share/opencode/
  • Package: @github/copilot
  • Command: copilot --allow-all-tools --allow-all-paths --allow-all-urls
  • Requirements: gh CLI authenticated with gh auth login
  • Configuration: Stored in ~/.copilot
  • Environment: Automatically uses GH_TOKEN from gh CLI
  1. Configuration Detection: Scans current directory for .tool-versions, mise.toml, and idiomatic version files
  2. Version Parsing: Extracts tool names and versions from configuration files
  3. Dockerfile Generation: Creates a Debian 12-slim based Dockerfile with:
    • mise runtime manager
    • All detected development tools at specified versions
    • Non-root user (UID 1000) for security
  4. Image Building: Builds Docker image (or reuses cached image if unchanged)
    • Image naming: mheap/agent-en-place:<tool1>-<version1>-<tool2>-<version2>-...
  5. Container Execution: Outputs docker run command with:
    • Current directory mounted to /workdir
    • Provider config directory mounted (e.g., ~/.copilot)
    • Appropriate environment variables set

--debug

Show Docker build output instead of hiding it. Useful for troubleshooting build failures.

agent-en-place --debug opencode

--rebuild

Force rebuilding the Docker image even if it already exists. Useful when you want to pull latest tool versions.

agent-en-place --rebuild copilot

--dockerfile

Print the generated Dockerfile and exit without building. Useful for debugging or customization.

agent-en-place --dockerfile codex
agent-en-place --debug --rebuild opencode

MIT License

联系我们 contact @ memedata.com