From 22a13e8863494b49dee5a109580d9f3253bd637f Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Sun, 4 Feb 2024 17:11:31 -0700 Subject: [PATCH] Add Autotools build Dockerfiles (#386) To make local Autotools build testing easier. --- .dockerignore | 8 + .github/workflows/docker-image-build.yml | 2 + docker/centos/stream/Dockerfile.autotools | 198 ++++++++++++++++++++++ docker/debian/Dockerfile | 2 +- docker/debian/Dockerfile.autotools | 98 +++++++++++ docker/docker-compose.yml | 56 ++++++ docker/ubuntu/Dockerfile.autotools | 98 +++++++++++ 7 files changed, 461 insertions(+), 1 deletion(-) create mode 100644 docker/centos/stream/Dockerfile.autotools create mode 100644 docker/debian/Dockerfile.autotools create mode 100644 docker/ubuntu/Dockerfile.autotools diff --git a/.dockerignore b/.dockerignore index e76d6d2d..0fad02e7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,3 +9,11 @@ !src !tests !utils/example-map + +# AutoTools +!autogen.sh +!configure.ac +!etc/renderd/renderd.conf +!m4 +!Makefile.am +!modules.mk diff --git a/.github/workflows/docker-image-build.yml b/.github/workflows/docker-image-build.yml index 0d4ba021..0ddcda7b 100644 --- a/.github/workflows/docker-image-build.yml +++ b/.github/workflows/docker-image-build.yml @@ -21,6 +21,7 @@ jobs: - debian-11 - debian-12 - debian-testing + - debian-testing-autotools - fedora-38 - fedora-39 - fedora-rawhide @@ -29,6 +30,7 @@ jobs: - ubuntu-20.04 - ubuntu-22.04 - ubuntu-devel + - ubuntu-devel-autotools fail-fast: false steps: - name: Checkout repository diff --git a/docker/centos/stream/Dockerfile.autotools b/docker/centos/stream/Dockerfile.autotools new file mode 100644 index 00000000..fbcb8de9 --- /dev/null +++ b/docker/centos/stream/Dockerfile.autotools @@ -0,0 +1,198 @@ +# Arguments +ARG centos_stream_version +ARG extra_repository +ARG mapnik_version=3.1.0 + +# Mapnik Builder +FROM quay.io/centos/centos:stream${centos_stream_version} as mapnik-builder + +## Arguments +ARG centos_stream_version +ARG extra_repository +ARG mapnik_version + +## Install mapnik-builder dependencies +RUN --mount=id=centos:stream${centos_stream_version}-/var/cache/dnf,target=/var/cache/dnf,type=cache,sharing=locked \ + echo "install_weak_deps=False" >> /etc/dnf/dnf.conf && \ + echo "keepcache=True" >> /etc/dnf/dnf.conf && \ + dnf --assumeyes install "dnf-command(config-manager)" && \ + dnf config-manager --save \ + --setopt=${extra_repository}.enabled=1 && \ + dnf --assumeyes install epel-release && \ + dnf --assumeyes upgrade && \ + dnf --assumeyes install \ + boost-devel \ + bzip2 \ + cairo-devel \ + freetype-devel \ + gcc \ + gcc-c++ \ + gdal-devel \ + harfbuzz-devel \ + libicu-devel \ + libjpeg-devel \ + libpng-devel \ + libtiff-devel \ + libwebp-devel \ + libxml2-devel \ + make \ + patch \ + postgresql-devel \ + proj-devel \ + python3 \ + python3-scons \ + sqlite-devel \ + tar \ + zlib-devel + +## Download, Build & Install `Mapnik` +WORKDIR /usr/local/src/mapnik +RUN --mount=id=centos:stream${centos_stream_version}-mapnik:${mapnik_version},target=/usr/local/src/mapnik,type=cache \ + export DESTDIR="/tmp/mapnik"; \ + export GDAL_DATA="$(gdal-config --datadir)"; \ + export JOBS="$(nproc)"; \ + export PROJ_LIB="/usr/share/proj"; \ + export PYTHON="python3"; \ + mkdir --parents ${GDAL_DATA} ${PROJ_LIB}; \ + if [ ! -f SConstruct ]; then \ + curl --silent --location https://github.com/mapnik/mapnik/releases/download/v${mapnik_version}/mapnik-v${mapnik_version}.tar.bz2 \ + | tar --extract --bzip2 --strip-components=1 --file=-; \ + if [ "${centos_stream_version}" = "9" ]; then \ + curl --silent --location https://github.com/mapnik/mapnik/commit/8944e81367d2b3b91a41e24116e1813c01491e5d.patch \ + | patch -Np1; \ + curl --silent --location https://github.com/mapnik/mapnik/commit/83779b7b6bdd229740b1b5e12a4a8fe27114cb7d.patch \ + | patch -F3 -Np1; \ + fi \ + fi; \ + if [ "${centos_stream_version}" = "8" ]; then \ + export SCONS_CMD="scons-3"; \ + export CUSTOM_CFLAGS="-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H"; \ + export CUSTOM_CXXFLAGS="-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H"; \ + fi; \ + ${SCONS_CMD:-scons} configure \ + CPP_TESTS=False \ + CUSTOM_CFLAGS="${CUSTOM_CFLAGS:-}" \ + CUSTOM_CXXFLAGS="${CUSTOM_CXXFLAGS:-}" \ + CUSTOM_LDFLAGS="${CUSTOM_LDFLAGS:-}" \ + DEMO=False \ + DESTDIR="${DESTDIR}" \ + FAST=True \ + INPUT_PLUGINS=all \ + LIBDIR_SCHEMA=lib64 \ + OPTIMIZATION=2 \ + PREFIX=/usr \ + SVG2PNG=True \ + XMLPARSER=libxml2 && \ + make PYTHON="${PYTHON}" && \ + make install PYTHON="${PYTHON}" + +# Builder +FROM quay.io/centos/centos:stream${centos_stream_version} as builder + +## Arguments +ARG centos_stream_version +ARG extra_repository + +## Install builder dependencies +RUN --mount=id=centos:stream${centos_stream_version}-/var/cache/dnf,target=/var/cache/dnf,type=cache,sharing=locked \ + echo "install_weak_deps=False" >> /etc/dnf/dnf.conf && \ + echo "keepcache=True" >> /etc/dnf/dnf.conf && \ + dnf --assumeyes install "dnf-command(config-manager)" && \ + dnf config-manager --save \ + --setopt=${extra_repository}.enabled=1 && \ + dnf --assumeyes install epel-release && \ + dnf --assumeyes upgrade && \ + dnf --assumeyes install \ + automake \ + boost-devel \ + cairo-devel \ + gcc \ + gcc-c++ \ + gdal \ + glib2-devel \ + harfbuzz-devel \ + httpd-devel \ + iniparser-devel \ + libcurl-devel \ + libicu-devel \ + libjpeg-devel \ + libmemcached-devel \ + librados2-devel \ + libtiff-devel \ + libwebp-devel \ + libxml2-devel \ + make \ + proj-devel \ + redhat-rpm-config \ + sqlite-devel + +## Copy files from builder(s) +### Mapnik +COPY --from=mapnik-builder /tmp/mapnik / + +## Build, Test & Install `mod_tile` +COPY . /tmp/mod_tile_src +WORKDIR /tmp/mod_tile_src +RUN ./autogen.sh && \ + ./configure && \ + make +RUN export DESTDIR=/tmp/mod_tile && \ + ./gen_tile_test && \ + make DESTDIR=${DESTDIR} install install-mod_tile + +# Runner +FROM quay.io/centos/centos:stream${centos_stream_version} as runner + +## Arguments +ARG centos_stream_version +ARG extra_repository + +## Install runner dependencies +RUN --mount=id=centos:stream${centos_stream_version}-/var/cache/dnf,target=/var/cache/dnf,type=cache,sharing=locked \ + echo "install_weak_deps=False" >> /etc/dnf/dnf.conf && \ + echo "keepcache=True" >> /etc/dnf/dnf.conf && \ + dnf --assumeyes install "dnf-command(config-manager)" && \ + dnf config-manager --save \ + --setopt=${extra_repository}.enabled=1 && \ + dnf --assumeyes install epel-release && \ + dnf --assumeyes upgrade && \ + dnf --assumeyes install \ + boost-filesystem \ + boost-program-options \ + boost-regex \ + cairo \ + gdal \ + harfbuzz \ + httpd \ + iniparser \ + libicu \ + libmemcached \ + librados2 \ + libtiff \ + libwebp \ + proj + +## Copy files from builder(s) +### Mapnik +COPY --from=mapnik-builder /tmp/mapnik / +### mod_tile +COPY --from=builder /tmp/mod_tile / +COPY --chown=apache:apache --from=builder \ + /tmp/mod_tile_src/utils/example-map \ + /usr/share/renderd/example-map +COPY --from=builder \ + /tmp/mod_tile_src/etc/apache2/renderd-example-map.conf \ + /etc/httpd/conf.d/renderd-example-map.conf + +RUN printf "LoadModule tile_module $(find /usr -name mod_tile.so)\n" > /etc/httpd/conf.modules.d/11-tile.conf + +RUN sed \ + --expression "s#/usr/lib/mapnik/3.1/input#$(find /usr -mindepth 1 -type d -name input)#g" \ + --expression "s#/usr/share/fonts/truetype#/usr/share/fonts#g" \ + /usr/local/etc/renderd.conf > /etc/renderd.conf && \ + printf '\n[example-map]\nURI=/tiles/renderd-example\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf + +RUN mkdir --parents /run/renderd /var/cache/renderd/tiles + +CMD /usr/sbin/httpd -e debug -k start; \ + G_MESSAGES_DEBUG=${G_MESSAGES_DEBUG:-info} renderd --foreground diff --git a/docker/debian/Dockerfile b/docker/debian/Dockerfile index e40cbfff..4d5c450b 100644 --- a/docker/debian/Dockerfile +++ b/docker/debian/Dockerfile @@ -47,8 +47,8 @@ RUN export DESTDIR=/tmp/mod_tile && \ FROM debian:${debian_version} as runner ## Arguments -ARG libmapnik_version ARG debian_version +ARG libmapnik_version ## Install runner dependencies RUN --mount=id=debian:${debian_version}-/var/cache/apt,sharing=locked,target=/var/cache/apt,type=cache \ diff --git a/docker/debian/Dockerfile.autotools b/docker/debian/Dockerfile.autotools new file mode 100644 index 00000000..e50c6458 --- /dev/null +++ b/docker/debian/Dockerfile.autotools @@ -0,0 +1,98 @@ +# Arguments +ARG debian_version=12 +ARG libmapnik_version=3.1 + +# Builder +FROM debian:${debian_version} as builder + +## Arguments +ARG debian_version + +## Install builder dependencies +RUN --mount=id=debian:${debian_version}-/var/cache/apt,sharing=locked,target=/var/cache/apt,type=cache \ + --mount=id=debian:${debian_version}-/var/lib/apt,sharing=locked,target=/var/lib/apt,type=cache \ + export DEBIAN_FRONTEND=noninteractive && \ + apt-get --yes update && \ + apt-get --yes upgrade && \ + apt-get --no-install-recommends --yes install \ + apache2 \ + apache2-dev \ + curl \ + g++ \ + gcc \ + libcairo2-dev \ + libcurl4-openssl-dev \ + libglib2.0-dev \ + libiniparser-dev \ + libmapnik-dev \ + libmemcached-dev \ + librados-dev \ + netbase + +## Build, Test & Install `mod_tile` +COPY . /tmp/mod_tile_src +WORKDIR /tmp/mod_tile_src +RUN ./autogen.sh && \ + ./configure && \ + make +RUN export DESTDIR=/tmp/mod_tile && \ + ./gen_tile_test && \ + make DESTDIR=${DESTDIR} install install-mod_tile + +# Runner +FROM debian:${debian_version} as runner + +## Arguments +ARG debian_version +ARG libmapnik_version + +## Install runner dependencies +RUN --mount=id=debian:${debian_version}-/var/cache/apt,sharing=locked,target=/var/cache/apt,type=cache \ + --mount=id=debian:${debian_version}-/var/lib/apt,sharing=locked,target=/var/lib/apt,type=cache \ + export DEBIAN_FRONTEND=noninteractive && \ + apt-get --yes update && \ + apt-get --yes upgrade && \ + apt-get --no-install-recommends --yes install \ + apache2 \ + libcairo2 \ + libcurl4 \ + libglib2.0 \ + libiniparser1 \ + libmapnik${libmapnik_version} \ + libmemcached11 \ + librados2 + +## Copy files from builder(s) +### mod_tile +COPY --from=builder /tmp/mod_tile / +COPY --from=builder \ + /tmp/mod_tile_src/utils/example-map \ + /usr/share/renderd/example-map +COPY --from=builder \ + /tmp/mod_tile_src/etc/apache2/renderd-example-map.conf \ + /etc/apache2/sites-available/renderd-example-map.conf + +## Fix mapnik directories +RUN sed \ + --expression "s#/usr/lib/mapnik/3.1/input#$(find /usr -mindepth 1 -type d -name input)#g" \ + --expression "s#/usr/share/fonts/truetype#/usr/share/fonts#g" \ + /usr/local/etc/renderd.conf > /etc/renderd.conf + +## Add configuration +RUN printf "LoadModule tile_module $(find /usr -name mod_tile.so)\n" > /etc/apache2/mods-available/tile.load +RUN printf '\n[example-map]\nURI=/tiles/renderd-example\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf +RUN printf '\n[example-map-jpg]\nTYPE=jpg image/jpeg jpeg\nURI=/tiles/renderd-example-jpg\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf +RUN printf '\n[example-map-png256]\nTYPE=png image/png png256\nURI=/tiles/renderd-example-png256\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf +RUN printf '\n[example-map-png32]\nTYPE=png image/png png32\nURI=/tiles/renderd-example-png32\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf +RUN printf '\n[example-map-webp]\nTYPE=webp image/webp webp\nURI=/tiles/renderd-example-webp\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf + +## Create missing directories +RUN mkdir --parents /run/renderd /var/cache/renderd/tiles + +## Enable module & site +RUN a2enmod tile && \ + a2ensite renderd-example-map + +## Start services +CMD apachectl -e debug -k start; \ + G_MESSAGES_DEBUG=${G_MESSAGES_DEBUG:-info} renderd --foreground diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 2f422a67..5facfc31 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -53,6 +53,14 @@ services: args: libmapnik_version: "3.0" debian_version: "10" + debian-10-autotools: + <<: *service_defaults + build: + <<: *build_defaults_debian + args: + libmapnik_version: "3.0" + debian_version: "10" + dockerfile: docker/debian/Dockerfile.autotools debian-11: <<: *service_defaults build: @@ -60,6 +68,14 @@ services: args: libmapnik_version: "3.1" debian_version: "11" + debian-11-autotools: + <<: *service_defaults + build: + <<: *build_defaults_debian + args: + libmapnik_version: "3.1" + debian_version: "11" + dockerfile: docker/debian/Dockerfile.autotools debian-12: <<: *service_defaults build: @@ -67,6 +83,14 @@ services: args: libmapnik_version: "3.1" debian_version: "12" + debian-12-autotools: + <<: *service_defaults + build: + <<: *build_defaults_debian + args: + libmapnik_version: "3.1" + debian_version: "12" + dockerfile: docker/debian/Dockerfile.autotools debian-testing: <<: *service_defaults build: @@ -74,6 +98,14 @@ services: args: libmapnik_version: "3.1" debian_version: testing + debian-testing-autotools: + <<: *service_defaults + build: + <<: *build_defaults_debian + args: + libmapnik_version: "3.1" + debian_version: testing + dockerfile: docker/debian/Dockerfile.autotools fedora-34: <<: *service_defaults build: @@ -136,6 +168,14 @@ services: args: libmapnik_version: "3.0" ubuntu_version: "20.04" + ubuntu-20.04-autotools: + <<: *service_defaults + build: + <<: *build_defaults_ubuntu + args: + libmapnik_version: "3.0" + ubuntu_version: "20.04" + dockerfile: docker/ubuntu/Dockerfile.autotools ubuntu-22.04: <<: *service_defaults build: @@ -143,6 +183,14 @@ services: args: libmapnik_version: "3.1" ubuntu_version: "22.04" + ubuntu-22.04-autotools: + <<: *service_defaults + build: + <<: *build_defaults_ubuntu + args: + libmapnik_version: "3.1" + ubuntu_version: "22.04" + dockerfile: docker/ubuntu/Dockerfile.autotools ubuntu-devel: <<: *service_defaults build: @@ -150,6 +198,14 @@ services: args: libmapnik_version: "3.1" ubuntu_version: "devel" + ubuntu-devel-autotools: + <<: *service_defaults + build: + <<: *build_defaults_ubuntu + args: + libmapnik_version: "3.1" + ubuntu_version: "devel" + dockerfile: docker/ubuntu/Dockerfile.autotools ubuntu-devel-full: <<: *service_defaults build: diff --git a/docker/ubuntu/Dockerfile.autotools b/docker/ubuntu/Dockerfile.autotools new file mode 100644 index 00000000..70190f9f --- /dev/null +++ b/docker/ubuntu/Dockerfile.autotools @@ -0,0 +1,98 @@ +# Arguments +ARG libmapnik_version=3.1 +ARG ubuntu_version=22.04 + +# Builder +FROM ubuntu:${ubuntu_version} as builder + +## Arguments +ARG ubuntu_version + +## Install builder dependencies +RUN --mount=id=ubuntu:${ubuntu_version}-/var/cache/apt,sharing=locked,target=/var/cache/apt,type=cache \ + --mount=id=ubuntu:${ubuntu_version}-/var/lib/apt,sharing=locked,target=/var/lib/apt,type=cache \ + export DEBIAN_FRONTEND=noninteractive && \ + apt-get --yes update && \ + apt-get --yes upgrade && \ + apt-get --no-install-recommends --yes install \ + apache2 \ + apache2-dev \ + curl \ + g++ \ + gcc \ + libcairo2-dev \ + libcurl4-openssl-dev \ + libglib2.0-dev \ + libiniparser-dev \ + libmapnik-dev \ + libmemcached-dev \ + librados-dev \ + netbase + +## Build, Test & Install `mod_tile` +COPY . /tmp/mod_tile_src +WORKDIR /tmp/mod_tile_src +RUN ./autogen.sh && \ + ./configure && \ + make +RUN export DESTDIR=/tmp/mod_tile && \ + ./gen_tile_test && \ + make DESTDIR=${DESTDIR} install install-mod_tile + +# Runner +FROM ubuntu:${ubuntu_version} as runner + +## Arguments +ARG libmapnik_version +ARG ubuntu_version + +## Install runner dependencies +RUN --mount=id=ubuntu:${ubuntu_version}-/var/cache/apt,sharing=locked,target=/var/cache/apt,type=cache \ + --mount=id=ubuntu:${ubuntu_version}-/var/lib/apt,sharing=locked,target=/var/lib/apt,type=cache \ + export DEBIAN_FRONTEND=noninteractive && \ + apt-get --yes update && \ + apt-get --yes upgrade && \ + apt-get --no-install-recommends --yes install \ + apache2 \ + libcairo2 \ + libcurl4 \ + libglib2.0-0 \ + libiniparser1 \ + libmapnik${libmapnik_version} \ + libmemcached11 \ + librados2 + +## Copy files from builder(s) +### mod_tile +COPY --from=builder /tmp/mod_tile / +COPY --from=builder \ + /tmp/mod_tile_src/utils/example-map \ + /usr/share/renderd/example-map +COPY --from=builder \ + /tmp/mod_tile_src/etc/apache2/renderd-example-map.conf \ + /etc/apache2/sites-available/renderd-example-map.conf + +## Fix mapnik directories +RUN sed \ + --expression "s#/usr/lib/mapnik/3.1/input#$(find /usr -mindepth 1 -type d -name input)#g" \ + --expression "s#/usr/share/fonts/truetype#/usr/share/fonts#g" \ + /usr/local/etc/renderd.conf > /etc/renderd.conf + +## Add configuration +RUN printf "LoadModule tile_module $(find /usr -name mod_tile.so)\n" > /etc/apache2/mods-available/tile.load +RUN printf '\n[example-map]\nURI=/tiles/renderd-example\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf +RUN printf '\n[example-map-jpg]\nTYPE=jpg image/jpeg jpeg\nURI=/tiles/renderd-example-jpg\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf +RUN printf '\n[example-map-png256]\nTYPE=png image/png png256\nURI=/tiles/renderd-example-png256\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf +RUN printf '\n[example-map-png32]\nTYPE=png image/png png32\nURI=/tiles/renderd-example-png32\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf +RUN printf '\n[example-map-webp]\nTYPE=webp image/webp webp\nURI=/tiles/renderd-example-webp\nXML=/usr/share/renderd/example-map/mapnik.xml\n' >> /etc/renderd.conf + +## Create missing directories +RUN mkdir --parents /run/renderd /var/cache/renderd/tiles + +## Enable module & site +RUN a2enmod tile && \ + a2ensite renderd-example-map + +## Start services +CMD apachectl -e debug -k start; \ + G_MESSAGES_DEBUG=${G_MESSAGES_DEBUG:-info} renderd --foreground