我负责将旧项目从pip迁移到pipenv。
构建完成后,将不安装依赖项。
任何线索为什么会这样?
顺便说一句,我们尝试从容器内的pipenv shell安装所有依赖项
DockerFile
FROM python:3.7-alpine
ENV PYTHONUNBUFFERED 1
RUN apk update \
# psycopg2 dependencies
&& apk add --virtual build-deps gcc g++ python3-dev musl-dev \
&& apk add postgresql-dev \
# Pillow dependencies
&& apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
# CFFI dependencies
&& apk add libffi-dev py-cffi \
# Translations dependencies
&& apk add gettext \
# https://docs.djangoproject.com/en/dev/ref/django-admin/#dbshell
&& apk add postgresql-client
# && apk add libxml2-dev libxslt-dev linux-headers gettext-dev
#for geodjango
RUN apk add --no-cache --virtual .build-deps-edge \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
gdal-dev geos-dev proj-dev gdal geos proj libcrypto1.1
# Install packages
RUN apk add --no-cache libcurl
RUN pip install pipenv
# Needed for pycurl
ENV PYCURL_SSL_LIBRARY=openssl
# Install packages only needed for building, install and clean on a single layer
RUN apk add --no-cache --virtual .build-dependencies build-base curl-dev \
&& apk add libxml2-dev libxslt-dev linux-headers gettext-dev \
&& pip install pycurl \
&& apk del .build-dependencies
RUN apk add --update chromium
ENV CHROME_BIN=/usr/bin/chromium-browser
ENV CHROME_PATH=/usr/lib/chromium/
ENV PIPENV_DEFAULT_PYTHON_VERSION = 3.7.5
RUN apk add chromium-chromedriver
COPY ./requirements /requirements
COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r//' /entrypoint
RUN chmod +x /entrypoint
COPY ./compose/local/django/start /start
RUN sed -i 's/\r//' /start
RUN chmod +x /start
WORKDIR /app
ONBUILD COPY Pipfile Pipfile
ONBUILD COPY Pipfile.lock Pipfile.lock
RUN pipenv install --three
RUN pipenv lock > requirements.txt
ENTRYPOINT ["/entrypoint"]
Pipfile
BTW,此文件不是由终端手动创建的。所有依赖项均从local.txt文件导入]
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
aniso8601="~=3.0.2"
argon2-cffi="~=19.1.0" # https://github.com/hynek/argon2_cffi
googlemaps="~=3.0.2"
graphene="~=2.1.5"
graphene-django="~=2.3.0"
graphql-core="~=2.1"
graphql-relay="~=0.4.5"
numpy="~=1.16.3"
pandas="~=0.24.2"
promise="~=2.2.1"
psycopg2-binary="~=2.8.2"
pytz="~=2019.1"
requests="~=2.21.0"
Rx="~=1.6.1"
singledispatch="~=3.4.0.3"
six="~=1.12.0"
sqlparse="~=0.3.0"
sentry-sdk="~=0.7.14" # it should be only in production
beautifulsoup4="~=4.7.1"
# Django
# ------------------------------------------------------------------------------
django = "~=2.2"
django-constance = "~=2.4.0"
django-environ="~=0.4.5"
django-graphql-geojson="~=0.1.4"
django-picklefield="~=2.0"
django-graphql-jwt="~=0.2.2"
# recommendations are commented
ipdb="~=0.11" # https://github.com/gotcha/ipdb
# Sphinx=1.8.2 # https://github.com/sphinx-doc/sphinx
# Testing
# ------------------------------------------------------------------------------
mypy="~=0.650" # https://github.com/python/mypy
pytest="~=4.0.2" # https://github.com/pytest-dev/pytest
pytest-sugar="~=0.9.2" # https://github.com/Frozenball/pytest-sugar
# Code quality
# ------------------------------------------------------------------------------
# flake8=3.6.0 # https://github.com/PyCQA/flake8
# coverage=4.5.2 # https://github.com/nedbat/coveragepy
# Django
# ------------------------------------------------------------------------------
# factory-boy=2.11.1 # https://github.com/FactoryBoy/factory_boy
django-debug-toolbar="~=1.11" # https://github.com/jazzband/django-debug-toolbar
django-extensions="~=2.1.6"
# django-coverage-plugin=1.6.0 # https://github.com/nedbat/django_coverage_plugin
pytest-django="~=3.4.4" # https://github.com/pytest-dev/pytest-django
pycurl="~=7.43.0.3"
wptools="~=0.4.17"
# For the Soap Client
# ------------------------------------------------------------------------------
lxml="~=4.4.1"
zeep="~=3.4.0"
# For Selenium
# ------------------------------------------------------------------------------
# urllib3=1.25.3
selenium="~=3.141.0"
[dev-packages]
[requires]
python_version = "==3.7.5"
[当我通过ssh输入到容器并尝试运行pipenv图时,没有显示任何内容
我的猜测是ONBUILD:“当图像用作另一个构建的基础时,ONBUILD指令会在图像上添加一个触发指令,以便稍后执行。”
因此,只需删除ONBUILD(即执行COPY而不是ONBUILD COPY),看看是否有帮助。