如何扩展代码块依赖库
依赖库持久化
以下操作需要在服务运行中状态下进行,仅需首次完成一次即可,后续安装扩展库时无需操作
-
创建依赖库挂载目录(实际目录可自定义),如:
mkdir -p /data/mingdao/script/volume/command/package/python-3.6/
mkdir -p /data/mingdao/script/volume/command/package/nodejs-10.18.0/ -
获取预置依赖库
- 微服务版本>=5.1.0
- 微服务版本<5.1.0
docker cp $(docker ps | grep command | awk '{print $1}'):/usr/local/lib/python3.6/site-packages/ /data/mingdao/script/volume/command/package/python-3.6/
docker cp $(docker ps | grep command | awk '{print $1}'):/usr/local/node-10.18.0/lib/node_modules/ /data/mingdao/script/volume/command/package/nodejs-10.18.0/docker cp $(docker ps | grep 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 community | awk '{print $1}'):/usr/local/node-10.18.0/lib/node_modules/ /data/mingdao/script/volume/command/package/nodejs-10.18.0/ -
修改
docker-compose.yaml
,将宿主机的依赖库目录挂载到容器内- 微服务版本>=5.1.0
- 微服务版本<5.1.0
services:
command:
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/services:
app:
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/