From 1bf8b18af9eb6c9b9c82e0c03d55297aaa10b648 Mon Sep 17 00:00:00 2001 From: Thomas Nordquist Date: Wed, 19 Jul 2017 12:54:37 +0200 Subject: [PATCH] Initial commit --- Dockerfile | 17 ++++++++++++++++ README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 15 +++++++++++++++ entrypoint.sh | 15 +++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f4825c1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM openjdk:8-jre + +# Install pbzip2 for parallel extraction +RUN apt-get update \ + && apt-get -y install \ + pbzip2 \ + wget \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /photon +ADD http://photon.komoot.de/data/photon-0.2.7.jar /photon/photon.jar +COPY entrypoint.sh ./entrypoint.sh + +VOLUME /photon/photon_data +EXPOSE 2322 + +ENTRYPOINT /photon/entrypoint.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..420ae26 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +[![GitHub issues](https://img.shields.io/github/issues/thomasnordquist/photon-docker.svg)](https://github.com/thomasnordquist/photon-docker/issues) [![GitHub stars](https://img.shields.io/github/stars/thomasnordquist/photon-docker.svg)](https://github.com/thomasnordquist/photon-docker/stargazers) [![GitHub forks](https://img.shields.io/github/forks/thomasnordquist/photon-docker.svg)](https://github.com/thomasnordquist/photon-docker/network) + +Have your own geocoder up and running within the hour, you will require about 60GB of disk space. + +Feel free to fork and improve + +# Run + +The image itself is pretty small, the first time the container is executed, a 30GB searchindex will be downloaded. +The data volume is exposed as `/photon/photon_data` and can be mounted, this way you'll only have to download the data once. + +## With `docker run` + +``` +docker run -p 2322:2322 -it thomasnordquist/photon-geocoder:latest +``` + +## Build and run from git +https://github.com/thomasnordquist/photon-docker + +### With docker-compose +``` +docker-compose build +docker-compose up +``` +*Note: if you abort the download, you have to remove the volume `photon_data` before restarting the container* + + +### Without docker-compose +``` +docker build --tag thomasnordquist/photon-geocoder:latest . +docker run -p 2322:2322 -it thomasnordquist/photon-geocoder:latest + +``` + + +## FAQ + + - How do I pass arguments to the `photon.jar` ? + + *The entrypoint accepts arguments for the `photon.jar`, you can invoke it by using `docker exec`* + - Do I need to have nominatim ? + + *The container downloads the latest prebuilt search index, there is no immediate need to have nominatim installed.* + + - What is photon ? + + *photon is a geocoder, check out ***[their website](https://photon.komoot.de/)*** and their ***[github repository](https://github.com/komoot/photon)**** diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..47034ae --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: '2' +services: + photon: + build: + context: . + dockerfile: Dockerfile + image: thomasnordquist/photon-geocoder:latest + volumes: + - data:/photon/photon_data + ports: + - 2322:2322 + +volumes: + data: + driver: local diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..b469a23 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Download elasticsearch index +if [ ! -d "/photon/photon_data/elasticsearch" ]; then + echo "Downloading search index" + wget -O - http://download1.graphhopper.com/public/photon-db-latest.tar.bz2 | bzip2 -cd | tar x +fi + +# Start photon if elastic index exists +if [ -d "/photon/photon_data/elasticsearch" ]; then + echo "Start photon" + java -jar photon.jar $@ +else + echo "Could not start photon, the search index could not be found" +fi