From ffa3ed5302afdbcc43a7fbb614dce5655f25e8cc Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 27 Feb 2025 12:35:00 +0100 Subject: [PATCH] multi-arch builds --- .github/workflows/push.yml | 7 ++++- .github/workflows/runtime_alpine_3_10.yml | 34 +++++++++++++++++---- .github/workflows/runtime_debian_buster.yml | 34 +++++++++++++++++---- .github/workflows/runtime_ubuntu_bionic.yml | 34 +++++++++++++++++---- .github/workflows/runtime_ubuntu_focal.yml | 34 +++++++++++++++++---- Dockerfile | 8 ++--- runtime/install/_utils.sh | 4 +-- runtime/install/expat.sh | 2 +- runtime/install/geos.sh | 2 +- runtime/install/icu.sh | 4 ++- runtime/install/libtiff.sh | 2 +- runtime/install/libxml2.sh | 4 +-- runtime/install/proj7.sh | 4 +-- runtime/install/readosm.sh | 5 ++- runtime/install/rttopo.sh | 2 +- runtime/install/spatialite-tools.sh | 27 +++------------- runtime/install/spatialite5.sh | 12 +++++--- runtime/install/sqlite.sh | 2 +- runtime/install/zlib.sh | 4 +-- runtime/runtime.alpine.3.10.Dockerfile | 7 ++--- runtime/runtime.debian.buster.Dockerfile | 4 +-- runtime/runtime.ubuntu.bionic.Dockerfile | 2 +- runtime/runtime.ubuntu.focal.Dockerfile | 4 +-- 23 files changed, 162 insertions(+), 80 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9043c43..469d7bd 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,5 +1,10 @@ name: Continuous Integration -on: push +on: + schedule: + - cron: '0 0 2 * *' + push: + branches-ignore: + - runtime jobs: build-docker-images: runs-on: ubuntu-latest diff --git a/.github/workflows/runtime_alpine_3_10.yml b/.github/workflows/runtime_alpine_3_10.yml index eab4302..bed373b 100644 --- a/.github/workflows/runtime_alpine_3_10.yml +++ b/.github/workflows/runtime_alpine_3_10.yml @@ -1,5 +1,7 @@ name: 'build & push: runtime_alpine_3_10' on: + schedule: + - cron: '0 0 1 * *' push: branches: - runtime @@ -7,14 +9,34 @@ jobs: push_to_registry: name: 'build & push: runtime_alpine_3_10' runs-on: ubuntu-latest + timeout-minutes: 360 steps: + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true - name: Check out the repo - uses: actions/checkout@v2 - - name: runtime_alpine_3_10 - uses: docker/build-push-action@v1 + uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - repository: pelias/spatial - dockerfile: runtime/runtime.alpine.3.10.Dockerfile - tags: runtime_alpine_3_10 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Build Docker Images + timeout-minutes: 360 + env: + TAG: runtime_alpine_3_10 + FILE: runtime/runtime.debian.buster.Dockerfile + run: | + docker buildx create --use --bootstrap --platform='linux/amd64,linux/arm64' --name 'multi-platform-builder' + docker buildx build --platform 'linux/amd64' -f $FILE -t pelias/spatial:$TAG . + docker buildx build --platform 'linux/arm64' -f $FILE -t pelias/spatial:$TAG . + docker buildx build --platform 'linux/arm64,linux/amd64' -f $FILE -t pelias/spatial:$TAG --push . diff --git a/.github/workflows/runtime_debian_buster.yml b/.github/workflows/runtime_debian_buster.yml index 2cac3fe..27e3c18 100644 --- a/.github/workflows/runtime_debian_buster.yml +++ b/.github/workflows/runtime_debian_buster.yml @@ -1,5 +1,7 @@ name: 'build & push: runtime_debian_buster' on: + schedule: + - cron: '0 0 1 * *' push: branches: - runtime @@ -7,14 +9,34 @@ jobs: push_to_registry: name: 'build & push: runtime_debian_buster' runs-on: ubuntu-latest + timeout-minutes: 360 steps: + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true - name: Check out the repo - uses: actions/checkout@v2 - - name: runtime_debian_buster - uses: docker/build-push-action@v1 + uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - repository: pelias/spatial - dockerfile: runtime/runtime.debian.buster.Dockerfile - tags: runtime_debian_buster + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Build Docker Images + timeout-minutes: 360 + env: + TAG: runtime_debian_buster + FILE: runtime/runtime.debian.buster.Dockerfile + run: | + docker buildx create --use --bootstrap --platform='linux/amd64,linux/arm64' --name 'multi-platform-builder' + docker buildx build --platform 'linux/amd64' -f $FILE -t pelias/spatial:$TAG . + docker buildx build --platform 'linux/arm64' -f $FILE -t pelias/spatial:$TAG . + docker buildx build --platform 'linux/arm64,linux/amd64' -f $FILE -t pelias/spatial:$TAG --push . diff --git a/.github/workflows/runtime_ubuntu_bionic.yml b/.github/workflows/runtime_ubuntu_bionic.yml index 849d2c1..3459a6e 100644 --- a/.github/workflows/runtime_ubuntu_bionic.yml +++ b/.github/workflows/runtime_ubuntu_bionic.yml @@ -1,5 +1,7 @@ name: 'build & push: runtime_ubuntu_bionic' on: + schedule: + - cron: '0 0 1 * *' push: branches: - runtime @@ -7,14 +9,34 @@ jobs: push_to_registry: name: 'build & push: runtime_ubuntu_bionic' runs-on: ubuntu-latest + timeout-minutes: 360 steps: + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true - name: Check out the repo - uses: actions/checkout@v2 - - name: runtime_ubuntu_bionic - uses: docker/build-push-action@v1 + uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - repository: pelias/spatial - dockerfile: runtime/runtime.ubuntu.bionic.Dockerfile - tags: runtime_ubuntu_bionic + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Build Docker Images + timeout-minutes: 360 + env: + TAG: runtime_ubuntu_bionic + FILE: runtime/runtime.ubuntu.bionic.Dockerfile + run: | + docker buildx create --use --bootstrap --platform='linux/amd64,linux/arm64' --name 'multi-platform-builder' + docker buildx build --platform 'linux/amd64' -f $FILE -t pelias/spatial:$TAG . + docker buildx build --platform 'linux/arm64' -f $FILE -t pelias/spatial:$TAG . + docker buildx build --platform 'linux/arm64,linux/amd64' -f $FILE -t pelias/spatial:$TAG --push . diff --git a/.github/workflows/runtime_ubuntu_focal.yml b/.github/workflows/runtime_ubuntu_focal.yml index f686c3b..3bc37b2 100644 --- a/.github/workflows/runtime_ubuntu_focal.yml +++ b/.github/workflows/runtime_ubuntu_focal.yml @@ -1,5 +1,7 @@ name: 'build & push: runtime_ubuntu_focal' on: + schedule: + - cron: '0 0 1 * *' push: branches: - runtime @@ -7,14 +9,34 @@ jobs: push_to_registry: name: 'build & push: runtime_ubuntu_focal' runs-on: ubuntu-latest + timeout-minutes: 360 steps: + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true - name: Check out the repo - uses: actions/checkout@v2 - - name: runtime_ubuntu_focal - uses: docker/build-push-action@v1 + uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - repository: pelias/spatial - dockerfile: runtime/runtime.ubuntu.focal.Dockerfile - tags: runtime_ubuntu_focal + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Build Docker Images + timeout-minutes: 360 + env: + TAG: runtime_ubuntu_focal + FILE: runtime/runtime.ubuntu.focal.Dockerfile + run: | + docker buildx create --use --bootstrap --platform='linux/amd64,linux/arm64' --name 'multi-platform-builder' + docker buildx build --platform 'linux/amd64' -f $FILE -t pelias/spatial:$TAG . + docker buildx build --platform 'linux/arm64' -f $FILE -t pelias/spatial:$TAG . + docker buildx build --platform 'linux/arm64,linux/amd64' -f $FILE -t pelias/spatial:$TAG --push . \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5702ff6..9165a6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,16 +5,16 @@ # 4. Produce a minimally sized image for distribution # 1. ------------------------------------------------ -FROM pelias/spatial:runtime_ubuntu_bionic as runtime +FROM pelias/spatial:runtime_ubuntu_bionic AS runtime # 2. ------------------------------------------------ -FROM pelias/baseimage as better_sqlite3 +FROM pelias/baseimage AS better_sqlite3 # we require clang++ for compiling better-sqlite3 # this adds ~400MB to the image, so we build in a # separate image and only copy the files we need. RUN apt-get update -y -RUN apt-get install -y clang python3 make +RUN apt-get install -y clang python3 build-essential # copy runtime COPY --from=runtime /opt/spatial /opt/spatial @@ -27,7 +27,7 @@ WORKDIR /code RUN bin/compile_better_sqlite3 # 3. ------------------------------------------------ -FROM pelias/baseimage as testing +FROM pelias/baseimage AS testing # copy runtime COPY --from=runtime /opt/spatial /opt/spatial diff --git a/runtime/install/_utils.sh b/runtime/install/_utils.sh index ef45e17..6c45668 100644 --- a/runtime/install/_utils.sh +++ b/runtime/install/_utils.sh @@ -13,10 +13,10 @@ function gaia_download(){ function gaia_clone(){ REPO="$1" rm -rf "${REPO}" "${REPO}.fossil"* - USER='me' fossil clone https://www.gaia-gis.it/fossil/$REPO $REPO.fossil + USER='me' fossil clone https://www.gaia-gis.it/fossil/$REPO $REPO.fossil | wc -l mkdir -p "${REPO}" cd "${REPO}" - fossil open "../${REPO}.fossil" + fossil open "../${REPO}.fossil" | wc -l cd - rm -rf "${REPO}.fossil"* } diff --git a/runtime/install/expat.sh b/runtime/install/expat.sh index 69b7eb5..5f783ed 100755 --- a/runtime/install/expat.sh +++ b/runtime/install/expat.sh @@ -24,7 +24,7 @@ cd expat --enable-static=no # compile and install in runtime directory -make -j8 +make -j4 make install-strip # clean up diff --git a/runtime/install/geos.sh b/runtime/install/geos.sh index b5131cf..2d88e7c 100755 --- a/runtime/install/geos.sh +++ b/runtime/install/geos.sh @@ -24,7 +24,7 @@ cd geos --enable-static=no # compile and install in runtime directory -make -j8 +make -j4 make install-strip # clean up diff --git a/runtime/install/icu.sh b/runtime/install/icu.sh index ce7df13..09e1277 100755 --- a/runtime/install/icu.sh +++ b/runtime/install/icu.sh @@ -25,10 +25,12 @@ cd icu/source --disable-debug \ --disable-samples \ --disable-tests \ + --disable-tools \ + --disable-extras \ --disable-static # compile and install in runtime directory -make -j8 +make -j4 make install # clean up diff --git a/runtime/install/libtiff.sh b/runtime/install/libtiff.sh index d0cea90..401b91e 100755 --- a/runtime/install/libtiff.sh +++ b/runtime/install/libtiff.sh @@ -24,7 +24,7 @@ cd libtiff --enable-static=no # compile and install in runtime directory -make -j8 +make -j4 make install-strip # clean up diff --git a/runtime/install/libxml2.sh b/runtime/install/libxml2.sh index 6ecb9bc..6c2a52a 100755 --- a/runtime/install/libxml2.sh +++ b/runtime/install/libxml2.sh @@ -12,7 +12,7 @@ cd /tmp rm -rf libxml2 && mkdir -p libxml2 # download release and decompress it -curl -L 'ftp://xmlsoft.org/libxml2/libxml2-2.9.10.tar.gz' \ +curl -L 'ftp://xmlsoft.org/libxml2/libxml2-2.9.12.tar.gz' \ | tar -xz --strip-components=1 -C libxml2 # working directory @@ -25,7 +25,7 @@ cd libxml2 --without-python # compile and install in runtime directory -make -j8 +make -j4 make install-strip # clean up diff --git a/runtime/install/proj7.sh b/runtime/install/proj7.sh index 84f33ae..5f6c7be 100755 --- a/runtime/install/proj7.sh +++ b/runtime/install/proj7.sh @@ -12,7 +12,7 @@ cd /tmp rm -rf proj7 && mkdir -p proj7 # download release and decompress it -curl -L 'https://download.osgeo.org/proj/proj-7.0.1.tar.gz' \ +curl -L 'https://download.osgeo.org/proj/proj-7.2.1.tar.gz' \ | tar -xz --strip-components=1 -C proj7 # working directory @@ -35,7 +35,7 @@ export TIFF_LIBS="-L${RUNTIME}/lib -ltiff" --enable-static=no # compile and install in runtime directory -make -j8 +make -j4 make install-strip # clean up diff --git a/runtime/install/readosm.sh b/runtime/install/readosm.sh index 8bdc0fd..3de8929 100755 --- a/runtime/install/readosm.sh +++ b/runtime/install/readosm.sh @@ -20,6 +20,9 @@ export CPPFLAGS="-I${RUNTIME}/include" export LDFLAGS="-L${RUNTIME}/lib" export LIBS="-ldl" +# generate config.guess +autoreconf -fi + # configure build ./configure \ --prefix="${RUNTIME}" \ @@ -27,7 +30,7 @@ export LIBS="-ldl" --enable-static=no # compile and install in runtime directory -make -j8 +make -j4 make install-strip # clean up diff --git a/runtime/install/rttopo.sh b/runtime/install/rttopo.sh index a9cd048..e3e0b1a 100755 --- a/runtime/install/rttopo.sh +++ b/runtime/install/rttopo.sh @@ -34,7 +34,7 @@ export LDFLAGS="-L${RUNTIME}/lib" --enable-static=no # compile and install in runtime directory -make -j8 +make -j4 make install-strip # clean up diff --git a/runtime/install/spatialite-tools.sh b/runtime/install/spatialite-tools.sh index f08fd8d..8bb7e37 100755 --- a/runtime/install/spatialite-tools.sh +++ b/runtime/install/spatialite-tools.sh @@ -20,23 +20,6 @@ export CPPFLAGS="-I${RUNTIME}/include" export LDFLAGS="-L${RUNTIME}/lib" export LDFLAGS="${LDFLAGS} -Wl,-rpath,${RUNTIME}/lib" # set 'rpath' export PKG_CONFIG_PATH="${RUNTIME}/lib/pkgconfig" -export LIBS='-ldl ' # note: requires trailing space! - -# link spatialite -export LIBSPATIALITE_CFLAGS="-I${RUNTIME}/include" -export LIBSPATIALITE_LIBS='-lspatialite' - -# link readosm -export LIBREADOSM_CFLAGS="-I${RUNTIME}/include" -export LIBREADOSM_LIBS="-L${RUNTIME}/lib -lreadosm" - -# link rttopo -export RTTOPO_CFLAGS="-I${RUNTIME}/include" -export RTTOPO_LIBS='-lrttopo' - -# link libxml2 -export LIBXML2_CFLAGS="-I${RUNTIME}/include/libxml2" -export LIBXML2_LIBS="-L${RUNTIME}/lib -lxml2" # fix for expat install!? if [ -x "$(command -v gsed)" ]; then @@ -45,18 +28,18 @@ else sed -i 's:LIBS="-lexpat $LIBS":LIBS="-L/opt/spatial/lib -lexpat":g' configure fi +# generate config.guess +autoreconf -fi + # configure build ./configure \ --prefix="${RUNTIME}" \ --disable-dependency-tracking \ - --enable-rttopo \ - --enable-libxml2 \ - --disable-freexl \ - --with-geosconfig="${RUNTIME}/bin/geos-config" \ + --disable-readosm \ --enable-static=no # compile and install in runtime directory -make -j8 +make -j4 make install-strip ## test binary correctly linked in empty env diff --git a/runtime/install/spatialite5.sh b/runtime/install/spatialite5.sh index 545f2db..96e8d12 100755 --- a/runtime/install/spatialite5.sh +++ b/runtime/install/spatialite5.sh @@ -22,11 +22,10 @@ cd 'libspatialite' export CPPFLAGS="-I${RUNTIME}/include" export LDFLAGS="-L${RUNTIME}/lib" export LDFLAGS="${LDFLAGS} -Wl,-rpath,${RUNTIME}/lib" # set 'rpath' -export LIBS='-ldl' +export PKG_CONFIG_PATH="${RUNTIME}/lib/pkgconfig" -# link libxml2 -export LIBXML2_CFLAGS="-I${RUNTIME}/include/libxml2" -export LIBXML2_LIBS="-L${RUNTIME}/lib -lxml2" +# generate config.guess +autoreconf -fi # configure build ./configure \ @@ -35,6 +34,9 @@ export LIBXML2_LIBS="-L${RUNTIME}/lib -lxml2" --enable-rttopo=yes \ --enable-proj=yes \ --enable-geos=yes \ + --disable-geos390 \ + --disable-geos3100 \ + --disable-geos3110 \ --enable-gcp=yes \ --enable-libxml2=yes \ --disable-freexl \ @@ -42,7 +44,7 @@ export LIBXML2_LIBS="-L${RUNTIME}/lib -lxml2" --enable-static=no # compile and install in runtime directory -make -j8 +make -j4 make install-strip ## symlink 'mod_spatialite.dylib' on Mac diff --git a/runtime/install/sqlite.sh b/runtime/install/sqlite.sh index 604e8c5..3ecb88d 100755 --- a/runtime/install/sqlite.sh +++ b/runtime/install/sqlite.sh @@ -71,7 +71,7 @@ export LDFLAGS="${LDFLAGS} -Wl,-rpath,${RUNTIME}/lib" # set 'rpath' --disable-debug # compile and install in runtime directory -make -j8 +make -j4 make install-strip ## generate DYLIB shared lib on Mac diff --git a/runtime/install/zlib.sh b/runtime/install/zlib.sh index bf6144c..698f1a1 100755 --- a/runtime/install/zlib.sh +++ b/runtime/install/zlib.sh @@ -22,7 +22,7 @@ cd zlib ./configure --prefix="${RUNTIME}" # compile and install zlib in runtime directory -make -j8 +make -j4 make install # install minizip @@ -33,7 +33,7 @@ autoreconf -i ./configure --prefix="${RUNTIME}" # compile and install minizip in runtime directory -make -j8 +make -j4 make install # clean up diff --git a/runtime/runtime.alpine.3.10.Dockerfile b/runtime/runtime.alpine.3.10.Dockerfile index 0e8e289..67c19b4 100644 --- a/runtime/runtime.alpine.3.10.Dockerfile +++ b/runtime/runtime.alpine.3.10.Dockerfile @@ -1,11 +1,10 @@ -FROM alpine:3.10 as build +FROM alpine:3.10 AS build # apk dependencies -RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories RUN apk update && \ apk --no-cache --update upgrade musl && \ - apk add --upgrade --force-overwrite apk-tools@edge && \ - apk add --update --force-overwrite autoconf automake gcc g++ libtool make musl-dev@edge && \ + apk add --upgrade --force-overwrite apk-tools && \ + apk add --update --force-overwrite autoconf automake gcc g++ libtool make musl-dev cmake && \ apk add --update --force-overwrite curl-dev && \ apk add --update --force-overwrite bash curl file unzip && \ apk add --update --force-overwrite fossil git && \ diff --git a/runtime/runtime.debian.buster.Dockerfile b/runtime/runtime.debian.buster.Dockerfile index 23826af..b4321e8 100644 --- a/runtime/runtime.debian.buster.Dockerfile +++ b/runtime/runtime.debian.buster.Dockerfile @@ -1,9 +1,9 @@ -FROM debian:buster as build +FROM debian:buster AS build ENV DEBIAN_FRONTEND=noninteractive # apt dependencies RUN apt-get update -y && \ - apt-get install -y build-essential autoconf libtool pkg-config && \ + apt-get install -y build-essential autoconf libtool pkg-config cmake && \ apt-get install -y libcurl4-gnutls-dev && \ apt-get install -y curl unzip && \ apt-get install -y fossil git-core && \ diff --git a/runtime/runtime.ubuntu.bionic.Dockerfile b/runtime/runtime.ubuntu.bionic.Dockerfile index a5fffb8..850ab8a 100644 --- a/runtime/runtime.ubuntu.bionic.Dockerfile +++ b/runtime/runtime.ubuntu.bionic.Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:bionic as build +FROM ubuntu:bionic AS build ENV DEBIAN_FRONTEND=noninteractive # apt dependencies diff --git a/runtime/runtime.ubuntu.focal.Dockerfile b/runtime/runtime.ubuntu.focal.Dockerfile index 217363c..920c43a 100644 --- a/runtime/runtime.ubuntu.focal.Dockerfile +++ b/runtime/runtime.ubuntu.focal.Dockerfile @@ -1,9 +1,9 @@ -FROM ubuntu:focal as build +FROM ubuntu:focal AS build ENV DEBIAN_FRONTEND=noninteractive # apt dependencies RUN apt-get update -y && \ - apt-get install -y build-essential autoconf libtool pkg-config && \ + apt-get install -y build-essential autoconf libtool pkg-config cmake && \ apt-get install -y libcurl4-gnutls-dev && \ apt-get install -y curl unzip && \ apt-get install -y fossil git-core && \