From e9a9ba3189d173a2f0c60c9e4ed5ffc3005a00a3 Mon Sep 17 00:00:00 2001 From: Homme Zwaagstra Date: Thu, 6 Aug 2015 12:55:33 +0100 Subject: [PATCH] Update the build system to use a Makefile. This allows for a 'mixin' approach when building the image and means it doesn't derive from the `geodata/gdal` image any more but uses `ubuntu:trusty` instead. --- docker/Dockerfile | 30 ++++++-------------- docker/Makefile | 60 ++++++++++++++++++++++++++++++++++++++++ docker/gdal-checkout.txt | 1 + docker/install-ctb.sh | 18 ------------ 4 files changed, 69 insertions(+), 40 deletions(-) create mode 100644 docker/Makefile create mode 100644 docker/gdal-checkout.txt delete mode 100755 docker/install-ctb.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index bbcdab0..7337e8a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,27 +7,13 @@ # Builder software (https://github.com/geo-data/cesium-terrain-builder). # -FROM geodata/gdal:latest +# Ubuntu 14.04 Trusty Tahyr +FROM ubuntu:trusty MAINTAINER Homme Zwaagstra -# Install as root -USER root - -# Upgrade from gcc 4.6 to 4.7 (see -# http://askubuntu.com/questions/113291/how-do-i-install-gcc-4-7) -RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test -RUN apt-get update -y -RUN apt-get install -y gcc-4.7 g++-4.7 -RUN apt-get remove -y gcc-4.6 -RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7 - -# Ensure `cmake` is present -RUN apt-get install -y cmake - -# Install Cesium Terrain Builder itself -ADD ./ctb-checkout.txt /tmp/ctb-checkout.txt -ADD ./install-ctb.sh /tmp/ -RUN sh /tmp/install-ctb.sh - -# Clean up APT when done -RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +# Install the application. +ADD . /usr/local/src/cesium-terrain-builder/ +RUN apt-get update -y && \ + apt-get install -y make && \ + make -C /usr/local/src/cesium-terrain-builder install clean && \ + apt-get purge -y make diff --git a/docker/Makefile b/docker/Makefile new file mode 100644 index 0000000..ce15ac0 --- /dev/null +++ b/docker/Makefile @@ -0,0 +1,60 @@ +## +# Install Cesium Terrain Builder from within a docker container +# +# This Makefile is designed to be run from within a docker container in order to +# install Cesium Terrain Builder. The following is an example invocation: +# +# make -C /usr/local/src/cesium-terrain-builder install clean +# + +# Version related variables. +CTB_VERSION := $(shell cat ./ctb-checkout.txt) +GDAL_VERSION := $(shell cat ./gdal-checkout.txt) + +# CTB dependency targets. +CTB := /usr/local/bin/ctb-tile +GDAL_CONFIG := /usr/local/bin/gdal_config +CTB_SRC := /tmp/cesium-terrain-builder-$(CTB_VERSION) + +# Build tools. +WGET := /usr/bin/wget + +install: $(CTB) + +$(CTB): $(CTB_SRC) /tmp/ctb-build $(GDAL_CONFIG) + cd /tmp/ctb-build \ + && cmake $(CTB_SRC) \ + && make -j$$(nproc) \ + && make install \ + && ldconfig \ + && touch -c $(CTB) + +/tmp/ctb-build: + mkdir -p /tmp/ctb-build + +$(CTB_SRC): $(WGET) + $(WGET) --no-verbose "https://github.com/geo-data/cesium-terrain-builder/archive/$(CTB_VERSION).tar.gz" -O $(CTB_SRC).tar.gz \ + && tar -C /tmp -xzf $(CTB_SRC).tar.gz \ + && touch -c $(CTB_SRC) + +$(GDAL_CONFIG): /usr/local/src/gdal-docker + make -C /usr/local/src/gdal-docker install \ + && touch -c $(GDAL_CONFIG) +/usr/local/src/gdal-docker: $(WGET) + $(WGET) --no-verbose "https://github.com/geo-data/gdal-docker/archive/$(CTB_VERSION).tar.gz" -O /tmp/gdal-docker-$(GDAL_VERSION).tar.gz \ + && tar -C /tmp -xzf /tmp/gdal-docker-$(GDAL_VERSION).tar.gz \ + && mv /tmp/gdal-docker-$(GDAL_VERSION) /usr/local/src/gdal-docker \ + && touch -c /usr/local/src/gdal-docker + +$(WGET): /tmp/apt-updated + apt-get install -y wget && touch -c $(WGET) + +/tmp/apt-updated: + apt-get update -y && touch /tmp/apt-updated + +# Remove build time dependencies. Delegate to gdal-docker clean as this removes +# everything, including wget. +clean: + make -C /usr/local/src/gdal-docker clean + +.PHONY: install clean diff --git a/docker/gdal-checkout.txt b/docker/gdal-checkout.txt new file mode 100644 index 0000000..1f7391f --- /dev/null +++ b/docker/gdal-checkout.txt @@ -0,0 +1 @@ +master diff --git a/docker/install-ctb.sh b/docker/install-ctb.sh deleted file mode 100755 index 93f23ae..0000000 --- a/docker/install-ctb.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/env sh - -## -# Obtain, configure and install Cesium Terrain Builder -# - -checkout=`cat /tmp/ctb-checkout.txt` - -# Get CTB from github -cd /tmp/ && \ - wget --no-verbose "https://github.com/geo-data/cesium-terrain-builder/archive/${checkout}.tar.gz" && \ - tar -xzf "${checkout}.tar.gz" && \ - cd "cesium-terrain-builder-${checkout}" && \ - mkdir build && \ - cd build && \ - cmake .. && \ - make install && \ - ldconfig || exit 1