如何扩展代码块依赖库

依赖库持久化

以下操作需要在服务运行状态进行,只需完成一次即可

  1. 创建依赖库挂载目录(实际目录可自定义),如:

    mkdir -p /data/mingdao/script/volume/command/package/python-3.6/
    mkdir -p /data/mingdao/script/volume/command/package/nodejs-10.18.0/
    
  2. 获取预置依赖库

    docker cp $(docker ps | grep mingdaoyun-community | awk '{print $1}'):/usr/local/lib/python3.6/site-packages/ /data/mingdao/script/volume/command/package/python-3.6/
    docker cp $(docker ps | grep mingdaoyun-community | awk '{print $1}'):/usr/local/node-10.18.0/lib/node_modules/ /data/mingdao/script/volume/command/package/nodejs-10.18.0/
    
  3. 修改 docker-compose.yaml,将宿主机的依赖库目录挂载到容器内

    volumes:
      - ./volume/command/package/python-3.6/site-packages/:/usr/local/lib/python3.6/site-packages/
      - ./volume/command/package/nodejs-10.18.0/node_modules/:/usr/local/node-10.18.0/lib/node_modules/
    
  4. 安装管理器根目录下执行以下命令,重启服务

     bash ./service.sh restartall
    

扩展库安装

Python

如安装 python-dateutil 扩展库:

docker exec -t $(docker ps | grep mingdaoyun-community | awk '{print $1}') bash -c 'pip3 install python-dateutil'

安装完成后可在宿主机目录 /data/mingdao/script/volume/command/package/python-3.6/site-packages/ 中进行查看。

JavaScript (基于 Nodejs)

如安装 dayjs 扩展包:

docker exec -t $(docker ps | grep mingdaoyun-community | awk '{print $1}') bash -c '/usr/local/node-10.18.0/bin/npm -g install dayjs'

安装完成后可在宿主机目录 /data/mingdao/script/volume/command/package/nodejs-10.18.0/node_modules/ 中进行查看。

results matching ""

    No results matching ""