Skip to content

Commit d5b47a7

Browse files
authored
refactor: switch to pmtiles and self-hosting (#394)
* refactor: switch to pmtiles and self-hosting * refactor: clean up unused pkgs and files
1 parent 6f8c716 commit d5b47a7

6 files changed

Lines changed: 35 additions & 1660 deletions

File tree

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ EXPOSE 4000
77

88
RUN mkdir -p ${APP_DIR}
99

10-
COPY . ./
10+
COPY . *.env ./
11+
1112

1213
RUN yarn install --no-progress && \
1314
yarn build-release

package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"devDependencies": {
1010
"@types/auth0": "^3.3.2",
1111
"@types/jest": "^29.4.0",
12-
"@types/mapbox__mapbox-sdk": "^0.14.0",
1312
"@types/node": "^18.13.0",
1413
"@types/supertest": "^2.0.12",
1514
"@types/underscore": "^1.11.4",
@@ -26,11 +25,9 @@
2625
"wait-for-expect": "^3.0.2"
2726
},
2827
"dependencies": {
29-
"@aws-sdk/client-s3": "^3.507.0",
3028
"@babel/runtime": "^7.17.2",
3129
"@google-cloud/storage": "^6.9.5",
3230
"@graphql-tools/schema": "^8.3.1",
33-
"@mapbox/mapbox-sdk": "^0.15.3",
3431
"@openbeta/sandbag": "^0.0.51",
3532
"@turf/area": "^6.5.0",
3633
"@turf/bbox": "^6.5.0",
@@ -92,9 +89,8 @@
9289
"prepare": "husky install",
9390
"import-users": "yarn build && node build/db/utils/jobs/migration/CreateUsersCollection.js",
9491
"maptiles:export-db": "node build/db/utils/jobs/MapTiles/exportCmd.js",
95-
"maptiles:generate": "./scripts/gen-tiles.sh",
96-
"maptiles:upload": "node build/db/utils/jobs/MapTiles/uploadCmd.js",
97-
"maptiles:full": "yarn build && yarn maptiles:export-db && yarn maptiles:generate && yarn maptiles:upload"
92+
"maptiles:upload": "./scripts/upload-tiles.sh",
93+
"maptiles:full": "yarn build && yarn maptiles:export-db && yarn maptiles:upload"
9894
},
9995
"standard": {
10096
"plugins": [
@@ -114,4 +110,4 @@
114110
"engines": {
115111
"node": ">=16.14.0"
116112
}
117-
}
113+
}

scripts/gen-tiles.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

scripts/upload-tiles.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# 1. Generate pmtiles tiles from geojson exports
3+
# 2. Upload to S3-compatible storage
4+
# See also https://github.com/felt/tippecanoe
5+
6+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
7+
8+
set -a
9+
. ${SCRIPT_DIR}/../.env 2> /dev/null
10+
. ${SCRIPT_DIR}/../.env.local 2> /dev/null
11+
set +a
12+
13+
# Define Cloudflare-R2 backend for rclone
14+
S3_DEST=':s3,provider=Cloudflare,no_check_bucket=true,env_auth=true,acl=private:maptiles'
15+
16+
echo "------ Generating crags tiles file ------"
17+
tippecanoe --force -o ${MAPTILES_WORKING_DIR}/crags.pmtiles -l crags -n "Crags" -zg ${MAPTILES_WORKING_DIR}/crags.*.geojson
18+
19+
echo "**Uploading to remote storage"
20+
rclone copy ${MAPTILES_WORKING_DIR}/crags.pmtiles ${S3_DEST}
21+
22+
echo "------ Generating crag group tiles file ------"
23+
tippecanoe --force -o ${MAPTILES_WORKING_DIR}/crag-groups.pmtiles -l crag-groups -n "Crag groups" -zg ${MAPTILES_WORKING_DIR}/crag-groups.geojson
24+
25+
echo "**Uploading to remote storage"
26+
rclone copy ${MAPTILES_WORKING_DIR}/crag-groups.pmtiles ${S3_DEST}
27+
28+
exit $?

src/db/utils/jobs/MapTiles/uploadCmd.ts

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)