将私有库安装到python docker映像
我有git private repo,它是python项目,它有setup.py和setup.cfg 树形结构将私有库安装到python docker映像,python,docker,docker-build,Python,Docker,Docker Build,我有git private repo,它是python项目,它有setup.py和setup.cfg 树形结构 bsNotify/ ├── deployment │ └── dockerfiles │ └── py │ └── Dockerfile ├── setup.cfg ├── setup.py └── src └── bsnotify ├── __init__.py └── resources.py setup
bsNotify/
├── deployment
│ └── dockerfiles
│ └── py
│ └── Dockerfile
├── setup.cfg
├── setup.py
└── src
└── bsnotify
├── __init__.py
└── resources.py
setup.py
setup.cfg
src/bsnotify/init.py
src/bsnotify/resources.py
src中的文件为空
部署/Dockerfile/py/Dockerfile
这很简单,但我不知道为什么当我试图建立形象时它会卡在某个地方
$ docker build -f deployment/dockerfiles/py/Dockerfile .
Sending build context to Docker daemon 60.06MB
Step 1/3 : FROM python:3.7
---> 8e3336637d81
Step 2/3 : ADD . .
---> 287d4e44a735
Step 3/3 : RUN pip3 install --upgrade pip pbr && pip3 install --no-cache-dir --compile --editable .
---> Running in cbf3c92083de
Collecting pip
Downloading pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
Collecting pbr
Downloading pbr-5.4.5-py2.py3-none-any.whl (110 kB)
Installing collected packages: pip, pbr
Attempting uninstall: pip
Found existing installation: pip 20.0.2
Uninstalling pip-20.0.2:
Successfully uninstalled pip-20.0.2
Successfully installed pbr-5.4.5 pip-20.1.1
Obtaining file:///
我等待了1个小时,但它从未通过此获取文件:///,因为容器中的默认目录为root::我建议对Dockerfile进行以下更改
$ cat bsNotify/setup.cfg
[metadata]
name = bsNotify
classifiers =
License :: N/A :: N/A
Programming Language :: Python :: 3.7
[options]
zip_safe = False
include_package_data = True
python_requires = >= 3.7
install_requires =
mongoengine
bson
package_dir=
=src
packages=find:
[options.packages.find]
where=src
[tool:wheel]
universal = 1
[flake8]
exclude =
venv,
.tox,
.git,
__pycache__,
*.pyc,
*.egg-info,
.cache,
.eggs,
max-line-length = 80
[tox]
envlist = py37,unittest,lint
[testenv]
basepython=python3.7
deps =
ipython
pylint
pytest
pytest-cov
pytest-xdist
flake8
flake8-docstrings
[testenv:unittest]
commands=
pytest -v -s -n auto -l --cov=bsnotify --cov-report term-missing --cov-report xml --no-cov-on-fail tests/unit
[testenv:lint]
commands=
flake8 src/bsnotify
pylint src/bsnotify
$ cat bsNotify/src/bsnotify/__init__.py
$ cat bsNotify/src/bsnotify/resources.py
FROM python:3.7
ADD . .
RUN pip3 install --upgrade pip pbr && pip3 install --no-cache-dir --compile --editable .
$ docker build -f deployment/dockerfiles/py/Dockerfile .
Sending build context to Docker daemon 60.06MB
Step 1/3 : FROM python:3.7
---> 8e3336637d81
Step 2/3 : ADD . .
---> 287d4e44a735
Step 3/3 : RUN pip3 install --upgrade pip pbr && pip3 install --no-cache-dir --compile --editable .
---> Running in cbf3c92083de
Collecting pip
Downloading pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
Collecting pbr
Downloading pbr-5.4.5-py2.py3-none-any.whl (110 kB)
Installing collected packages: pip, pbr
Attempting uninstall: pip
Found existing installation: pip 20.0.2
Uninstalling pip-20.0.2:
Successfully uninstalled pip-20.0.2
Successfully installed pbr-5.4.5 pip-20.1.1
Obtaining file:///
FROM python:3.7
# then scope of work is just reduced to this directory
WORKDIR /mypackage
ADD . .
RUN pip3 install --upgrade pip pbr && pip3 install --no-cache-dir --compile --editable .