-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add pipfile support to docker image #808
Conversation
docker/docker-python-entrypoint.sh
Outdated
source snyk/bin/activate | ||
pip install -U -r "${PROJECT_PATH}/requirements.txt" | ||
elif [ -f "${PROJECT_PATH}/Pipfile" ]; then | ||
cd "${PROJECT_PATH}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this command would change the state of whatever gets executed afterwards. Not sure how to test this with confidence, maybe just install at the full path without cd
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially tried to install with full path but was getting:
✔ Successfully created virtual environment! Virtualenv location: /home/node/.local/share/virtualenvs/node-lHasYD0_ Creating a Pipfile for this project… Installing /project/Pipfile… WARNING: Invalid requirement, parse error at "'/project'" ✘ Installation Failed Failed to run the process ... Failed to test pip project
Will serarch the docs to see if I can find a more efficent way to do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Don’t think this is a ‘no go’, just worth seeing if we can keep the simplicity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To enter the directory, and then return from whence you came, you could replace this with:
pushd "${PROJECT_PATH}"
Then after running pipenv run popd
docker/docker-python-entrypoint.sh
Outdated
pip install -U -r "${PROJECT_PATH}/requirements.txt" | ||
elif [ -f "${PROJECT_PATH}/Pipfile" ]; then | ||
cd "${PROJECT_PATH}" | ||
pipenv install Pipfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using pipenv install
here has some interesting side effects that I don't think are desirable here. Consider the case you have a Pipfile and a Pipfile.lock.
My understanding is that pipenv install
will install all dependencies, and update pipfile.lock
with the versions it used. So it's not checking what you've checked in.
pipenv sync
will install the exact versions specified in pipfile.lock and I think is a better solution when you detect a lock file.
The logic I have for this in the experimental images I'm plating with is https://github.com/garethr/snyk-images/blob/master/docker-entrypoint.sh#L14-L35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info, will update the PR :)
Why not use glob to match python custom |
@dkontorovskyy Would you match all .txt files? Or just |
All |
@dkontorovskyy I thought about it more and I'm probably for keeping it for |
Note that the new, experimental, set of images supports these use cases out of the box. https://github.com/snyk/snyk-images
More details in the README: https://github.com/snyk/snyk-images#running-bootstrap-commands It may be worth trying that out. |
What does this PR do?
Add pipfile support to dockerfile
Test Locally
docker build -t pipfiletest -f Dockerfile.python-3 . docker run -it -e SNYK_TOKEN=<INSERT_TOKEN> -v $PWD:/project pipfiletest:latest -d test
https://github.com/snyk/snyk/issues/786