Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal maplibre-gl-native changes + docker build update #602

Merged
merged 10 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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

Expand All @@ -51,5 +61,3 @@ EXPOSE 80
USER node:node

ENTRYPOINT ["/app/docker-entrypoint.sh"]

CMD ["-p", "80"]
5 changes: 3 additions & 2 deletions Dockerfile_light
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM node:10-stretch
FROM node:16-bullseye

ENV NODE_ENV="production"
ENV CHOKIDAR_USEPOLLING=1
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"]
3 changes: 2 additions & 1 deletion Dockerfile_test
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -17,6 +17,7 @@ RUN apt-get -qq update \
libllvm3.9 \
libprotobuf-dev \
libxxf86vm-dev \
libopengl0 \
xvfb \
&& apt-get clean

Expand Down
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=$?
Expand Down
35 changes: 35 additions & 0 deletions docker-entrypoint_light.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
27 changes: 23 additions & 4 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
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``
* ``libprotobuf-dev``

* ``libjpeg8-dev``
* ``libpango1.0-dev``
* ``libgif-dev``
* ``build-essential``
* ``g++``
* ``xvfb``
* ``libgles2-mesa-dev``
* ``libgbm-dev``
* ``libxxf86vm-dev``

``tileserver-gl-light`` on npm
==============================
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
},
"license": "BSD-2-Clause",
"engines": {
"node": ">=10 <11"
"node": ">=10 <17"
},
"scripts": {
"test": "mocha test/**.js --timeout 10000",
"docker": "docker build -f Dockerfile . && docker run --rm -i -p 8080:80 $(docker build -q .)"
},
"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",
Expand Down
3 changes: 2 additions & 1 deletion publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion src/serve_rendered.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/serve_style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down