Skip to content

Commit

Permalink
refactor: switch to pmtiles and self-hosting (#394)
Browse files Browse the repository at this point in the history
* refactor: switch to pmtiles and self-hosting
* refactor: clean up unused pkgs and files
  • Loading branch information
vnugent committed Feb 24, 2024
1 parent 6f8c716 commit d5b47a7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1,660 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ EXPOSE 4000

RUN mkdir -p ${APP_DIR}

COPY . ./
COPY . *.env ./


RUN yarn install --no-progress && \
yarn build-release
Expand Down
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"devDependencies": {
"@types/auth0": "^3.3.2",
"@types/jest": "^29.4.0",
"@types/mapbox__mapbox-sdk": "^0.14.0",
"@types/node": "^18.13.0",
"@types/supertest": "^2.0.12",
"@types/underscore": "^1.11.4",
Expand All @@ -26,11 +25,9 @@
"wait-for-expect": "^3.0.2"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.507.0",
"@babel/runtime": "^7.17.2",
"@google-cloud/storage": "^6.9.5",
"@graphql-tools/schema": "^8.3.1",
"@mapbox/mapbox-sdk": "^0.15.3",
"@openbeta/sandbag": "^0.0.51",
"@turf/area": "^6.5.0",
"@turf/bbox": "^6.5.0",
Expand Down Expand Up @@ -92,9 +89,8 @@
"prepare": "husky install",
"import-users": "yarn build && node build/db/utils/jobs/migration/CreateUsersCollection.js",
"maptiles:export-db": "node build/db/utils/jobs/MapTiles/exportCmd.js",
"maptiles:generate": "./scripts/gen-tiles.sh",
"maptiles:upload": "node build/db/utils/jobs/MapTiles/uploadCmd.js",
"maptiles:full": "yarn build && yarn maptiles:export-db && yarn maptiles:generate && yarn maptiles:upload"
"maptiles:upload": "./scripts/upload-tiles.sh",
"maptiles:full": "yarn build && yarn maptiles:export-db && yarn maptiles:upload"
},
"standard": {
"plugins": [
Expand All @@ -114,4 +110,4 @@
"engines": {
"node": ">=16.14.0"
}
}
}
16 changes: 0 additions & 16 deletions scripts/gen-tiles.sh

This file was deleted.

28 changes: 28 additions & 0 deletions scripts/upload-tiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# 1. Generate pmtiles tiles from geojson exports
# 2. Upload to S3-compatible storage
# See also https://github.com/felt/tippecanoe

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

set -a
. ${SCRIPT_DIR}/../.env 2> /dev/null
. ${SCRIPT_DIR}/../.env.local 2> /dev/null
set +a

# Define Cloudflare-R2 backend for rclone
S3_DEST=':s3,provider=Cloudflare,no_check_bucket=true,env_auth=true,acl=private:maptiles'

echo "------ Generating crags tiles file ------"
tippecanoe --force -o ${MAPTILES_WORKING_DIR}/crags.pmtiles -l crags -n "Crags" -zg ${MAPTILES_WORKING_DIR}/crags.*.geojson

echo "**Uploading to remote storage"
rclone copy ${MAPTILES_WORKING_DIR}/crags.pmtiles ${S3_DEST}

echo "------ Generating crag group tiles file ------"
tippecanoe --force -o ${MAPTILES_WORKING_DIR}/crag-groups.pmtiles -l crag-groups -n "Crag groups" -zg ${MAPTILES_WORKING_DIR}/crag-groups.geojson

echo "**Uploading to remote storage"
rclone copy ${MAPTILES_WORKING_DIR}/crag-groups.pmtiles ${S3_DEST}

exit $?
118 changes: 0 additions & 118 deletions src/db/utils/jobs/MapTiles/uploadCmd.ts

This file was deleted.

Loading

0 comments on commit d5b47a7

Please sign in to comment.