lym 29aa482154 update cicd | 4 月之前 | |
---|---|---|
test | 4 月之前 | |
.drone.yml | 9 月之前 | |
.gitignore | 9 月之前 | |
Dockerfile | 9 月之前 | |
README.MD | 9 月之前 | |
dockerBuild.sh | 9 月之前 | |
handleManager.py | 4 月之前 | |
index.html | 4 月之前 | |
main.py | 9 月之前 | |
requirements.txt | 9 月之前 |
requirements.txt 自动生成
安装
pip install pipreqs
执行
pipreqs . --encoding=utf8 --force
构建 Docker
# 1 将项目依赖库(即本地python环境)进行导出, 使用如下命令:
pipreqs . --encoding=utf8 --force
# 2. shell 时候下载,而非dockerfile构建时候下载,python项目所需依赖包到指定文件夹py_pkgs:
# pip download -d py_pkgs -r requirments.txt
# pip install --no-index --find-links=py_pkgs -r requirements.txt
# 3. 在宿主机上, 新建文件夹, 以spider_py_client文件夹为例, 放入如下内容:
# spider_py_client (作为Python项目根目录)
# |- modules (modules文件夹: 其中的内容是Python项目子目录文件)
# |- run.py (Python项目的执行入口)
# |- requirements.txt (步骤2生成的项目依赖列表)
# |- Dockerfile.txt (步骤4即将编写的文件)
# 4. 编写Dockerfile, 创建一个文件叫Dockerfile(已有)
# touch Dockerfile
# 5. 切换到代码路径下
cd /usr/lym/spider_py_client
# 6. 构建
docker build --no-cache -t="spider_py_client:latest" -t="spider_py_client:0.1" .
# 7. 查看
docker images
spider_py_client (作为Python项目根目录)
|- modules (modules文件夹: 其中的内容是Python项目子目录文件)
|- run.py (Python项目的执行入口)
|- requirements.txt (步骤2生成的项目依赖列表)
|- Dockerfile.txt (步骤4即将编写的文件)