Open Infrastructure Map, a view of infrastructure data in OpenStreetMap
Generalise tegola Docker with ability to use several configurations at build
FLacombe13c75f9e4f16
diff --git a/tegola/Dockerfile b/tegola/Dockerfileindex ffddd8a..49e6e9a 100644--- a/tegola/Dockerfile+++ b/tegola/Dockerfile@@ -1,11 +1,18 @@# Generate the Tegola config and bake it into a container.FROM python:3.9-slim AS build+ARG TEGOLA_CONFIG=.+WORKDIR /app-COPY . .+COPY ./*.py ./+COPY ${TEGOLA_CONFIG}/layers.yml ${TEGOLA_CONFIG}/tegola.yml ./RUN pip install PyYAML tomlRUN python generate_tegola_config.py ./tegola.yml ./layers.yml > ./config.tomlFROM gospatial/tegola:v0.16.0++ENV BOUNDS="-180,-85.0511,180,85.0511" \+ DB_URI=postgres://user:password@host:5432/database+COPY --from=build /app/config.toml /etc/tegola/config.tomlEXPOSE 80diff --git a/tegola/Dockerfile.expiry b/tegola/Dockerfile.expiryindex 9d958f1..86f9e3c 100644--- a/tegola/Dockerfile.expiry+++ b/tegola/Dockerfile.expiry@@ -1,6 +1,20 @@-# Container with the Tegola tileserver binary and the expire.py script,+## Container with the Tegola tileserver binary and the expire.py script,# which is used to invalidate tiles based on expiry files generated by Imposm.-FROM ghcr.io/openinframap/tileserver+FROM python:3.9-slim AS build+ARG TEGOLA_CONFIG=.++WORKDIR /app+COPY ./*.py ./+COPY ${TEGOLA_CONFIG}/layers.yml ${TEGOLA_CONFIG}/tegola.yml ./+RUN pip install PyYAML toml+RUN python generate_tegola_config.py ./tegola.yml ./layers.yml > ./config.toml++FROM gospatial/tegola:v0.16.0++ENV BOUNDS="-180,-85.0511,180,85.0511" \+ DB_URI=postgres://user:password@host:5432/database++COPY --from=build /app/config.toml /etc/tegola/config.tomlRUN apk update && \apk add python3 py3-pip && \diff --git a/tegola/README.md b/tegola/README.mdnew file mode 100644index 0000000..773f435--- /dev/null+++ b/tegola/README.md@@ -0,0 +1,47 @@+# OpennfraMap Tileserver++Map tiles are served with [Tegola](https://tegola.io/). There's a YAML-based language+which generates the Tegola config, from the `tegola.yml` and `layers.yml` files++## Build++You can generate Tegola config with:++```sh+python3 ./generate_tegola_config.py ./tegola.yml ./layers.yml > ./config.toml`+```++### Docker++Two images are to be considered, one to serve tiles and one to handle expiry logs coming from imposm.++Docker allows to build several images based upon independant configurations, with:++```sh+docker build --build-arg TEGOLA_CONFIG=. -f Dockerfile -t openinframap/tileserver .+docker build --build-arg TEGOLA_CONFIG=. -f Dockerfile.expiry -t openinframap/tileserverexpiry .+```++It is possible to omit TEGOLA_CONFIG arg to use `tegola.yml` and `layers.yml` from this directory.+Any other value sould refer to a directory available in docker builder scope container another `tegola.yml` and `layers.yml`.++## Run++Tegola is started with:++```sh+/opt/tegola serve --config ./config.toml+```++### Docker++You should run both container, main and expiry as to serve tiles and handle expiry logs coming from imposm++```sh+docker run -d --rm -v /tmp:/tmp -e BOUNDS=-180,-85.0511,180,85.0511 -e DB_URI=postgres://user:password@host:port/database openinframap/tileserver++docker run -d --rm -v /tmp:/tmp -e BOUNDS=-180,-85.0511,180,85.0511 -e DB_URI=postgres://user:password@host:port/database openinframap/tileserverexpiry+```++`BOUNDS` states which extent is served by the tileserver+`DB_URI` sets connection to the database\ No newline at end of filediff --git a/tegola/tegola.yml b/tegola/tegola.ymlindex b05e901..2cf1add 100644--- a/tegola/tegola.yml+++ b/tegola/tegola.yml@@ -8,5 +8,6 @@ cache:providers:- name: postgistype: mvt_postgis- uri: postgres://osm:[email protected]:5432/osm?pool_max_conns=20- srid: 3857\ No newline at end of file+ uri: "${DB_URI}"+ srid: 3857+ max_connections: 20\ No newline at end of file