基于 Docker 的 Python Language Server Protocol (LSP) 环境,提供轻量化的 Python LSP Server 容器。
- 基于 Python 3.11 的 Python LSP Server
- 包含完整的 Python LSP 插件生态
- 最小化系统依赖,轻量化镜像
- 非 root 用户运行,确保安全性
- 自动化的 Docker 镜像构建和发布
- 支持多架构构建(amd64, arm64)
预构建的镜像可在 GHCR 获取。您可以直接拉取并运行:
docker pull ghcr.io/reaslab/docker-lsp-python:latest
docker run --rm -it ghcr.io/reaslab/docker-lsp-python:latest
镜像标签 | 描述 |
---|---|
latest |
最新版本(Python 3.11 + 最新 LSP) |
{timestamp} |
构建时间戳标签(如 20241201-143022 ) |
容器支持标准的环境变量配置,如 PYTHONPATH
等。
示例:
docker run -e PYTHONPATH=/app ghcr.io/reaslab/docker-lsp-python:latest
version: '3.8'
services:
python-lsp:
image: ghcr.io/reaslab/docker-lsp-python:latest
ports:
- "2087:2087"
volumes:
- ~/.cache/python-lsp:/home/python/.cache
- ~/.config/python-lsp:/home/python/.config
- .:/app
working_dir: /app
command:
- pylsp
- --tcp
- --port
- "2087"
- --host
- "0.0.0.0"
- 克隆仓库:
git clone https://github.com/reaslab/docker-lsp-python.git
cd docker-lsp-python
- 构建镜像:
docker build -t docker-lsp-python:latest .
- 运行容器:
docker run --rm -it docker-lsp-python:latest
您可以通过挂载卷来自定义 LSP 配置:
docker run -v /path/to/your/config.json:/home/python/.config/python-lsp/config.json ghcr.io/reaslab/docker-lsp-python:latest
- 代码检查: pycodestyle, pyflakes, mccabe
- 代码格式化: autopep8, yapf
- 代码补全: jedi
- 类型检查: pylint(默认禁用)
- 其他: preload, rope
镜像包含最小化的系统依赖:
ca-certificates
: SSL 证书支持tini
: 进程管理器,正确处理信号
此项目使用 GitHub Actions 进行自动化构建:
- 推送构建: 推送到 main 分支时自动构建
- 手动构建: 通过 workflow_dispatch 手动触发
- 多架构支持: 同时构建 amd64 和 arm64 架构
- 标签策略:
latest
为最新版本,{timestamp}
为构建时间戳
# 构建镜像
docker build -t docker-lsp-python:latest .
# 运行容器(TCP 模式)
docker run --rm -p 2087:2087 docker-lsp-python:latest pylsp --tcp --port 2087 --host 0.0.0.0
# 运行容器(交互模式)
docker run --rm -it docker-lsp-python:latest
本项目采用 MIT 许可证。详见 LICENSE 文件。
欢迎提交 Issue 和 Pull Request!
- python-lsp-server - Python LSP Server 实现