railwayapp / nixpacks

App source + Nix packages + Docker = Image
https://nixpacks.com
MIT License
2.47k stars 232 forks source link

Issue while creating Docker image for Django application with latest python packages #950

Open basith1993 opened 1 year ago

basith1993 commented 1 year ago

Is there an existing issue for this?

Describe the bug

Facing issue while creating a docker image for django application with the following error:

 [stage-0 6/8] RUN --mount=type=cache,id=VEpalVgQOhk-/root/cache/pip,target=/root/.cache/pip python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt:
66036.40 Collecting s3transfer==0.6.1
66136.42   Downloading s3transfer-0.6.1-py3-none-any.whl (79 kB)
66236.42      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.8/79.8 KB 20.6 MB/s eta 0:00:00
66336.74 Collecting safetensors==0.3.1
66436.75   Downloading safetensors-0.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)
66536.77      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 80.6 MB/s eta 0:00:00
66637.25 ERROR: Could not find a version that satisfies the requirement scipy==1.11.1 (from versions: 0.8.0, 0.9.0, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.12.1, 0.13.0, 0.13.1, 0.13.2, 0.13.3, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 1.0.0, 1.0.1, 1.1.0, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.8.0rc1, 1.8.0rc2, 1.8.0rc3, 1.8.0rc4, 1.8.0, 1.8.1, 1.9.0rc1, 1.9.0rc2, 1.9.0rc3, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0rc1, 1.10.0rc2, 1.10.0, 1.10.1)
66737.25 ERROR: No matching distribution found for scipy==1.11.1
66837.51 WARNING: You are using pip version 22.0.4; however, version 23.2.1 is available.
66937.51 You should consider upgrading via the '/opt/venv/bin/python -m pip install --upgrade pip' command.
670------
671Dockerfile:20
672--------------------
673  18 |     ENV NIXPACKS_PATH /opt/venv/bin:$NIXPACKS_PATH
674  19 |     COPY . /app/.
675  20 | >>> RUN --mount=type=cache,id=VEpalVgQOhk-/root/cache/pip,target=/root/.cache/pip python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt
676  21 |     
677  22 |     
678--------------------
679ERROR: failed to solve: process "/bin/bash -ol pipefail -c python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt" did not complete successfully: exit code: 1
680Error: Docker build failed

To reproduce

  1. Run nixpacks inside any Django project with following requirements.txt
farm-haystack[inference]==1.19.0
absl-py==1.4.0
aiohttp==3.8.4
aiosignal==1.3.1
asgiref==3.7.2
astunparse==1.6.3
async-timeout==4.0.2
attrs==23.1.0
aws==0.2.5
bcrypt==4.0.1
boto==2.49.0
boto3==1.28.16
botocore==1.31.16
cachetools==5.3.1
certifi==2023.5.7
cffi==1.15.1
charset-normalizer==3.1.0
colorama==0.4.6
cryptography==41.0.2
decorator==5.1.1
Django==4.2.3
django-cors-headers==4.1.0
djangorestframework==3.14.0
fabric==3.1.0
filelock==3.12.2
flatbuffers==23.5.26
frozenlist==1.3.3
fsspec==2023.6.0
gast==0.4.0
google-auth==2.22.0
google-auth-oauthlib==1.0.0
google-pasta==0.2.0
grpcio==1.56.2
h5py==3.9.0
huggingface-hub==0.16.4
idna==3.4
invoke==2.2.0
Jinja2==3.1.2
jmespath==1.0.1
keras==2.13.1
libclang==16.0.6
Markdown==3.4.3
MarkupSafe==2.1.3
mpmath==1.3.0
multidict==6.0.4
networkx==3.1
nltk==3.8.1
numpy==1.24.3
oauthlib==3.2.2
openai==0.27.8
openpyxl
opt-einsum==3.3.0
packaging==23.1
pandas==2.0.3
paramiko==3.3.1
prettytable==3.8.0
protobuf==4.23.4
pyasn1==0.5.0
pyasn1-modules==0.3.0
pycparser==2.21
PyNaCl==1.5.0
python-dateutil==2.8.2
python-dotenv==1.0.0
pytz==2023.3
PyYAML==6.0.1
regex==2023.6.3
requests==2.31.0
requests-oauthlib==1.3.1
rsa==4.9
s3transfer==0.6.1
safetensors==0.3.1
scipy==1.11.1
six==1.16.0
sqlparse==0.4.4
sympy==1.12
tensorboard==2.13.0
tensorboard-data-server==0.7.1
tensorflow==2.13.0
tensorflow-estimator==2.13.0
tensorflow-io-gcs-filesystem==0.31.0
termcolor==2.3.0
tiktoken==0.4.0
tokenizers==0.13.3
tqdm==4.65.0
transformers==4.31.0
typing_extensions==4.5.0
tzdata==2023.3
urllib3==1.26.16
wcwidth==0.2.6
Werkzeug==2.3.6
wrapt==1.15.0
yarl==1.9.2
-f https://download.pytorch.org/whl/torch_stable.html
torch==2.0.0+cpu 
torchvision==0.15.1+cpu
torchaudio==2.0.1

Expected behavior

No response

Environment

Install nixpacks on Ubuntu system using: curl -sSL https://nixpacks.com/install.sh | bash

Complete log:

╔══════════════════════════════ Nixpacks v1.13.0 ══════════════════════════════╗
║ setup      │ python38, gcc                                                   ║
║──────────────────────────────────────────────────────────────────────────────║
║ install    │ python -m venv --copies /opt/venv && . /opt/venv/bin/activate   ║
║            │ && pip install -r requirements.txt                              ║
║──────────────────────────────────────────────────────────────────────────────║
║ start      │ python manage.py runserver                                      ║
╚══════════════════════════════════════════════════════════════════════════════╝

#1 [internal] load build definition from Dockerfile
#1 sha256:5c4d52d306bee6c92f87ad4fad3532132af71b2e86c26e9e8463cc1f40cfdc8a
#1 transferring dockerfile:
#1 transferring dockerfile: 905B 0.1s done
#1 DONE 0.3s

#2 [internal] load .dockerignore
#2 sha256:ac706efc854446867acbe4402e6d92da161d66a83a16b02369aa52792f7b984f
#2 transferring context: 2B done

.. .. ..

#11 131.1   Using cached requests_oauthlib-1.3.1-py2.py3-none-any.whl (23 kB)
#11 131.5 Collecting rsa==4.9
#11 131.6   Using cached rsa-4.9-py3-none-any.whl (34 kB)
#11 132.0 Collecting s3transfer==0.6.1
#11 132.0   Using cached s3transfer-0.6.1-py3-none-any.whl (79 kB)
#11 132.5 Collecting safetensors==0.3.1
#11 132.5   Using cached safetensors-0.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)
#11 133.2 ERROR: Could not find a version that satisfies the requirement scipy==1.11.1 (from versions: 0.8.0, 0.9.0, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.12.1, 0.13.0, 0.13.1, 0.13.2, 0.13.3, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 1.0.0, 1.0.1, 1.1.0, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.8.0rc1, 1.8.0rc2, 1.8.0rc3, 1.8.0rc4, 1.8.0, 1.8.1, 1.9.0rc1, 1.9.0rc2, 1.9.0rc3, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0rc1, 1.10.0rc2, 1.10.0, 1.10.1)
#11 133.2 ERROR: No matching distribution found for scipy==1.11.1
#11 133.2 WARNING: You are using pip version 22.0.4; however, version 23.2.1 is available.
#11 133.2 You should consider upgrading via the '/opt/venv/bin/python -m pip install --upgrade pip' command.
#11 ERROR: executor failed running [/bin/bash -ol pipefail -c python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt]: exit code: 1
------
 > [stage-0 6/8] RUN --mount=type=cache,id=HL2UOaTP7BA-/root/cache/pip,target=/root/.cache/pip python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt:
------
executor failed running [/bin/bash -ol pipefail -c python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt]: exit code: 1
Error: Docker build failed
brody192 commented 1 year ago

it's likely that one or more of those packages require a python version greater than 3.8, nixpacks supports up to python 3.11, and to use version 3.11 add 3.11 to a runtime.txt file and place that file in your project.

for any further questions please bring them to Railways discord server

jclaveau commented 11 months ago

Probably same issue while configuring a Directus 10.6 packages. If I remember well, Directus requires python due to node-gyp which may make this issue related to https://github.com/railwayapp/nixpacks/issues/904

nixpacks.toml


providers = ['...', 'python']

[phases.install]
cmds = ['pnpm i --frozen-lockfile']

[start]
cmd = 'pnpm railway:start:backend'

Normally this very light package.json should be enough:

{
  "scripts": {
    "railway:start:backend": "directus bootstrap --skipAdminInit; pnpm directus:schema:apply --yes; directus start",
  },
  "dependencies": {
    "@directus/api": "^11.1.0",
    "directus": "^10.6.1",
  },
}

Please tell me if it's not enough to reproduce the bug