Skip to content

Commit

Permalink
feat: support setup.py, custom requirements.txt on cli python docker
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Dec 27, 2019
1 parent 81de2e2 commit c210602
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions docker/docker-python-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,50 @@

virtualenv -p python snyk
source snyk/bin/activate

exitWithMsg() {
echo "Failed to run the process ..."

if [ -f "$1" ]; then
cat "$1"
else
echo "$1"
fi

exit "$2"
}

PROJECT_SUBDIR=""
echo "Project path = ${PROJECT_PATH}"
if [ -n "${TARGET_FILE}" ]; then
if [ ! -f "${PROJECT_PATH}/${PROJECT_FOLDER}/${TARGET_FILE}" ]; then
exitWithMsg "\"${PROJECT_PATH}/${PROJECT_FOLDER}/${TARGET_FILE}\" does not exist" 1
fi

PROJECT_SUBDIR=$(dirname "${TARGET_FILE}")
MANIFEST_NAME=$(basename "${TARGET_FILE}")
TEST_SETTINGS="--file=${MANIFEST_NAME} "

echo "Target file = ${TARGET_FILE}"

case $MANIFEST_NAME in
*req*.txt)
echo "Installing dependencies from requirements file"
pip install -U -r "${PROJECT_PATH}/$MANIFEST_NAME"
;;
*setup.py)
echo "Installing dependencies from setup.py"
pip install -U -e "${PROJECT_PATH}"
;;
*)
exitWithMsg "\"${PROJECT_PATH}/${TARGET_FILE}\" is not supported" 1
;;
esac
fi

if [ -f "${PROJECT_PATH}/requirements.txt" ]; then
echo "Found requirement.txt"
pip install -U -r "${PROJECT_PATH}/requirements.txt"
elif [ -f "${PROJECT_PATH}/setup.py" ]; then
pip install -U "${PROJECT_PATH}"
fi

bash docker-entrypoint.sh "$@"

0 comments on commit c210602

Please sign in to comment.