mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-22 09:41:26 -08:00
Simplifying, adding initialization script to docker-compose
This commit is contained in:
parent
8518e88f25
commit
9275966c0a
8 changed files with 42 additions and 52 deletions
|
@ -1,5 +1,15 @@
|
|||
# Tile Server
|
||||
|
||||
A simple tile server using [pg_tileserv](https://github.com/CrunchyData/pg_tileserv).
|
||||
## What is it?
|
||||
|
||||
Based on pg_tileserv [docker example](https://github.com/CrunchyData/pg_tileserv/tree/master/examples/docker).
|
||||
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`
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
BACKENDS_PROBE_INTERVAL: "15s"
|
||||
BACKENDS_PROBE_TIMEOUT: "5s"
|
||||
BACKENDS_PROBE_WINDOW: "3"
|
||||
BACKENDS: "tileserv:7800"
|
||||
DNS_ENABLED: "false"
|
||||
DASHBOARD_USER: "admin"
|
||||
DASHBOARD_PASSWORD: "admin1234"
|
||||
DASHBOARD_SERVERS: "web"
|
||||
PARAM_VALUE: "-p default_ttl=600"
|
|
@ -1,5 +0,0 @@
|
|||
POSTGRES_USER=tileserv
|
||||
POSTGRES_PASS=tileserv
|
||||
PGUSER=tileserv
|
||||
PGPASS=tileserv
|
||||
POSTGRES_DBNAME=tileserv
|
|
@ -1,4 +0,0 @@
|
|||
DATABASE_URL=postgres://tileserv:tileserv@tileserv_db/tileserv
|
||||
POSTGRES_USER=tileserv
|
||||
POSTGRES_PASSWORD=tileserv
|
||||
POSTGRES_DB=tileserv
|
|
@ -1,40 +1,34 @@
|
|||
version: "3.9" # optional since v1.27.0
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
tileserv:
|
||||
image: pramsey/pg_tileserv:20210210
|
||||
container_name: tileserv
|
||||
env_file:
|
||||
- ./config/tileserv.env
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://map_dev_user:map_pwd@db/map_dev
|
||||
depends_on:
|
||||
tileserv_db:
|
||||
db:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- 7800:7800
|
||||
tileserv_db:
|
||||
restart: unless-stopped
|
||||
db:
|
||||
image: kartoza/postgis:13-3.1
|
||||
container_name: tileserv_db
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
- ./data:/work
|
||||
- local_db:/var/lib/postgresql/data
|
||||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
- ./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 tileserv"]
|
||||
test: ["CMD-SHELL", "pg_isready -U map_dev_user -d map_dev"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
env_file:
|
||||
- ./config/db.env
|
||||
|
||||
# See https://blog.crunchydata.com/blog/production-postgis-vector-tiles-caching
|
||||
# cache:
|
||||
# image: eeacms/varnish
|
||||
# container_name: tileserv_cache
|
||||
# ports:
|
||||
# - "80:6081"
|
||||
# env_file:
|
||||
# - ./config/cache.env
|
||||
# depends_on:
|
||||
# - tileserv
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
local_db:
|
||||
pgdata:
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
CREATE EXTENSION IF NOT EXISTS postgis;
|
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"
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Load Maryland geojson
|
||||
echo "Loading data..."
|
||||
docker-compose exec tileserv_db sh -c 'ogr2ogr -progress -f PostgreSQL PG:"dbname=tileserv user=tileserv" /work/maryland.geojson -nln maryland'
|
||||
echo "Data load complete"
|
Loading…
Add table
Reference in a new issue