diff --git a/Dockerfile b/Dockerfile index 7b70733..dc9e0a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:10-buster AS builder +FROM node:16-bullseye AS builder RUN export DEBIAN_FRONTEND=noninteractive \ && apt-get -qq update \ @@ -11,7 +11,6 @@ RUN export DEBIAN_FRONTEND=noninteractive \ libcairo2-dev \ libgles2-mesa-dev \ libgbm-dev \ - libllvm7 \ libprotobuf-dev \ && apt-get -y --purge autoremove \ && apt-get clean \ @@ -24,7 +23,7 @@ ENV NODE_ENV="production" RUN cd /usr/src/app && npm install --production -FROM node:10-buster-slim AS final +FROM node:16-bullseye-slim AS final RUN export DEBIAN_FRONTEND=noninteractive \ && apt-get -qq update \ @@ -33,9 +32,20 @@ RUN export DEBIAN_FRONTEND=noninteractive \ libegl1 \ xvfb \ xauth \ + libopengl0 \ + libcurl4 \ + curl \ + libuv1-dev \ + libc6-dev \ + libcap2-bin \ && apt-get -y --purge autoremove \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* + +RUN curl http://archive.ubuntu.com/ubuntu/pool/main/libj/libjpeg-turbo/libjpeg-turbo8_2.0.3-0ubuntu1_amd64.deb --output libjpeg-turbo8_2.0.3-0ubuntu1_amd64.deb +RUN apt install ./libjpeg-turbo8_2.0.3-0ubuntu1_amd64.deb +RUN curl http://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu66_66.1-2ubuntu2_amd64.deb --output libicu66_66.1-2ubuntu2_amd64.deb +RUN apt install ./libicu66_66.1-2ubuntu2_amd64.deb COPY --from=builder /usr/src/app /app @@ -51,5 +61,3 @@ EXPOSE 80 USER node:node ENTRYPOINT ["/app/docker-entrypoint.sh"] - -CMD ["-p", "80"] diff --git a/Dockerfile_light b/Dockerfile_light index c5df16f..4112bf9 100644 --- a/Dockerfile_light +++ b/Dockerfile_light @@ -1,4 +1,4 @@ -FROM node:10-stretch +FROM node:16-bullseye ENV NODE_ENV="production" ENV CHOKIDAR_USEPOLLING=1 @@ -6,8 +6,9 @@ ENV CHOKIDAR_INTERVAL=500 EXPOSE 80 VOLUME /data WORKDIR /data -ENTRYPOINT ["node", "/usr/src/app/", "-p", "80"] +ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"] RUN mkdir -p /usr/src/app COPY / /usr/src/app RUN cd /usr/src/app && npm install --production +RUN ["chmod", "+x", "/usr/src/app/docker-entrypoint.sh"] diff --git a/Dockerfile_test b/Dockerfile_test index 37d34f8..227e1cb 100644 --- a/Dockerfile_test +++ b/Dockerfile_test @@ -2,7 +2,7 @@ # Simply run "docker build -f Dockerfile_test ." # WARNING: sometimes it fails with a core dumped exception -FROM node:10-stretch +FROM node:16-bullseye RUN apt-get -qq update \ && DEBIAN_FRONTEND=noninteractive apt-get -y install \ @@ -17,6 +17,7 @@ RUN apt-get -qq update \ libllvm3.9 \ libprotobuf-dev \ libxxf86vm-dev \ + libopengl0 \ xvfb \ && apt-get clean diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index a93e296..21eeaf7 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -20,7 +20,7 @@ trap refresh HUP if ! which -- "${1}"; then # first arg is not an executable - xvfb-run -a --server-args="-screen 0 1024x768x24" -- node /app/ "$@" & + xvfb-run -a --server-args="-screen 0 1024x768x24" -- node /app/ -p 80 "$@" & # Wait exits immediately on signals which have traps set. Store return value and wait # again for all jobs to actually complete before continuing. wait $! || RETVAL=$? diff --git a/docker-entrypoint_light.sh b/docker-entrypoint_light.sh new file mode 100644 index 0000000..e3c1c67 --- /dev/null +++ b/docker-entrypoint_light.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +set -e + +handle() { + SIGNAL=$(( $? - 128 )) + echo "Caught signal ${SIGNAL}, stopping gracefully" + kill -s ${SIGNAL} $(pidof node) 2>/dev/null +} + +trap handle INT TERM + +refresh() { + SIGNAL=$(( $? - 128 )) + echo "Caught signal ${SIGNAL}, refreshing" + kill -s ${SIGNAL} $(pidof node) 2>/dev/null +} + +trap refresh HUP + +if ! which -- "${1}"; then + # first arg is not an executable + node /usr/src/app/ -p 80 "$@" & + # Wait exits immediately on signals which have traps set. Store return value and wait + # again for all jobs to actually complete before continuing. + wait $! || RETVAL=$? + while [ ${RETVAL} = 129 ] ; do + # Refressh signal HUP received. Continue waiting for signals. + wait $! || RETVAL=$? + done + wait + exit ${RETVAL} +fi + +exec "$@" diff --git a/docs/installation.rst b/docs/installation.rst index 3741e89..232ca7a 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -26,11 +26,30 @@ Native dependencies There are some native dependencies that you need to make sure are installed if you plan to run the TileServer GL natively without docker. The precise package names you need to install may differ on various platforms. -These are required on Debian 9: - * ``build-essential`` - * ``libcairo2-dev`` - * ``libprotobuf-dev`` +These are required on Debian 11: + * ``libgles2-mesa`` + * ``libegl1`` + * ``xvfb`` + * ``xauth`` + * ``libopengl0`` + * ``libcurl4`` + * ``curl`` + * ``libuv1-dev`` + * ``libc6-dev`` + * ``http://archive.ubuntu.com/ubuntu/pool/main/libj/libjpeg-turbo/libjpeg-turbo8_2.0.3-0ubuntu1_amd64.deb`` + * ``http://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu66_66.1-2ubuntu2_amd64.deb`` +These are required on Ubuntu 20.04: + * ``libcairo2-dev`` + * ``libjpeg8-dev`` + * ``libpango1.0-dev`` + * ``libgif-dev`` + * ``build-essential`` + * ``g++`` + * ``xvfb`` + * ``libgles2-mesa-dev`` + * ``libgbm-dev`` + * ``libxxf86vm-dev`` ``tileserver-gl-light`` on npm ============================== diff --git a/package.json b/package.json index 6de09b1..d5c03cc 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "license": "BSD-2-Clause", "engines": { - "node": ">=10 <11" + "node": ">=10 <17" }, "scripts": { "test": "mocha test/**.js --timeout 10000", @@ -18,13 +18,13 @@ }, "dependencies": { "@mapbox/glyph-pbf-composite": "0.0.3", - "@mapbox/mapbox-gl-native": "5.0.2", - "@mapbox/mapbox-gl-style-spec": "13.12.0", - "@mapbox/mbtiles": "0.11.0", - "@mapbox/sphericalmercator": "1.1.0", + "@maplibre/maplibre-gl-native": "5.0.1-pre.0", + "@maplibre/maplibre-gl-style-spec": "17.0.1", + "@mapbox/mbtiles": "0.12.1", + "@mapbox/sphericalmercator": "1.2.0", "@mapbox/vector-tile": "1.3.1", "advanced-pool": "0.3.3", - "canvas": "2.6.1", + "canvas": "2.9.3", "chokidar": "3.3.1", "clone": "2.1.2", "color": "3.1.2", diff --git a/publish.js b/publish.js index 663cab0..26929c9 100644 --- a/publish.js +++ b/publish.js @@ -22,7 +22,7 @@ var packageJson = require('./package'); packageJson.name += '-light'; packageJson.description = 'Map tile server for JSON GL styles - serving vector tiles'; delete packageJson.dependencies['canvas']; -delete packageJson.dependencies['@mapbox/mapbox-gl-native']; +delete packageJson.dependencies['@maplibre/maplibre-gl-native']; delete packageJson.dependencies['sharp']; delete packageJson.optionalDependencies; @@ -34,6 +34,7 @@ var str = JSON.stringify(packageJson, undefined, 2); fs.writeFileSync('light/package.json', str); fs.renameSync('light/README_light.md', 'light/README.md'); fs.renameSync('light/Dockerfile_light', 'light/Dockerfile'); +fs.renameSync('light/docker-entrypoint_light.sh', 'light/docker-entrypoint.sh'); // for Build tileserver-gl-light docker image, don't publish if (process.argv.length > 2 && process.argv[2] == "--no-publish") { diff --git a/src/serve_rendered.js b/src/serve_rendered.js index 11b6bfb..39b6df5 100644 --- a/src/serve_rendered.js +++ b/src/serve_rendered.js @@ -17,7 +17,7 @@ const clone = require('clone'); const Color = require('color'); const express = require('express'); const mercator = new (require('@mapbox/sphericalmercator'))(); -const mbgl = require('@mapbox/mapbox-gl-native'); +const mbgl = require('@maplibre/maplibre-gl-native'); const MBTiles = require('@mapbox/mbtiles'); const proj4 = require('proj4'); const request = require('request'); diff --git a/src/serve_style.js b/src/serve_style.js index 050e9d1..c336eec 100644 --- a/src/serve_style.js +++ b/src/serve_style.js @@ -5,7 +5,7 @@ const fs = require('fs'); const clone = require('clone'); const express = require('express'); -import {validate} from '@mapbox/mapbox-gl-style-spec'; +import {validate} from '@maplibre/maplibre-gl-style-spec'; const utils = require('./utils');