Skip to content

reaslab/docker-lsp-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-lsp-python

基于 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

使用 Docker Compose

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"

本地开发

  1. 克隆仓库:
git clone https://github.com/reaslab/docker-lsp-python.git
cd docker-lsp-python
  1. 构建镜像:
docker build -t docker-lsp-python:latest .
  1. 运行容器:
docker run --rm -it docker-lsp-python:latest

配置

LSP 配置

您可以通过挂载卷来自定义 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!

相关项目

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages