Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rensanrenren committed Jan 3, 2025
1 parent 3c4bfdd commit 8a77728
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 37 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/

name: Fly Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
16 changes: 0 additions & 16 deletions Dockerfile

This file was deleted.

18 changes: 12 additions & 6 deletions app/server.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
const { PMTilesServer } = require('@protomaps/pmtiles');
const express = require('express');
const fs = require('fs');
const path = require('path');
const { PMTiles } = require('/pmtiles/js/dist/index'); // コンパイル後のエントリーポイントを指定

const app = express();
const port = 8080;

// PMTilesファイルが保存されるディレクトリ
const pmtilesPath = '/app/data/';
// PMTilesファイルのディレクトリ
const pmtilesPath = '/app/data';

app.get('/:file/:z/:x/:y', async (req, res) => {
const { file, z, x, y } = req.params;
try {
const filePath = `${pmtilesPath}${file}.pmtiles`;
const server = new PMTilesServer(filePath);
const tile = await server.getTile(z, x, y);
const filePath = path.join(pmtilesPath, `${file}.pmtiles`);
if (!fs.existsSync(filePath)) {
return res.status(404).send('PMTiles file not found');
}

const pmtiles = new PMTiles(filePath);
const tile = await pmtiles.getTile(z, x, y);

if (tile) {
res.setHeader('Content-Type', 'image/png');
Expand Down
32 changes: 17 additions & 15 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
app = "moon-maplibre-view-data"
# fly.toml app configuration file generated for moon-maplibre-view-data-weathered-pine-2280 on 2025-01-03T23:18:24+09:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'moon-maplibre-view-data-weathered-pine-2280'
primary_region = 'nrt'

[build]
dockerfile = "Dockerfile"

[[services]]
[http_service]
internal_port = 8080
protocol = "tcp"

[[services.ports]]
handlers = ["http"]
port = 80

[[services.ports]]
handlers = ["tls"]
port = 443
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[mounts]]
source = "pmtiles_data"
destination = "/app/data"
[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1

0 comments on commit 8a77728

Please sign in to comment.