Photon Docker Image
repository·main·Indexed 42 days ago
https://github.com/rtuszik/photon-dockerAn unofficial Docker distribution of the Photon geocoding engine, version 2.3.1, providing local OpenStreetMap-based search-as-you-type and reverse geocoding. Supports two import modes: a stable prebuilt index (db) and an experimental build from OSM JSONL dumps (jsonl). Includes configurable update strategies, regional data support, and Prometheus metrics integration.
What's inside Photon Docker
- This repository provides an unofficial Docker image for Photon, an open-source geocoding solution based on OpenStreetMap (OSM) data. Photon supports search-as-you-type and reverse geocoding. This Docker implementation allows for local hosting, which improves data privacy and facilitates integration with other services like Dawarich.
Important storage and performance considerations for Photon
mainRunning Photon requires significant disk space and time due to the size of the OSM data index.
Storage Requirements
As of mid-2026, expect the following approximate sizes:
dbmode: ~60GB (compressed planet index)jsonlmode: ~26GB (planet JSONL dump)
Performance Expectations
- Initial Setup: Downloading, extracting, and verifying checksums can take several hours depending on your hardware.
- JSONL Import: Importing the full planet JSONL is a heavy operation. On a 4C/16GB VPS, a full import took approximately 10 hours and 25 minutes.
Data Sources
To prevent overloading official Photon servers, the default
BASE_URLpoints to a community mirror.Choose an Import Mode for the Photon index
mainThe image supports two ways to build the search index via the
IMPORT_MODEenvironment variable:db(default): Downloads a prebuilt index (.tar.bz2) for a single region. This is the stable mode and supports scheduled updates usingUPDATE_STRATEGYandUPDATE_INTERVAL.jsonl(experimental): Builds the index inside the container from compressed OpenStreetMap JSONL dumps. This mode allows combining multiple regions and fine-tuning the import.
Note:
jsonlmode is experimental, does not support scheduled updates, and requiresFORCE_UPDATE=TRUEor a volume recreation to rebuild. It also does not supportFILE_URLorMD5_URL.# Example using experimental JSONL mode services: photon: image: rtuszik/photon-docker:latest environment: - IMPORT_MODE=jsonl - REGION=germany,austria,switzerland-liechtenstein - LANGUAGES=en,deIntegrate Photon with Dawarich
mainTo use this Photon container as a reverse-geocoder for Dawarich, configure the following environment variables in your Dawarich
docker-compose.yml:PHOTON_API_HOST: The IP address and port of your Photon instance (e.g.,192.168.10.10:2322). Do not append/apito this value.PHOTON_API_USE_HTTPS: Set tofalseunless your Photon instance is served over HTTPS.
Example configuration for Dawarich:
PHOTON_API_HOST=192.168.10.10:2322 PHOTON_API_USE_HTTPS=falseConfigure JSONL Import Mode (Experimental)
mainTo use the experimental
jsonlmode, setIMPORT_MODE=jsonl. You can specify one or more regions in theREGIONvariable (comma-separated). When multiple regions are requested, the container downloads the smallest dump covering all requested areas (e.g., a continent orplanet) and then filters it.Available configuration options for
jsonlmode:REGION: Comma-separated list of regions.LANGUAGES: List of languages (e.g.,en,de).EXTRA_TAGS: (Optional) Additional OSM tags to include (e.g.,surface,smoothness).IMPORT_GEOMETRIES: (Optional) Set totrueto include full geometries.REVERSE_ONLY: Set toTRUEto build a reverse-geocoding-only index. This results in a smaller index and faster import, but disables forward search endpoints (/api,/structured) and/metrics, serving only the/reverseendpoint.
services: photon: image: rtuszik/photon-docker:latest environment: - IMPORT_MODE=jsonl - REGION=germany,austria,switzerland-liechtenstein - LANGUAGES=en,de # - EXTRA_TAGS=surface,smoothness # - IMPORT_GEOMETRIES=true volumes: - photon_data:/photon/data restart: unless-stopped ports: - "2322:2322" volumes: photon_data:Deploy Photon using Docker Compose
mainYou can deploy the Photon Docker container using a
docker-compose.ymlfile. The following example sets up a service namedphotonusing thertuszik/photon-docker:latestimage, configures a parallel update strategy, and maps a persistent volume for data storage.To start the service in detached mode, run:
docker compose up -dservices: photon: image: rtuszik/photon-docker:latest environment: - UPDATE_STRATEGY=PARALLEL - UPDATE_INTERVAL=720h # Check for updates every 30 days # - REGION=andorra # Optional: specific region (continent, country, or planet) # - APPRISE_URLS=pover://user@token # Optional: notifications volumes: - photon_data:/photon/data restart: unless-stopped ports: - "2322:2322" volumes: photon_data:Build and run Photon locally
mainTo build the image locally using a specific Photon version, use the following command:
docker compose -f docker-compose.build.yml build --build-arg PHOTON_VERSION=1.2.0Enable Prometheus metrics
mainTo expose Prometheus metrics at the/metricsendpoint, set the environment variableENABLE_METRICS=TRUE. An example Grafana Dashboard is available at Grafana Labs.Understand the Photon-Docker startup lifecycle
mainWhen the container starts, the entrypoint follows a specific logic flow to ensure the index is ready:
- Configuration Validation: The container logs all active configuration variables and validates them using
validate_config(). - Index Reconciliation: The system calls
index.reconcile()to align the local state with requirements. - Forced Update Path: If
FORCE_UPDATEis enabled, the container immediately attempts a forced update or JSONL import, bypassing existing index checks. - Initial Setup Path:
- If no index is present and
INITIAL_DOWNLOADis enabled, it performs an initial download (always using theSEQUENTIALstrategy). - If no index is present but
INITIAL_DOWNLOADis disabled, the container logs a warning and stops.
- If no index is present and
- Existing Index Path:
- If an index exists and
IMPORT_MODEisjsonl, it skips automatic rebuilds. - If an index exists and
MIN_INDEX_DATEis set, it checks the index age viacheck_index_age(). If the index is too old, it performs aSEQUENTIALupdate.
- If an index exists and
Note on Strategies: While
UPDATE_STRATEGYcan be set toPARALLEL, the very first download of an index is always performed using theSEQUENTIALstrategy to ensure stability.- Configuration Validation: The container logs all active configuration variables and validates them using
Access the Photon API
mainOnce the container is running, you can access the forward search API via HTTP.
Example request:
http://localhost:2322/api?q=Hararehttp://localhost:2322/api?q=HarareConfigure photon-docker via environment variables
mainThe
photon-dockerapplication is configured primarily through environment variables. These variables control data import modes, update strategies, geographic regions, and networking parameters.Boolean values are parsed from strings like
true,1, ort(case-insensitive). For list-based configurations (likeLANGUAGESorEXTRA_TAGS), use a comma-separated string.Key Configuration Groups
Data Import & Updates
IMPORT_MODE: Mode for importing data (default:db).UPDATE_STRATEGY: Strategy for updates (default:SEQUENTIAL). Note: SettingFILE_URLautomatically sets this toDISABLED.UPDATE_INTERVAL: Frequency of updates using suffixes:d(days),h(hours), orm(minutes). Default is30d.FORCE_UPDATE: Force an update (default:False).INITIAL_DOWNLOAD: Whether to perform an initial download (default:True).IMPORT_GEOMETRIES: Whether to import geometries (default:False).REVERSE_ONLY: Whether to only process reverse geocoding (default:False).
Geographic & Language Scoping
REGION: Comma-separated list of regions (continents, countries, or planets) to process.LANGUAGES: Comma-separated list of languages to include.EXTRA_TAGS: Comma-separated list of additional tags to apply.
Networking & API
BASE_URL: The base URL for the service (default:https://r2.koalasec.org/public).PHOTON_LISTEN_IP: The IP address the Photon service listens on (default:0.0.0.0).PHOTON_PARAMS: Additional parameters passed to Photon.JAVA_PARAMS: Additional parameters passed to the Java runtime.APPRISE_URLS: URLs for Apprise notifications (e.g.,pover://user@token).
Reliability & Logging
DOWNLOAD_MAX_RETRIES: Max retries for downloads (default:3).CHECKSUM_MAX_RETRIES: Max retries for checksum verification (default:3).SKIP_MD5_CHECK: Skip MD5 verification (default:False).LOG_LEVEL: Logging verbosity (e.g.,INFO,DEBUG).ENABLE_METRICS: Enable metrics collection (default:False).
Configure REVERSE_ONLY for JSONL imports
mainTheREVERSE_ONLYoption is an import-time setting. It is only valid whenIMPORT_MODEis set tojsonl. Attempting to useREVERSE_ONLYwithIMPORT_MODE=dbwill result in a configuration error.