docker社區的geodata/gdal鏡像dockerfile分析
阿新 • • 發佈:2017-12-18
dlink add cal repo eat efi clean up delegate external
對應從事遙感與地理信息的同仁來說,gdal應該是所有工具中使用頻度最高的庫了,那麽在docker中使用gdal時,面臨的第一步就是構建gdal基礎鏡像,社區中引用最多的就是geodata提供的gdal基礎鏡像包,封裝的gdal最新版本是2.3.0dev。
geodata/gdal的docker在github上的地址如下:
https://github.com/geo-data/gdal-docker
根據該庫的提交記錄,其生成gdal鏡像的方法經歷了多次更新:
1 最初按照gdal官網步驟自行編譯;
2 基於makefile采用make系統編譯;
3 基於gdal的travel ci 腳本進行編譯。
dockerfile內容如下:
## # geodata/gdal # # This creates an Ubuntu derived base image that installs the latest GDAL # subversion checkout compiled with a broad range of drivers. The build process # is based on that defined in # <https://github.com/OSGeo/gdal/blob/trunk/.travis.yml> # # Ubuntu 14.04 Trusty Tahyr FROM ubuntu:trusty MAINTAINER Homme Zwaagstra<hrz@geodata.soton.ac.uk> # Install the application. ADD . /usr/local/src/gdal-docker/ RUN /usr/local/src/gdal-docker/build.sh # Externally accessible data is by default put in /data WORKDIR /data VOLUME ["/data"] # Output version and capabilities by default. CMD gdalinfo --version && gdalinfo --formats && ogrinfo --formats
基於ubuntu:trusty基礎鏡像,復制鏡像構建相關內容到鏡像的/usr/local/src/gdal-docker目錄,利用build.sh腳本執行構建操作。
build.sh內容如下:
#!/bin/sh ## # Install GDAL from within a docker container # # This script is designed to be run from within a docker container in order to # install GDAL. It delegates to `before_install.sh` and `install.sh` which are # patched from the Travis CI configuration in the GDAL repository. # set -e DIR=$(dirname "$(readlink -f "$0")") GDAL_VERSION=$(cat ${DIR}/gdal-checkout.txt) export DEBIAN_FRONTEND=noninteractive # Set the locale. Required for subversion to work on the repository. update-locale LANG="C.UTF-8" dpkg-reconfigure locales . /etc/default/locale export LANG # Instell prerequisites. apt-get update -y apt-get install -y software-properties-common wget unzip subversion ccache clang-3.5 patch python-dev ant # Everything happens under here. cd /tmp # Get GDAL. svn checkout --quiet "http://svn.osgeo.org/gdal/${GDAL_VERSION}/" /tmp/gdal/ # Install GDAL. cd /tmp/gdal # Apply our build patches. patch ./gdal/ci/travis/trusty_clang/before_install.sh ${DIR}/before_install.sh.patch patch ./gdal/ci/travis/trusty_clang/install.sh ${DIR}/install.sh.patch # Do the build. . ./gdal/ci/travis/trusty_clang/before_install.sh . ./gdal/ci/travis/trusty_clang/install.sh # Clean up. apt-get autoremove -y apt-get clean rm -rf /var/lib/apt/lists/partial/* /tmp/* /var/tmp/*
設置GDAL_VERSION(從gdal-checkout.txt讀取,為trunk,表示從svn主幹分支下載源代碼),下載gdal源代碼到/tmp/gdal目錄,下載編譯器clang和python環境,對gdal的trusty_clang的travis安裝腳本打補丁(通過修改後調用diff工具生成patch),安裝gdal,清理臨時文件。
docker社區的geodata/gdal鏡像dockerfile分析