mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-23 01:54:18 -08:00
Merge pull request #1 from usds/pgserver
Adding not-production-ready dockerized pg_tileserv server, mostly for local development
This commit is contained in:
commit
add0f1443c
5 changed files with 3995 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.env
|
15
server/README.md
Normal file
15
server/README.md
Normal 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
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
34
server/docker-compose.yml
Normal 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
12
server/load-data-db.sh
Executable 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"
|
Loading…
Add table
Reference in a new issue