Skip to content

Commit ea8afa5

Browse files
committed
update
1 parent 4510a3b commit ea8afa5

File tree

5 files changed

+20
-70
lines changed

5 files changed

+20
-70
lines changed

.github/workflows/docker.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ jobs:
5454
tags: |
5555
type=raw,value=latest,priority=500
5656
type=raw,value=${{ github.run_number }},priority=400
57-
type=ref,event=branch
58-
type=ref,event=pr
59-
type=sha,prefix={{branch}}-
6057
6158
- name: Build and push Docker image
6259
id: build-and-push

Dockerfile

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ RUN groupadd -g 1000 python && \
88
RUN apt-get update && \
99
apt-get install -y --no-install-recommends \
1010
ca-certificates \
11-
curl \
12-
git \
13-
tini \
14-
gosu \
15-
build-essential && \
11+
tini && \
1612
rm -rf /var/lib/apt/lists/*
1713

1814
# 安装 Python LSP Server
@@ -24,15 +20,10 @@ ENV UID=1000 USER=python \
2420
PYTHON_VERSION=3.11 \
2521
LSP_VERSION=latest
2622

27-
# 复制入口脚本
28-
COPY ./entrypoint.sh /entrypoint.sh
29-
RUN chmod +x /entrypoint.sh
30-
3123
# 切换到非 root 用户
3224
USER python
3325

3426
# 设置工作目录
3527
WORKDIR /home/python
3628

37-
ENTRYPOINT ["/entrypoint.sh"]
3829
CMD ["pylsp"]

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
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
9890
docker 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
# 构建镜像
124122
docker 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+
# 运行容器(交互模式)
127128
docker run --rm -it docker-lsp-python:latest
128129
```
129130

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
volumes:
1313
- ~/.cache/python-lsp:/home/python/.cache
1414
- ~/.config/python-lsp:/home/python/.config
15-
- .:/workspace
15+
- ./workspace:/workspace
1616
working_dir: /workspace
1717
command:
1818
- pylsp

entrypoint.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)