zoukankan      html  css  js  c++  java
  • docker社区的geodata/gdal镜像dockerfile分析

    对应从事遥感与地理信息的同仁来说,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,清理临时文件。

  • 相关阅读:
    codevs 1086 栈 2003年NOIP全国联赛普及组
    1200 同余方程 2012年NOIP全国联赛提高组
    【bzoj4939】【YNOI2016】掉进兔子洞(莫队)
    洛谷P3674 小清新人渣的本愿(莫队)
    Lucas卢卡斯定理
    组合数学习笔记
    洛谷P3178 [HAOI2015]树上操作(线段树)
    洛谷P3258 [JLOI2014]松鼠的新家(树上差分+树剖)
    洛谷P2526 [SHOI2001]小狗散步(二分图匹配)
    bzoj3140: [Hnoi2013]消毒(二分图)
  • 原文地址:https://www.cnblogs.com/dadream/p/8058810.html
Copyright © 2011-2022 走看看