serverless / serverless-python-requirements

⚡️🐍📦 Serverless plugin to bundle Python packages
MIT License
1.09k stars 289 forks source link

Incorrectly reports that docker is not found on docker-container error #785

Open jfgordon2 opened 11 months ago

jfgordon2 commented 11 months ago

Are you certain it's a bug?

Are you using the latest plugin release?

Is there an existing issue for this?

Issue description

Currently, if an error is raised within a docker container (such as missing python bin), then the error raised to the user is docker not found! Please install it even if it exists. Found by referencing a python3.9 image while using serverless file configured for python3.8.

This error is misleading, as it leads a developer to investigate getting the docker CLI onto their path within their development environment, rather than correctly investigating the issue within the container.

Service configuration (serverless.yml) content

service: aws-python-rest-api

frameworkVersion: '3'

plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    usePipenv: true
    usePoetry: false
    dockerImage: public.ecr.aws/sam/build-python3.9:latest-x86_64
    dockerizePip: true

provider:
  name: aws
  runtime: python3.8

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: /
          method: get

Command name and used flags

serverless package

Command output

Run serverless package --verbose

Packaging aws-python-rest-api for stage dev (us-east-1)

Generating requirements.txt from Pipfile
Parsed requirements.txt from Pipfile in /home/runner/work/example/example/.serverless/requirements.txt
Installing requirements from "/home/runner/.cache/serverless-python-requirements/487616df2faf4e5d7376ec4f48b2975119acdddd9b98f821e416bc7e8e11d57f_x86_64_slspyc/requirements.txt"
Docker Image: public.ecr.aws/sam/build-python3.9:latest-x86_64
Using download cache directory /home/runner/.cache/serverless-python-requirements/downloadCacheslspyc
Running docker run --rm -v /home/runner/.cache/serverless-python-requirements/487616df2faf4e5d7376ec4f48b2975119acdddd9b98f821e416bc7e8e11d57f_x86_64_slspyc\:/var/task\:z -v /home/runner/.cache/serverless-python-requirements/downloadCacheslspyc\:/var/useDownloadCache\:z public.ecr.aws/sam/build-python3.9\:latest-x86_64 /bin/sh -c 'chown -R 0\\:0 /var/useDownloadCache && python3.8 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache && chown -R 1000\\:1000 /var/task && chown -R 1000\\:1000 /var/useDownloadCache && find /var/task -name \\*.so -exec strip \\{\\} \\;'...
Environment: linux, node 20.5.1, framework 3.33.0 (local), plugin 6.2.3, SDK 4.3.2
Credentials: Local, environment variables
Docs:        docs.serverless.com
Support:     forum.serverless.com
Error:
docker not found! Please install it
Bugs:        github.com/serverless/serverless/issues

Environment information

Framework Core: 3.33.0 (local)
Plugin: 6.2.3
SDK: 4.3.2
douglasmoraisdev commented 2 months ago

I have exactly the same error using Ubuntu and MacOS