From 7282f6230545afd64c529597ef90c033299a46f4 Mon Sep 17 00:00:00 2001 From: brokun Date: Fri, 15 Nov 2024 16:39:59 +0800 Subject: [PATCH] chore: provider a docker image with ull feature supports --- Dockerfile | 9 +++++++-- docker/jupyter_server_config.py | 28 ++++++++++++++++++++++++++++ docker/start.sh | 8 ++++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8307487..b598a11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ -# 使用 python 3.11 作为基础镜像 -FROM python:3.11-slim-bookworm +# 使用 python 3.11 nodejs 20作为基础镜像 +FROM nikolaik/python-nodejs:python3.11-nodejs20-slim # 创建 ADMIN 用户并设置其为非特权用户 RUN useradd -m admin # 安装 libro 包 RUN pip install libro +RUN pip install libro-flow +RUN npm install @difizen/libro-analyzer -g # 创建 Jupyter 配置目录和工作区目录 RUN mkdir -p /home/admin/.jupyter /home/admin/workspace @@ -28,5 +30,8 @@ USER admin # 设置工作目录为 admin 用户的主目录 WORKDIR /home/admin +# 设置容器的默认端口 +EXPOSE 6780 + # 使用 ENTRYPOINT 来设置启动脚本 ENTRYPOINT ["/home/admin/start.sh"] diff --git a/docker/jupyter_server_config.py b/docker/jupyter_server_config.py index 43182f3..9565be9 100644 --- a/docker/jupyter_server_config.py +++ b/docker/jupyter_server_config.py @@ -1779,3 +1779,31 @@ # "display_name": "libro-analyzer", # }, # } + + +c.LanguageServerManager.autodetect = False +# c is a magic, lazy variable +c.LanguageServerManager.language_servers = { + "ruff-lsp": { + # if installed as a binary + "argv": [ + "ruff-lsp", + ], + "languages": ["python"], + "version": 2, + "mime_types": ["text/x-python"], + "display_name": "ruff-lsp", + }, + "libro-analyzer": { + # if installed as a binary + "argv": [ + "node", + "/usr/local/lib/node_modules/@difizen/libro-analyzer/index.js", + "--stdio", + ], + "languages": ["python"], + "version": 2, + "mime_types": ["text/x-python"], + "display_name": "libro-analyzer", + }, +} diff --git a/docker/start.sh b/docker/start.sh index dc47ab3..4b22ac9 100644 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,10 +1,14 @@ #!/bin/bash +# PORT 默认值为 6780 +LIBRO_PORT=6780 # 检查 PORT 环境变量是否设置 if [ -z "$PORT" ]; then echo "PORT 环境变量未设置" - exit 1 +else + echo "PORT 环境变量设置为 $PORT" + LIBRO_PORT=$PORT fi # 启动 libro,并将 PORT 环境变量传递给它 -exec libro --port="$PORT" --notebook-dir="/home/admin/workspace" +exec libro --port="$LIBRO_PORT" --notebook-dir="/home/admin/workspace"