cognition-datasources
cognition-datasources copied to clipboard
Defining PROD_LIBS in same ENV block as PYTHONPATH results in missing `requirements.txt` entries.
The driver/Dockerfile
template has the following definition:
ENV \
PROD_LIBS=/build/prod \
PYTHONPATH=$PYTHONPATH:/$PROD_LIBS/lib/python3.6/site-packages:/home/cognition-datasources/spatial-db/lambda_db \
LAMBDA_DB_PATH=/home/cognition-datasources/spatial-db/lambda_db/database.fs
Due to the way that Docker evaluates environment variable definitions, PROD_LIBS
is not in scope when PYTHONPATH
is set, and therefore the site-packages
under /build/prod
doesn't end up in the PYTHONPATH
. This results in dependencies needed by custom drivers not being available in the run time.
You can verify this outcome by running the following:
$ docker run --rm -v $PWD:/home/cognition-datasources -it earthcache-driver:latest bash
bash-4.2# echo $PYTHONPATH
result:
/var/runtime://lib/python3.6/site-packages:/home/cognition-datasources/spatial-db/lambda_db
The fix is to break out the definition of PROD_LIBS
into a separate layer:
ENV PROD_LIBS=/build/prod
ENV \
PYTHONPATH=$PYTHONPATH:/$PROD_LIBS/lib/python3.6/site-packages:/home/cognition-datasources/spatial-db/lambda_db \
LAMBDA_DB_PATH=/home/cognition-datasources/spatial-db/lambda_db/database.fs