【发布时间】:2022-08-11 20:10:07
【问题描述】:
我有一个私人仓库,我有一个 python 包。我已将包包含在我的 requirements.txt 文件中。当我尝试构建 docker 映像时。我收到以下错误
#14 246.0 WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by \'NewConnectionError(\'<pip._vendor.urllib3.connecction.HTTPConnection object at 0x7fe307604520>: Failed to establish a new connection: [Errno -2] Name does not resolve\')\': //pypi-production.vogorental.com/py-commons/
#14 246.1 ERROR: Could not find a version that satisfies the requirement py-commons==3.8.4 (from versions: 0.1.0, 0.1.2)
#14 246.1 ERROR: No matching distribution found for py-commons==3.8.4
Dockerfile
# syntax=docker/dockerfile:1.0.0-experimental
# The above comment is not to be deleted, its necessary. We are using an experimental feature and above line is important to enable that
# please refer to this, https://medium.com/@tonistiigi/build-secrets-and-ssh-forwarding-in-docker-18-09-ae8161d066 to know more about this
# before building docker image using this dockerfile, please do export DOCKER_BUILDKIT=1
FROM python:3.10-alpine
# This unsets the buffering of the stdout data(PS- I don\'t know what it does, everybody recommended it so I added it)
ENV PYTHONUNBUFFERED 1
ENV LC_ALL en_US.UTF-8
ARG PYPI_USERNAME
ARG PYPI_PASSWORD
ARG PYPI_URL
ENV PYPI_USERNAME=$PYPI_USERNAME
ENV PYPI_PASSWORD=$PYPI_PASSWORD
ENV PYPI_URL=$PYPI_URL
# copying the code
COPY requirements /temp/requirements
COPY api /temp/api
COPY pytest.ini pyproject.toml /temp/
# setting the work directory
WORKDIR /temp/api/
# installing essential packages for building and running packages
# the packages needed for build are later removed while the packages
# needed for running are kept
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN --mount=type=ssh pip install git+ssh://git@github.com:vogolabs/py-commons.git
RUN apk add --no-cache --virtual .build-deps \\
ca-certificates gcc build-base alpine-sdk postgresql-dev linux-headers musl-dev \\
libffi-dev jpeg-dev zlib-dev git \\
&& pip install -r ../requirements/requirements.txt --extra-index-url http://${PYPI_USERNAME}:${PYPI_PASSWORD}@${PYPI_URL} --trusted-host ${PYPI_URL} \\
&& apk --update --upgrade add gcc musl-dev jpeg-dev zlib-dev libffi-dev build-base pango ttf-liberation \\
&& find /usr/local \\
\\( -type d -a -name test -o -name tests \\) \\
-o \\( -type f -a -name \'*.pyc\' -o -name \'*.pyo\' \\) \\
-exec rm -rf \'{}\' + \\
&& runDeps=\"$( \\
scanelf --needed --nobanner --recursive /usr/local \\
| awk \'{ gsub(/,/, \"\\nso:\", $2); print \"so:\" $2 }\' \\
| sort -u \\
| xargs -r apk info --installed \\
| sort -u \\
)\" \\
&& apk add --virtual .rundeps $runDeps \\
&& apk del .build-deps \\
&& rm -rf src/py-commons/.git/
## this command will run on container creation
ENTRYPOINT [\"/bin/sh\", \"start.sh\"]
pip 试图访问全局包而不是私有 repo。如何重定向它以使用我的私人仓库
标签: python dockerfile