Merge branch 'master' into ep/reload

This commit is contained in:
Andrew Calcutt 2022-12-15 20:14:37 -05:00 committed by GitHub
commit 646ac6fbb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 864 additions and 435 deletions

19
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: npm
versioning-strategy: increase
directory: '/'
schedule:
interval: daily
commit-message:
prefix: fix
prefix-development: chore
include: scope
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: weekly
commit-message:
prefix: fix
prefix-development: chore
include: scope

20
.github/workflows/automerger.yml vendored Normal file
View file

@ -0,0 +1,20 @@
name: 'Auto Merge PRs'
on:
pull_request:
branches:
- master
permissions:
pull-requests: write
contents: write
jobs:
automerge:
runs-on: ubuntu-latest
if: >
github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]'
steps:
- uses: fastify/github-action-merge-dependabot@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

35
.github/workflows/codeql.yml vendored Normal file
View file

@ -0,0 +1,35 @@
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '45 23 * * 2'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [javascript]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: '/language:${{ matrix.language }}'

57
.github/workflows/ct.yml vendored Normal file
View file

@ -0,0 +1,57 @@
name: 'Continuous Testing'
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
checks: write
contents: read
jobs:
ct:
runs-on: ubuntu-20.04
steps:
- name: Check out repository ✨ (non-dependabot)
if: ${{ github.actor != 'dependabot[bot]' }}
uses: actions/checkout@v3
- name: Check out repository 🎉 (dependabot)
if: ${{ github.actor == 'dependabot[bot]' }}
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Update apt-get 🚀
run: sudo apt-get update -qq
- name: Install dependencies (Ubuntu) 🚀
run: >-
sudo apt-get install -qq libcairo2-dev libjpeg8-dev libpango1.0-dev
libgif-dev build-essential g++ xvfb libgles2-mesa-dev libgbm-dev
libxxf86vm-dev
- name: Setup node env 📦
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
check-latest: true
cache: 'npm'
- name: Install dependencies 🚀
run: npm ci --prefer-offline --no-audit --omit=optional
- name: Pull test data 📦
run: >-
wget -O test_data.zip
https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
- name: Prepare test data 📦
run: unzip -q test_data.zip -d test_data
- name: Run tests 🧪
run: xvfb-run --server-args="-screen 0 1024x768x24" npm test

112
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,112 @@
name: "Build, Test, Release"
on:
workflow_dispatch:
inputs:
docker_user:
description: 'Docker Username'
required: true
docker_token:
description: 'Docker Token'
required: true
npm_token:
description: 'NPM Token'
required: true
jobs:
release:
name: "Build, Test, Publish"
runs-on: ubuntu-20.04
steps:
- name: Check out repository ✨
uses: actions/checkout@v3
- name: Update apt-get 🚀
run: sudo apt-get update -qq
- name: Install dependencies (Ubuntu) 🚀
run: >-
sudo apt-get install -qq libcairo2-dev libjpeg8-dev libpango1.0-dev
libgif-dev build-essential g++ xvfb libgles2-mesa-dev libgbm-dev
libxxf86vm-dev
- name: Setup node env 📦
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
check-latest: true
cache: 'npm'
- name: Install dependencies 🚀
run: npm ci --prefer-offline --no-audit --omit=optional
- name: Pull test data 📦
run: >-
wget -O test_data.zip
https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
- name: Prepare test data 📦
run: unzip -q test_data.zip -d test_data
- name: Run tests 🧪
run: xvfb-run --server-args="-screen 0 1024x768x24" npm test
- name: Remove Test Data
run: rm -R test_data*
- name: Publish to Full Version NPM
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --access public
env:
NPM_TOKEN: ${{ github.event.inputs.npm_token }}
- name: Get version
run: |
echo "PACKAGE_VERSION=$(grep '"version"' package.json | cut -d '"' -f 4 | head -n 1)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ github.event.inputs.docker_user }}
password: ${{ github.event.inputs.docker_token }}
- name: Build and publish Full Version to Docker Hub
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: maptiler/tileserver-gl:latest, maptiler/tileserver-gl:v${{ env.PACKAGE_VERSION }}
platforms: linux/arm64,linux/amd64
- name: Create Tileserver Light Directory
run: node publish.js --no-publish
- name: Install node dependencies
run: npm install
working-directory: ./light
- name: Publish to Light Version NPM
working-directory: ./light
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --access public
env:
NPM_TOKEN: ${{ github.event.inputs.npm_token }}
- name: Build and publish Light Version to Docker Hub
uses: docker/build-push-action@v3
with:
context: ./light
file: ./light/Dockerfile
push: true
tags: maptiler/tileserver-gl-light:latest, maptiler/tileserver-gl-light:v${{ env.PACKAGE_VERSION }}
platforms: linux/arm64,linux/amd64

View file

@ -1,21 +0,0 @@
language: node_js
node_js:
- "10"
env:
- CXX=g++-4.8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
- sudo apt-get install -qq xvfb libgles2-mesa-dev libgbm-dev libxxf86vm-dev
install:
- npm install
- wget -O test_data.zip https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
- unzip -q test_data.zip -d test_data
script:
- xvfb-run --server-args="-screen 0 1024x768x24" npm test

View file

@ -76,7 +76,7 @@ RUN mkdir -p /data && chown node:node /data
VOLUME /data
WORKDIR /data
EXPOSE 80
EXPOSE 8080
USER node:node

View file

@ -20,7 +20,7 @@ RUN set -ex; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*;
EXPOSE 80
EXPOSE 8080
RUN mkdir -p /data && chown node:node /data
VOLUME /data

View file

@ -44,7 +44,7 @@ An alternative to npm to start the packed software easier is to install [Docker]
Example using a mbtiles file
```bash
wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles
docker run --rm -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl --mbtiles zurich_switzerland.mbtiles
docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl --mbtiles zurich_switzerland.mbtiles
[in your browser, visit http://[server ip]:8080]
```
@ -52,13 +52,13 @@ Example using a config.json + style + mbtiles file
```bash
wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
unzip test_data.zip
docker run --rm -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl
docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl
[in your browser, visit http://[server ip]:8080]
```
Example using a different path
```bash
docker run --rm -it -v /your/local/config/path:/data -p 8080:80 maptiler/tileserver-gl
docker run --rm -it -v /your/local/config/path:/data -p 8080:8080 maptiler/tileserver-gl
```
replace '/your/local/config/path' with the path to your config file

View file

@ -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 /usr/src/app/ -p 80 "$@" &
xvfb-run -a --server-args="-screen 0 1024x768x24" -- node /usr/src/app/ "$@" &
# 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=$?

View file

@ -20,7 +20,7 @@ trap refresh HUP
if ! which -- "${1}"; then
# first arg is not an executable
node /usr/src/app/ -p 80 "$@" &
node /usr/src/app/ "$@" &
# 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=$?

View file

@ -7,7 +7,7 @@ Docker
When running docker image, no special installation is needed -- the docker will automatically download the image if not present.
Just run ``docker run --rm -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl``.
Just run ``docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl``.
Additional options (see :doc:`/usage`) can be passed to the TileServer GL by appending them to the end of this command. You can, for example, do the following:

View file

@ -36,3 +36,9 @@ It is possible to reload the configuration file without restarting the whole pro
- The `docker kill -s HUP tileserver-gl` command can be used when running the tileserver-gl docker container.
- The `docker-compose kill -s HUP tileserver-gl-service-name` can be used when tileserver-gl is run as a docker-compose service.
Docker and `--port`
======
When running tileserver-gl in a Docker container, using the `--port` option would make the container incorrectly seem unhealthy.
Instead, it is advised to use Docker's port mapping and map the default port 8080 to the desired external port.

961
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "tileserver-gl",
"version": "4.1.3",
"version": "4.3.2",
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
"main": "src/main.js",
"bin": "src/main.js",
@ -14,7 +14,7 @@
"lint:eslint:fix": "eslint --fix \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs}\" --ignore-path .gitignore",
"lint:prettier": "prettier --check \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs,json}\" --ignore-path .gitignore",
"lint:prettier:fix": "prettier --write \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs,json}\" --ignore-path .gitignore",
"docker": "docker build -f Dockerfile . && docker run --rm -i -p 8080:80 $(docker build -q .)",
"docker": "docker build -f Dockerfile . && docker run --rm -i -p 8080:8080 $(docker build -q .)",
"prepare": "node -e \"if (process.env.NODE_ENV !== 'production'){ process.exit(1) } \" || husky install"
},
"dependencies": {
@ -22,43 +22,43 @@
"@mapbox/mbtiles": "0.12.1",
"@mapbox/sphericalmercator": "1.2.0",
"@mapbox/vector-tile": "1.3.1",
"@maplibre/maplibre-gl-native": "5.0.1-pre.6",
"@maplibre/maplibre-gl-native": "5.1.0",
"@maplibre/maplibre-gl-style-spec": "17.0.1",
"advanced-pool": "0.3.3",
"canvas": "2.10.1",
"canvas": "2.10.2",
"chokidar": "3.5.3",
"clone": "2.1.2",
"color": "4.2.3",
"commander": "9.4.0",
"commander": "9.4.1",
"cors": "2.8.5",
"express": "4.18.1",
"express": "4.18.2",
"handlebars": "4.7.7",
"http-shutdown": "1.2.2",
"morgan": "1.10.0",
"pbf": "3.2.1",
"proj4": "2.8.0",
"request": "2.88.2",
"sharp": "0.31.0",
"sharp": "0.31.2",
"tileserver-gl-styles": "2.0.0",
"sanitize-filename": "1.6.3"
},
"devDependencies": {
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"chai": "4.3.6",
"eslint": "^8.24.0",
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.46.1",
"chai": "4.3.7",
"eslint": "^8.29.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jsdoc": "^39.3.6",
"eslint-plugin-jsdoc": "^39.6.4",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-security": "^1.5.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"mocha": "^10.0.0",
"prettier": "^2.7.1",
"lint-staged": "^13.1.0",
"mocha": "^10.2.0",
"prettier": "^2.8.1",
"should": "^13.2.3",
"supertest": "^6.2.4",
"supertest": "^6.3.3",
"yaml-lint": "^1.7.0"
},
"keywords": [

2
run.sh
View file

@ -29,7 +29,7 @@ export DISPLAY=:${displayNumber}.${screenNumber}
echo
cd /data
node /usr/src/app/ -p 80 "$@" &
node /usr/src/app/ "$@" &
child=$!
wait "$child"

View file

@ -2,7 +2,7 @@ import * as http from 'http';
var options = {
timeout: 2000,
};
var url = 'http://localhost:80/health';
var url = 'http://localhost:8080/health';
var request = http.request(url, options, (res) => {
console.log(`STATUS: ${res.statusCode}`);
if (res.statusCode == 200) {

View file

@ -54,7 +54,10 @@ export const serve_data = {
if (/does not exist/.test(err.message)) {
return res.status(204).send();
} else {
return res.status(500).send(err.message);
return res
.status(500)
.header('Content-Type', 'text/plain')
.send(err.message);
}
} else {
if (data == null) {

View file

@ -54,7 +54,7 @@ export const serve_font = (options, allowedFonts) => {
res.header('Last-Modified', lastModified);
return res.send(concated);
},
(err) => res.status(400).send(err),
(err) => res.status(400).header('Content-Type', 'text/plain').send(err),
);
});

View file

@ -661,7 +661,10 @@ export const serve_rendered = {
pool.release(renderer);
if (err) {
console.error(err);
return res.status(500).send(err);
return res
.status(500)
.header('Content-Type', 'text/plain')
.send(err);
}
// Fix semi-transparent outlines on raw, premultiplied input