Merge pull request #1 from usds/pgserver

Adding not-production-ready dockerized pg_tileserv server, mostly for local development
This commit is contained in:
Nat Hillard 2021-05-04 15:02:16 -04:00 committed by GitHub
commit add0f1443c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 3995 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.env

15
server/README.md Normal file
View file

@ -0,0 +1,15 @@
# Tile Server
## What is it?
A simple tile server using [pg_tileserv](https://github.com/CrunchyData/pg_tileserv), based on pg_tileserv [docker example](https://github.com/CrunchyData/pg_tileserv/tree/master/examples/docker).
## How to use it?
1. Edit variables in `docker-compose.yml` if necessary to customize username/pw
2. Run `docker-compose up` to start running the server. It will likely stall in enabling extensions (TODO: figure this out))
3. Restart the server with ctrl-c. It should load the data from the `data/` directory exactly one time.
## Using
- Point your visualization library to the following URL, and select `vector` tiles: `http://localhost:7800/public.maryland/{z}/{x}/{y}.mvt`

3933
server/data/maryland.geojson Normal file

File diff suppressed because one or more lines are too long

34
server/docker-compose.yml Normal file
View file

@ -0,0 +1,34 @@
version: "3.9"
services:
tileserv:
image: pramsey/pg_tileserv:20210210
environment:
- DATABASE_URL=postgresql://map_dev_user:map_pwd@db/map_dev
depends_on:
db:
condition: service_healthy
ports:
- 7800:7800
restart: unless-stopped
db:
image: kartoza/postgis:13-3.1
volumes:
- pgdata:/var/lib/postgresql/data
- ./data:/work
- ./load-data-db.sh:/docker-entrypoint-initdb.d/load_data-db.sh
environment:
- POSTGRES_USER=map_dev_user
- POSTGRES_PASS=map_pwd
- POSTGRES_DB=map_dev
- ALLOW_IP_RANGE=0.0.0.0/0
ports:
- 5434:5432
healthcheck:
test: ["CMD-SHELL", "pg_isready -U map_dev_user -d map_dev"]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
volumes:
pgdata:

12
server/load-data-db.sh Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail
# echo "[SQL INIT SCRIPT] Creating extension..."
# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "gis" <<-EOSQL
# CREATE EXTENSION IF NOT EXISTS postgis;
# EOSQL
# Load Maryland geojson
echo "[SQL INIT SCRIPT] Loading data from geojson..."
ogr2ogr -progress -f PostgreSQL PG:"host=localhost dbname=map_dev user=map_dev_user password=map_pwd" /work/maryland.geojson -nln maryland
echo "Data load complete"