Deploy an Application Including the GDAL Library
The GDAL library is often used in application needing to manipulate geospatial data. This page describes the steps to deploy an application on Scalingo which makes use of the GDAL library.
Install GDAL on a Scalingo Application
To install the GDAL library on a Scalingo application, you need to make use of the APT buildpack. Such a buildpack should be used as part of a multi-buildpack. For instance, if your application is developed using the Python programming language:
$ echo 'https://github.com/Scalingo/apt-buildpack' > .buildpacks
$ echo 'https://github.com/Scalingo/python-buildpack' >> .buildpacks
$ git add .buildpacks
$ git commit -m 'Add multi-buildpack'
You need to instruct the APT buildpack to install the GDAL library. Create a Aptfile
at the root of your project with the following content:
gdal-bin
libgdal-dev
Last, set the following environment variables on your application:
PYTHONPATH=/app/.apt/usr/lib/python3/dist-packages/
LD_LIBRARY_PATH=/app/.apt/usr/lib/x86_64-linux-gnu/blas/:/app/.apt/usr/lib/x86_64-linux-gnu/lapack/
PROJ_LIB=/app/.apt/usr/share/proj
Deploy your application, it is ready to use the GDAL library!
GDAL with Django
The GDAL library won’t be accessible during the build so the django collectstatic step will fail. A solution is to disable the collectstatic feature during the build with the following environment variable:
DISABLE_COLLECTSTATIC=1
Then you will be able to trigger the collectstatic after the build by creating a post_compile script like this:
#!/bin/sh
export PYTHONPATH=/build/${REQUEST_ID}/.apt/usr/lib/python3/dist-packages/:{PYTHONPATH}
export LD_LIBRARY_PATH=/build/${REQUEST_ID}/.apt/usr/lib/x86_64-linux-gnu/blas/:/build/${REQUEST_ID}/.apt/usr/lib/x86_64-linux-gnu/lapack/:${LD_LIBRARY_PATH}
export PROJ_LIB=/build/${REQUEST_ID}/.apt/usr/share/proj
python manage.py collectstatic --noinput