From feb188ba1cd9d3b23941b3fed721092143d3b960 Mon Sep 17 00:00:00 2001 From: Stepan Kuzmin Date: Mon, 4 Feb 2019 13:00:37 +0300 Subject: [PATCH] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20=20add=20note=20on?= =?UTF-8?q?=20running=20docker=20with=20localhost=20postgres?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9e492ca8..e0462bbe 100755 --- a/README.md +++ b/README.md @@ -98,13 +98,11 @@ Function Source is a database function which can be used to query [vector tiles] Here is an example of a function that can be used as a Function Source. ```plsql -CREATE OR REPLACE FUNCTION public.function_source(z integer, x integer, y integer, query_params json) RETURNS bytea AS $$ +CREATE OR REPLACE FUNCTION public.function_source(z integer, x integer, y integer, query_params json) RETURNS BYTEA AS $$ DECLARE - bounds geometry; - mvt bytea; + bounds GEOMETRY(POLYGON, 3857) := TileBBox(z, x, y, 3857); + mvt BYTEA; BEGIN - SELECT INTO bounds TileBBox(z, x, y, 3857); - SELECT INTO mvt ST_AsMVT(tile, 'public.function_source', 4096, 'geom') FROM ( SELECT ST_AsMVTGeom(geom, bounds, 4096, 64, true) AS geom @@ -209,7 +207,7 @@ You can also configure martin using environment variables ## Using with Docker -You can use official Docker image `urbica/martin` +You can use official Docker image [`urbica/martin`](https://hub.docker.com/r/urbica/martin) ```shell docker run \ @@ -218,6 +216,36 @@ docker run \ urbica/martin ``` +If you are running PostgreSQL instance on `localhost`, you have to change network settings to allow the Docker container to access the `localhost` network. + +For Linux, add the `--net=host` flag to access the `localhost` PostgreSQL service. + +```shell +docker run \ + --net=host \ + -p 3000:3000 \ + -e DATABASE_URL=postgres://postgres@localhost/db \ + urbica/martin +``` + +For macOS, use `host.docker.internal` as hostname to access the `localhost` PostgreSQL service. + +```shell +docker run \ + -p 3000:3000 \ + -e DATABASE_URL=postgres://postgres@host.docker.internal/db \ + urbica/martin +``` + +For Windows, use `docker.for.win.localhost` as hostname to access the `localhost` PostgreSQL service. + +```shell +docker run \ + -p 3000:3000 \ + -e DATABASE_URL=postgres://postgres@docker.for.win.localhost/db \ + urbica/martin +``` + ## Building from Source You can clone the repository and build martin using [cargo](https://doc.rust-lang.org/cargo) package manager.