├── Dockerfile ├── README.md ├── docker-compose.yml └── entrypoint.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jre 2 | 3 | # Install pbzip2 for parallel extraction 4 | RUN apt-get update \ 5 | && apt-get -y install \ 6 | pbzip2 \ 7 | wget \ 8 | && rm -rf /var/lib/apt/lists/* 9 | 10 | WORKDIR /photon 11 | ADD https://github.com/komoot/photon/releases/download/0.4.2/photon-0.4.2.jar /photon/photon.jar 12 | COPY entrypoint.sh ./entrypoint.sh 13 | 14 | VOLUME /photon/photon_data 15 | EXPOSE 2322 16 | 17 | ENTRYPOINT /photon/entrypoint.sh 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Have your own geocoder up and running within the hour, you will require about 60GB of disk space and has no further dependencies. If you select a specific country, you can reduce the necessary disk space. 2 | 3 | Feel free to fork and improve. 4 | 5 | See this [blog post](https://tonsnoei.nl/en/post/2023/03/20/set-up-your-own-geocoder-api/) for more info. 6 | 7 | 8 | # Run 9 | 10 | The image itself is pretty small, the first time the container is executed, a 60GB searchindex will be downloaded. The [blog post](https://tonsnoei.nl/en/post/2023/03/20/set-up-your-own-geocoder-api/) explains how to use only a specific country or region. 11 | 12 | The data volume is exposed as `/photon/photon_data` and can be mounted, this way you'll only have to download the data once. 13 | 14 | ## With `docker run` 15 | 16 | ```bash 17 | docker run -p 2322:2322 -it tonsnoei/photon-geocoder:latest 18 | ``` 19 | 20 | ## Search 21 | 22 | ``` 23 | http://localhost:2322/api?q=amsterdam 24 | ``` 25 | *For more details on the API check the Photon [github repository](https://github.com/komoot/photon).* 26 | 27 | 28 | 29 | ## Build from git 30 | https://github.com/tonsnoei/photon-docker 31 | 32 | ### With docker-compose 33 | ```bash 34 | docker-compose build #optional 35 | docker-compose up 36 | ``` 37 | *Note: if you abort the download, you have to remove the volume `photon_data` before restarting the container* 38 | 39 | 40 | ## FAQ 41 | 42 | - How do I pass arguments to the `photon.jar` ? 43 | 44 | *The entrypoint accepts arguments for the `photon.jar`, you can invoke it by using `docker exec`* 45 | - Do I need to have nominatim ? 46 | 47 | *The container downloads the latest prebuilt search index, there is no immediate need to have nominatim installed.* 48 | 49 | - What is Photon ? 50 | 51 | *Photon is a geocoder, check out [their website](https://photon.komoot.de/) and their [github repository](https://github.com/komoot/photon)* 52 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | photon: 4 | build: 5 | context: . 6 | dockerfile: Dockerfile 7 | image: tonsnoei/photon-geocoder:latest 8 | volumes: 9 | - ./data:/photon/photon_data 10 | ports: 11 | - 2322:2322 12 | 13 | volumes: 14 | data: 15 | driver: local 16 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # Download elasticsearch index 5 | if [ ! -d "/photon/photon_data/elasticsearch" ]; then 6 | echo "Downloading search index" 7 | 8 | # Let graphhopper know where the traffic is coming from 9 | USER_AGENT="docker: tonsnoei/photon-geocoder" 10 | # If you want to install a specific region only, enable the line below and disable the current 'wget' row. 11 | # Take a look at http://download1.graphhopper.com/public/extracts/by-country-code for your country 12 | # wget --user-agent="$USER_AGENT" -O - http://download1.graphhopper.com/public/extracts/by-country-code/nl/photon-db-nl-latest.tar.bz2 | bzip2 -cd | tar x 13 | wget --user-agent="$USER_AGENT" -O - http://download1.graphhopper.com/public/photon-db-latest.tar.bz2 | bzip2 -cd | tar x 14 | fi 15 | 16 | # Start photon if elastic index exists 17 | if [ -d "/photon/photon_data/elasticsearch" ]; then 18 | echo "Start photon" 19 | java -jar photon.jar $@ 20 | else 21 | echo "Could not start photon, the search index could not be found" 22 | fi 23 | --------------------------------------------------------------------------------