Skip to content

Commit

Permalink
Merge pull request #453 from dfpc-coe/pmtiles-api
Browse files Browse the repository at this point in the history
Add PMTiles API
  • Loading branch information
ingalls authored Dec 18, 2024
2 parents d654705 + 2be5008 commit 4d99ef0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
19 changes: 18 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
services:
api:
platform: linux/amd64
build: ./api/
build:
context: ./api/
dockerfile: Dockerfile
restart: 'always'
links:
- postgis
Expand All @@ -23,6 +25,21 @@ services:
- API_URL=localhost:5000
- ROOT_URL=localhost:5001

tiles:
platform: linux/amd64
build:
context: ./tasks/pmtiles/
dockerfile: Dockerfile.compose
restart: 'always'
ports:
- "5002:5002"
environment:
- SigningSecret=coe-wildland-fire
- ASSET_BUCKET=cloudtak
- AWS_S3_Endpoint=http://store:9000
- AWS_S3_AccessKeyId=cloudtakminioadmin
- AWS_S3_SecretAccessKey=cloudtakminioadmin

media:
build: https://github.com/dfpc-coe/media-infra.git
restart: 'always'
Expand Down
22 changes: 22 additions & 0 deletions tasks/pmtiles/Dockerfile.compose
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM alpine:3.20

EXPOSE 5002

ENV HOME=/home/etl
WORKDIR $HOME

RUN apk add git nodejs-current npm

WORKDIR $HOME/tiles

ADD package.json ./
ADD package-lock.json ./

RUN npm install

COPY ./ $HOME/tiles

RUN npm run lint \
&& npm run build

CMD ["npm", "run", "prod"]
4 changes: 3 additions & 1 deletion tasks/pmtiles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"scripts": {
"check": "tsc --noEmit",
"lint": "eslint src/",
"build": "tsup --target es2022 --format esm src/"
"build": "tsup --target es2022 --format esm src/",
"dev": "tsx watch src/index.ts --noevents --nometrics --nosinks --unsafe",
"prod": "NODE_OPTIONS='--max-old-space-size=6144' node dist/index.js"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.213.0",
Expand Down
15 changes: 14 additions & 1 deletion tasks/pmtiles/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ app.use(cors({

app.use(schema.router);

schema.get('/tiles', {
name: 'API Info',
group: 'Root',
description: 'Return API Info for the Tiles API',
res: Type.Object({
name: Type.String()
})
}, (req, res) => {
res.json({
name: process.env.StackName || 'Default Tiles API'
});
});

schema.get('/tiles/profile/:username/:file', {
name: 'Get TileJSON',
group: 'ProfileTiles',
Expand Down Expand Up @@ -310,7 +323,7 @@ export const handler = serverless(app);

const startServer = async () => {
app.listen(5002, () => {
console.log('ok - tile server on localhost:5002');
console.log('ok - tile server on http://localhost:5002');
});
};

Expand Down

0 comments on commit 4d99ef0

Please sign in to comment.