11# docker-lsp-python
22
3- 基于 Docker 的 Python Language Server Protocol (LSP) 环境,支持多版本 Python 和 Python LSP Server。
3+ 基于 Docker 的 Python Language Server Protocol (LSP) 环境,提供轻量化的 Python LSP Server 容器 。
44
55## 特性
66
77- 基于 Python 3.11 的 Python LSP Server
88- 包含完整的 Python LSP 插件生态
9- - 用户和组管理,确保安全的文件权限
9+ - 最小化系统依赖,轻量化镜像
10+ - 非 root 用户运行,确保安全性
1011- 自动化的 Docker 镜像构建和发布
1112- 支持多架构构建(amd64, arm64)
1213
@@ -30,16 +31,12 @@ docker run --rm -it ghcr.io/reaslab/docker-lsp-python:latest
3031
3132### 环境变量
3233
33- ` entrypoint.sh ` 脚本支持以下环境变量:
34-
35- - ` USER ` , ` GROUP ` : 设置容器内的用户名/组名(默认:` python ` )
36- - ` UID ` , ` GID ` : 设置用户/组 ID(默认:1000)
37- - ` XDG_CACHE_HOME ` : 设置自定义缓存目录(默认:` /home/python/.cache ` )
34+ 容器支持标准的环境变量配置,如 ` PYTHONPATH ` 等。
3835
3936示例:
4037
4138``` sh
42- docker run -e USER=myuser -e UID=1234 ghcr.io/reaslab/docker-lsp-python:latest
39+ docker run -e PYTHONPATH=/home/python ghcr.io/reaslab/docker-lsp-python:latest
4340```
4441
4542### 使用 Docker Compose
@@ -54,13 +51,8 @@ services:
5451 volumes :
5552 - ~/.cache/python-lsp:/home/python/.cache
5653 - ~/.config/python-lsp:/home/python/.config
57- - ./workspace:/workspace
58- working_dir : /workspace
59- environment :
60- - USER=python
61- - UID=1000
62- - GROUP=python
63- - GID=1000
54+ - ./workspace:/home/python/workspace
55+ working_dir : /home/python/workspace
6456 command :
6557 - pylsp
6658 - --tcp
@@ -92,7 +84,7 @@ docker run --rm -it docker-lsp-python:latest
9284
9385### LSP 配置
9486
95- 容器包含默认的 LSP 配置,位于 ` /home/python/.config/python-lsp/config.json ` 。您可以通过挂载卷来自定义配置 :
87+ 您可以通过挂载卷来自定义 LSP 配置:
9688
9789``` sh
9890docker run -v /path/to/your/config.json:/home/python/.config/python-lsp/config.json ghcr.io/reaslab/docker-lsp-python:latest
@@ -106,6 +98,12 @@ docker run -v /path/to/your/config.json:/home/python/.config/python-lsp/config.j
10698- ** 类型检查** : pylint(默认禁用)
10799- ** 其他** : preload, rope
108100
101+ ### 系统依赖
102+
103+ 镜像包含最小化的系统依赖:
104+ - ` ca-certificates ` : SSL 证书支持
105+ - ` tini ` : 进程管理器,正确处理信号
106+
109107## 自动化构建
110108
111109此项目使用 GitHub Actions 进行自动化构建:
@@ -123,7 +121,10 @@ docker run -v /path/to/your/config.json:/home/python/.config/python-lsp/config.j
123121# 构建镜像
124122docker build -t docker-lsp-python:latest .
125123
126- # 运行容器
124+ # 运行容器(TCP 模式)
125+ docker run --rm -p 2087:2087 docker-lsp-python:latest pylsp --tcp --port 2087 --host 0.0.0.0
126+
127+ # 运行容器(交互模式)
127128docker run --rm -it docker-lsp-python:latest
128129```
129130
0 commit comments