Common Dockerfile for CVP-Sanity and CVP-SPT
Related-Task: #PROD-26312(PROD:26312)
Change-Id: I457a8d5c6ff73d944518f6b0c2c568f8286728a9
diff --git a/bin/entrypoint.sh b/bin/entrypoint.sh
index 99cd175..a925b49 100755
--- a/bin/entrypoint.sh
+++ b/bin/entrypoint.sh
@@ -10,5 +10,22 @@
set -x
}
-_info
-exec "$@"
+function activate_venv(){
+ set +x
+ if [ -f venv/bin/activate ]; then
+ echo "Activating venv in $(pwd)"
+ source venv/bin/activate && echo "Activated succesfully"
+ else
+ echo "WARNING: No venv found in $(pwd)"
+ return 1
+ fi
+}
+
+echo "$@"
+if [ "$1" = "pytest" ] || [ "$1" = "python" ] || [ "$1" = "pip" ]; then
+ activate_venv &&
+ _info &&
+ exec "$@"
+else
+ exec "$@"
+fi