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

feat: serve styles from tileserver #33

Merged
merged 5 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
30 changes: 27 additions & 3 deletions .github/workflows/tiles-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,41 @@ on:
branches: [ "main" ]
paths:
- ".github/workflows/tiles-file.yml"
- "styles-gen/**"

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
deploy_tiles:
name: Deploy Tiles
name: Deploy Tiles & Styles
strategy:
matrix:
bucket_region: [ "wnam", "enam", "weur", "eeur", "apac" ]
defaults:
run:
working-directory: 'styles-gen'
runs-on: ubuntu-latest
outputs:
KEY: ${{ steps.latest_build.outputs.KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: 'styles-gen/.nvmrc'

- name: Install dependencies
run: npm ci

- name: Generate styles
run: npm run generate

- name: Find latest pmtiles build
id: latest_build
env:
Expand All @@ -34,6 +54,7 @@ jobs:
else
build=$FILE_NAME
fi
export build=${build%.pmtiles}
echo "KEY=$build"
echo "KEY=$build" >> $GITHUB_OUTPUT

Expand All @@ -53,8 +74,11 @@ jobs:
type = http
url = https://build.protomaps.com/

- name: Copy latest styles to R2
run: rclone --progress copy ./dist/ r2:/tiles-${{ matrix.bucket_region }}/${{ steps.latest_build.outputs.KEY }}/styles/ --s3-no-check-bucket --s3-chunk-size=64M --multi-thread-streams=50 --checkers=512

- name: Copy latest tiles to R2
run: rclone --progress copyto pmtiles:/${{ steps.latest_build.outputs.KEY }} r2:/tiles-${{ matrix.bucket_region }}/${{ steps.latest_build.outputs.KEY }} --s3-no-check-bucket --s3-chunk-size=64M --multi-thread-streams=50 --checkers=512
run: rclone --progress copyto pmtiles:/${{ steps.latest_build.outputs.KEY }}.pmtiles r2:/tiles-${{ matrix.bucket_region }}/${{ steps.latest_build.outputs.KEY }}/tiles.pmtiles --s3-no-check-bucket --s3-chunk-size=64M --multi-thread-streams=50 --checkers=512
update_tile_ref:
name: Update tile server file reference
needs: [deploy_tiles]
Expand All @@ -74,7 +98,7 @@ jobs:

- name: Update deployment file name
run: |
sed -i -E 's/"pmtiles_file_name": "(.*)"/"pmtiles_file_name": "${{ needs.deploy_tiles.outputs.KEY }}"/' deployment/modules/cloudflare/tiles-worker/tiles.tfvars.json
sed -i -E 's/"pmtiles_deployment_key": "(.*)"/"pmtiles_deployment_key": "${{ needs.deploy_tiles.outputs.KEY }}"/' deployment/modules/cloudflare/tiles-worker/tiles.tfvars.json

- name: Push updated tiles.tfvars to repo
uses: EndBug/add-and-commit@v9
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "submodules/basemaps"]
path = submodules/basemaps
url = https://github.com/protomaps/basemaps.git
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"pmtiles_file_name": "20240812.pmtiles"
"pmtiles_deployment_key": "20240812"
}
2 changes: 1 addition & 1 deletion deployment/modules/cloudflare/tiles-worker/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variable "cloudflare_account_id" {}
variable "tf_state_postgres_conn_str" {}
variable "pmtiles_file_name" {}
variable "pmtiles_deployment_key" {}
variable "tiles_build_dir" {}
variable "vmetrics_api_token" {}
variable "env" {}
2 changes: 1 addition & 1 deletion deployment/modules/cloudflare/tiles-worker/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource "cloudflare_workers_script" "tiles" {

plain_text_binding {
name = "PMTILES_FILE_NAME"
text = var.pmtiles_file_name
text = var.pmtiles_deployment_key
}

plain_text_binding {
Expand Down
2 changes: 2 additions & 0 deletions styles-gen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
1 change: 1 addition & 0 deletions styles-gen/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.10
Loading
Loading