From 01c16b18a493196bbea012d47d6ac8b535df2d88 Mon Sep 17 00:00:00 2001 From: Jan Nonnen Date: Tue, 10 Feb 2015 13:38:06 +0100 Subject: [PATCH 01/17] =?UTF-8?q?Updated=20to=20Ubuntu=2014.04,=20PostgreS?= =?UTF-8?q?QL=209.3=20Changed=20default=20Ports=20to=208072=20(was=208080)?= =?UTF-8?q?=20Modified=20to=20use=20Monacco=20instead=20of=20Andorra=20(co?= =?UTF-8?q?uld=20still=20be=20optimized=20by=20storing=20data=20in=20a=20v?= =?UTF-8?q?olume=20and=20not=20during=20docker=20image=20build)=20Removed?= =?UTF-8?q?=20unused=20scripts=20Add=20libboost=20f=C3=BCr=20osm2sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 400-nominatim.conf | 4 +- Dockerfile | 51 +++-- README.md | 23 ++- config.sh | 56 ------ configPostgresql.sh | 2 +- configPostgresqlDiskWrites.sh | 8 +- install.sh | 349 ---------------------------------- local.php | 8 +- 8 files changed, 56 insertions(+), 445 deletions(-) delete mode 100644 config.sh delete mode 100644 install.sh diff --git a/400-nominatim.conf b/400-nominatim.conf index 4aea773..58ebad0 100644 --- a/400-nominatim.conf +++ b/400-nominatim.conf @@ -1,5 +1,5 @@ -Listen 8080 - +Listen 8072 + ServerName localhost ServerAdmin root@example.com DocumentRoot /var/www/nominatim diff --git a/Dockerfile b/Dockerfile index 4e23331..4eeedbe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:12.04 +FROM ubuntu:14.04 RUN apt-get update @@ -7,39 +7,45 @@ RUN apt-get -y install wget # Note: libgeos++-dev is included here too (the nominatim install page suggests installing it if there is a problem with the 'pear install DB' below - it seems safe to install it anyway) -RUN apt-get -y install build-essential automake -RUN apt-get -y install libxml2-dev -RUN apt-get -y install libgeos-dev -RUN apt-get -y install libpq-dev -RUN apt-get install -y libbz2-dev -RUN apt-get install -y libtool libproj-dev -RUN apt-get install -y libgeos++-dev -RUN apt-get -y install gcc proj-bin libgeos-c1 git osmosis -RUN apt-get -y install php5 php-pear php5-pgsql php5-json +RUN apt-get -y install build-essential +RUN apt-get -y install gcc git osmosis +RUN apt-get -y install libxml2-dev libgeos-dev libpq-dev libbz2-dev libtool automake libproj-dev +RUN apt-get -y install proj-bin libgeos-c1 libgeos++-dev + +# Install Boost (required by osm2pqsql) +RUN apt-get -y install autoconf make g++ libboost-dev \ + libboost-system-dev libboost-filesystem-dev libboost-thread-dev + +# Install PHP5 +RUN apt-get -y install php5 php-pear php5-pgsql php5-json php-db + +# From the website "If you plan to install the source from github, the following additional packages are needed:" +# RUN apt-get -y install git autoconf-archive + +# Install Postgres, PostGIS and dependencies +RUN apt-get -y install postgresql postgis postgresql-contrib postgresql-9.3-postgis-2.1 postgresql-server-dev-9.3 + # Some additional packages that may not already be installed # bc is needed in configPostgresql.sh RUN apt-get -y install bc -# Install Postgres, PostGIS and dependencies -RUN apt-get -y install postgresql postgis postgresql-contrib postgresql-9.1-postgis postgresql-server-dev-9.1 # Install Apache RUN apt-get -y install apache2 -# Install gdal - which is apparently used for US data (more steps need to be added to this script to support that US data) -RUN apt-get -y install python-gdal - # Add Protobuf support RUN apt-get -y install libprotobuf-c0-dev protobuf-c-compiler RUN apt-get install -y sudo +# + RUN pear install DB RUN useradd -m -p password1234 nominatim RUN mkdir -p /app/nominatim RUN git clone --recursive https://github.com/twain47/Nominatim.git /app/nominatim -RUN cd /app/nominatim && git pull && git submodule update --init +RUN cd /app/nominatim WORKDIR /app/nominatim RUN ./autogen.sh RUN ./configure @@ -47,26 +53,31 @@ RUN make # Configure postgresql RUN service postgresql start && \ - pg_dropcluster --stop 9.1 main + pg_dropcluster --stop 9.3 main RUN service postgresql start && \ - pg_createcluster --start -e UTF-8 9.1 main + pg_createcluster --start -e UTF-8 9.3 main RUN service postgresql start && \ sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='nominatim'" | grep -q 1 || sudo -u postgres createuser -s nominatim && \ sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='www-data'" | grep -q 1 || sudo -u postgres createuser -SDR www-data && \ sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim" -RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/north-america-latest.osm.pbf +RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf +# RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/europe/luxembourg-latest.osm.pbf +# RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/north-america-latest.osm.pbf # RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/north-america/us/delaware-latest.osm.pbf WORKDIR /app/nominatim + +ADD local.php /app/nominatim/settings/local.php + + RUN ./utils/setup.php --help RUN service postgresql start && \ sudo -u nominatim ./utils/setup.php --osm-file /app/data.pbf --all --threads 2 -ADD local.php /app/nominatim/settings/local.php RUN mkdir -p /var/www/nominatim RUN ls settings/ diff --git a/README.md b/README.md index a1f941a..737dfc6 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # Nominatom Docker -Run [http://wiki.openstreetmap.org/wiki/Nominatim](http://wiki.openstreetmap.org/wiki/Nominatim) in a docker container. +Run [http://wiki.openstreetmap.org/wiki/Nominatim](http://wiki.openstreetmap.org/wiki/Nominatim) in a docker container. Clones the current master and builds it. This is always the latest version, be cautious as it may be unstable. -# Usage +Uses Ubuntu 14.04 and PostgreSQL 9.3 -``` -docker pull nisaacson/nominatim-docker -``` +# Country +It downloads Europe/Monacco (latest) from geofabrik.de. +If a different country should be used, change the wget line in the Dockerfile to pull a different country file. # Building To rebuild the image locally execute @@ -18,12 +18,12 @@ docker build -t nominatim . # Running -By default the container exposes port `8080` To run the container execute +By default the container exposes port `8072` To run the container execute ``` # remove any existing containers docker rm -f nominatim_container || echo "nominatim_container not found, skipping removal" -docker run -p 8080:8080 --name nominatim_container --detach nomintatim +docker run -p 8072:8072 --name nominatim_container --detach nominatim ``` Check the logs of the running container @@ -32,8 +32,13 @@ Check the logs of the running container docker logs nominatim_container ``` -Connect to the nominatim webserver with curl. If this succeeds, open [http://localhost:8080/](http:/localhost:8080) in a web browser +Stop the container +``` +docker stop nominatim_container +``` + +Connect to the nominatim webserver with curl. If this succeeds, open [http://localhost:8072/](http:/localhost:8072) in a web browser ``` -curl "http://localhost:8080" +curl "http://localhost:8072" ``` diff --git a/config.sh b/config.sh deleted file mode 100644 index 43d4857..0000000 --- a/config.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# Contains credentials -# This is a template file, save as simply .config.sh (amd make executable) and set your own values below. - -# Define the website hostname and e-mail for the VirtualHost -# Several option groups here, comment in / out as necessary -# Localhost -websiteurl=nominatim.localhost -emailcontact=nominatim@localhost -# CycleStreets -#websiteurl=nominatim.cyclestreets.net -#emailcontact=webmasterATcyclestreets.net - -# Define the username for Nominatim to install/run under, so that it can run independent of any individual personal account on the machine -username=nominatim -password= - -# Apache virtual host configuration file name - with .conf extension -nominatimVHfile=400-nominatim.conf - -### SETTINGS ### -# Define either a full planet, or an extract by commenting in the relevant sections - -## Full Planet -# On a machine with 1.2TB disk, 32 GB RAM, Quad processors - it took 10 days to run and used about 700GB. (December 2013) -#planetUrl=http://ftp5.gwdg.de/pub/misc/openstreetmap/planet.openstreetmap.org/pbf/ -#postgresconfigmode=dw -#override_maintenance_work_mem=16GB -# 18GB is recommended for full planet import (arg value is in MB) -#osm2pgsqlcache="--osm2pgsql-cache 18000" - - -## Geofabrik Extract -# If planetUrl is an empty string that tells the install script to configure for Geofabrik extract -planetUrl= -geofabrikUrl=http://download.geofabrik.de/ -postgresconfigmode=oltp -override_maintenance_work_mem= -# Default cache -osm2pgsqlcache= -# Define the location of the .pdf OSM data file -# Several option groups here, comment in / out as necessary -# Andorra (install, without wikipedia data, takes 12 minutes) -osmdatafolder=europe/ -osmdatacountry=andorra -## British Isles -#osmdatafolder=europe/ -#osmdatacountry=british-isles -## Iceland -#osmdatafolder=europe/ -#osmdatacountry=iceland -## Europe -# On a machine with 64GB ram and four processors takes 2.5 days to complete the initial install Oct 2012. -#osmdatafolder= -#osmdatacountry=europe - diff --git a/configPostgresql.sh b/configPostgresql.sh index a7479eb..1abb237 100644 --- a/configPostgresql.sh +++ b/configPostgresql.sh @@ -75,7 +75,7 @@ echo "#\tConfiguring as usage type: $1, Dedicated PostgreSQL server: ${dedicated ################################### # Postgres version -PGver=9.1 +PGver=9.3 # These variables are for Debian...be sure to alter them if your OS is different! PGHOMEDIR=/var/lib/postgresql diff --git a/configPostgresqlDiskWrites.sh b/configPostgresqlDiskWrites.sh index 145b6f9..98cff8e 100644 --- a/configPostgresqlDiskWrites.sh +++ b/configPostgresqlDiskWrites.sh @@ -3,9 +3,9 @@ # It changes the postgresql configuration to write changes to disk. # Need to sync these with configPostgresql.sh -PGver=9.1 +PGver=9.3 CONFIG_FILE=/etc/postgresql/$PGver/main/postgresql.conf -TEMP_FILE=${CONFIG_FILE}.TMP +TEMP_FILE=${CONFIG_FILE}.TMP # After the initial nominatim import these two variables need to be turned back on to avoid database corruption. FSYNC=on @@ -18,7 +18,7 @@ if [ -e $CONFIG_FILE ]; then echo "#\tApplying the following changes:" echo "#\tfsync $FSYNC" echo "#\tfull_page_writes $FULL_PAGE_WRITES" - + sed \ -e "s/[#]*fsync = .*/fsync = $FSYNC/" \ -e "s/[#]*full_page_writes = .*/full_page_writes = $FULL_PAGE_WRITES/" \ @@ -26,7 +26,7 @@ $CONFIG_FILE > $TEMP_FILE # Make the change mv $TEMP_FILE $CONFIG_FILE -fi +fi echo "#\tReload postgres for the changes to come into effect" diff --git a/install.sh b/install.sh deleted file mode 100644 index 289f7f5..0000000 --- a/install.sh +++ /dev/null @@ -1,349 +0,0 @@ -#!/bin/sh -# Script to install Nominatim on Ubuntu -# Tested on 12.04 (View Ubuntu version using 'lsb_release -a') using Postgres 9.1 -# http://wiki.openstreetmap.org/wiki/Nominatim/Installation#Ubuntu.2FDebian -# Synced with: Latest revision as of 18:41, 22 January 2014 - -# !! Marker #idempotent indicates limit of testing for idempotency - it has not yet been possible to make it fully idempotent. - -echo "#\tNominatim installation $(date)" - -# Ensure this script is run as root -if [ "$(id -u)" != "0" ]; then - echo "#\tThis script must be run as root." 1>&2 - exit 1 -fi - -# Bind current directory -nomInstalDir=$(pwd) - -# Bomb out if something goes wrong -set -e - -### CREDENTIALS ### -# Name of the credentials file -configFile=.config.sh - -# Generate your own credentials file by copying from .config.sh.template -if [ ! -e ./${configFile} ]; then - echo "#\tThe config file, ${configFile}, does not exist - copy your own based on the ${configFile}.template file." 1>&2 - exit 1 -fi - -# Load the credentials -. ./${configFile} - -# Check either planet or extract selected -if [ -z "${planetUrl}" -a -z "${geofabrikUrl}" ]; then - # Report and fail - echo "# Configuration error, please specify either a full planet or a Geofabrik extract" - exit 1 -fi - -# Check either planet or extract selected but not both -if [ -n "${planetUrl}" -a -n "${geofabrikUrl}" ]; then - # Report and fail - echo "# Configuration error, please specify either a full planet or a Geofabrik extract, not both" - echo "# Planet: ${planetUrl}" - echo "# Extract: ${geofabrikUrl}" - exit 1 -fi - -# Download -if [ -n "${planetUrl}" ]; then - - # Options for a full planet - osmdatafilename=planet-latest.osm.pbf - osmdatafolder=wholePlanet/ - osmdataurl=${planetUrl}${osmdatafilename} - -else - # Options for a Geofabrik Extract - osmdatafilename=${osmdatacountry}-latest.osm.pbf - osmdataurl=${geofabrikUrl}${osmdatafolder}${osmdatafilename} - osmupdates=${geofabrikUrl}${osmdatafolder}${osmdatacountry}-updates -fi - -# Where the downloaded data is stored -osmdatapath=data/${osmdatafolder}${osmdatafilename} - - -### MAIN PROGRAM ### - -# Logging -# Use an absolute path for the log file to be tolerant of the changing working directory in this script -setupLogFile=$(readlink -e $(dirname $0))/setupLog.txt -touch ${setupLogFile} -chmod a+w ${setupLogFile} -echo "#\tImport and index OSM data in progress, follow log file with:\n#\ttail -f ${setupLogFile}" -echo "#\tNominatim installation $(date)" >> ${setupLogFile} - -# Ensure there is a nominatim user account -if id -u ${username} >/dev/null 2>&1; then - echo "# User ${username} exists already and will be used." -else - echo "# User ${username} does not exist: creating now." - - # Request a password for the Nominatim user account; see http://stackoverflow.com/questions/3980668/how-to-get-a-password-from-a-shell-script-without-echoing - if [ ! ${password} ]; then - stty -echo - printf "Please enter a password that will be used to create the Nominatim user account:" - read password - printf "\n" - printf "Confirm that password:" - read passwordconfirm - printf "\n" - stty echo - if [ $password != $passwordconfirm ]; then - echo "#\tThe passwords did not match" - exit 1 - fi - fi - - # Create the nominatim user - useradd -m -p $password $username - echo "#\tNominatim user ${username} created" >> ${setupLogFile} -fi - -# Prepare the apt index; it may be practically non-existent on a fresh VM -apt-get update > /dev/null - -# Install basic software -apt-get -y install wget >> ${setupLogFile} - - -# Install software -echo "\n#\tInstalling software packages" >> ${setupLogFile} -# Note: libgeos++-dev is included here too (the nominatim install page suggests installing it if there is a problem with the 'pear install DB' below - it seems safe to install it anyway) -apt-get -y install build-essential libxml2-dev libgeos-dev libpq-dev libbz2-dev libtool automake libproj-dev libgeos++-dev >> ${setupLogFile} -apt-get -y install gcc proj-bin libgeos-c1 git osmosis >> ${setupLogFile} -apt-get -y install php5 php-pear php5-pgsql php5-json >> ${setupLogFile} - -# Some additional packages that may not already be installed -# bc is needed in configPostgresql.sh -apt-get -y install bc >> ${setupLogFile} - -# Install Postgres, PostGIS and dependencies -echo "\n#\tInstalling postgres and link to postgis" >> ${setupLogFile} -apt-get -y install postgresql postgis postgresql-contrib postgresql-9.1-postgis postgresql-server-dev-9.1 >> ${setupLogFile} - -# Install Apache -echo "\n#\tInstalling Apache" >> ${setupLogFile} -apt-get -y install apache2 >> ${setupLogFile} - -# Install gdal - which is apparently used for US data (more steps need to be added to this script to support that US data) -echo "\n#\tInstalling gdal" >> ${setupLogFile} -apt-get -y install python-gdal >> ${setupLogFile} - -# Add Protobuf support -echo "\n#\tInstalling protobuf" >> ${setupLogFile} -apt-get -y install libprotobuf-c0-dev protobuf-c-compiler >> ${setupLogFile} - -# Temporarily allow commands to fail without exiting the script -set +e - -# PHP Pear::DB is needed for the runtime website -# There doesn't seem an easy way to avoid this failing if it is already installed. -echo "\n#\tInstalling pear DB" >> ${setupLogFile} -pear install DB >> ${setupLogFile} - -# Bomb out if something goes wrong -set -e - -# Tuning PostgreSQL -echo "\n#\tTuning PostgreSQL" >> ${setupLogFile} -./configPostgresql.sh ${postgresconfigmode} n ${override_maintenance_work_mem} - -# Restart postgres assume the new config -echo "\n#\tRestarting PostgreSQL" >> ${setupLogFile} -/etc/init.d/postgresql restart - -# We will use the Nominatim user's homedir for the installation, so switch to that -eval cd /home/${username} - -# Get Nominatim software -if [ ! -d "/home/${username}/Nominatim/.git" ]; then - # Install - echo "\n#\tInstalling Nominatim software" >> ${setupLogFile} - sudo -u ${username} git clone --recursive https://github.com/twain47/Nominatim.git >> ${setupLogFile} - cd Nominatim -else - # Update - echo "\n#\tUpdating Nominatim software" >> ${setupLogFile} - cd Nominatim - sudo -u ${username} git pull >> ${setupLogFile} - # Some of the schema is created by osm2pgsql which is updated by: - sudo -u ${username} git submodule update --init >> ${setupLogFile} -fi - -# Compile Nominatim software -echo "\n#\tCompiling Nominatim software" >> ${setupLogFile} -sudo -u ${username} ./autogen.sh >> ${setupLogFile} -sudo -u ${username} ./configure >> ${setupLogFile} -sudo -u ${username} make >> ${setupLogFile} - - -# Get Wikipedia data which helps with name importance hinting -echo "\n#\tWikipedia data" >> ${setupLogFile} -# These large files are optional, and if present take a long time to process by ./utils/setup.php later in the script. -# Download them if they are not already present - the available ones date from early 2012. -if test ! -r data/wikipedia_article.sql.bin; then - sudo -u ${username} wget --output-document=data/wikipedia_article.sql.bin http://www.nominatim.org/data/wikipedia_article.sql.bin -fi -if test ! -r data/wikipedia_redirect.sql.bin; then - sudo -u ${username} wget --output-document=data/wikipedia_redirect.sql.bin http://www.nominatim.org/data/wikipedia_redirect.sql.bin -fi - -# http://stackoverflow.com/questions/8546759/how-to-check-if-a-postgres-user-exists -# Creating the importer account in Postgres -echo "\n#\tCreating the importer account" >> ${setupLogFile} -sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='${username}'" | grep -q 1 || sudo -u postgres createuser -s $username - -# Create website user in Postgres -echo "\n#\tCreating website user" >> ${setupLogFile} -websiteUser=www-data -sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='${websiteUser}'" | grep -q 1 || sudo -u postgres createuser -SDR ${websiteUser} - -# Nominatim module reading permissions -echo "\n#\tNominatim module reading permissions" >> ${setupLogFile} -chmod +x "/home/${username}" -chmod +x "/home/${username}/Nominatim" -chmod +x "/home/${username}/Nominatim/module" - -# Ensure download folder exists -sudo -u ${username} mkdir -p data/${osmdatafolder} - -# Download OSM data if not already present -if test ! -r ${osmdatapath}; then - echo "\n#\tDownload OSM data" >> ${setupLogFile} - sudo -u ${username} wget --output-document=${osmdatapath}.md5 ${osmdataurl}.md5 - sudo -u ${username} wget --output-document=${osmdatapath} ${osmdataurl} -fi - -# Check the md5 matches -if [ "$(md5sum ${osmdatapath} | awk '{print $1;}')" != "$(cat ${osmdatapath}.md5 | awk '{print $1;}')" ]; then - echo "#\tThe md5 checksum for osmdatapath: ${osmdatapath} does not match, stopping." - exit 1 - echo "\n#\tDownloaded OSM data integrity verified by md5 check." >> ${setupLogFile} -fi - - -#idempotent -# Cannot make idempotent safely from here because that would require editing nominatim's setup scripts. -# Remove any pre-existing nominatim database -echo "\n#\tRemove any pre-existing nominatim database" >> ${setupLogFile} -sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim" - -# Add local Nominatim settings -localNominatimSettings=/home/${username}/Nominatim/settings/local.php - -cat > ${localNominatimSettings} << EOF -> ${localNominatimSettings} << EOF - // Setting up the update process - @define('CONST_Replication_Url', '${osmupdates}'); - @define('CONST_Replication_MaxInterval', '86400'); // Process each update separately, osmosis cannot merge multiple updates - @define('CONST_Replication_Update_Interval', '86400'); // How often upstream publishes diffs - @define('CONST_Replication_Recheck_Interval', '900'); // How long to sleep if no update found yet -EOF -fi - -# Change settings file to Nominatim ownership -chown ${username}:${username} ${localNominatimSettings} - -# Import and index main OSM data -eval cd /home/${username}/Nominatim/ -echo "#\tStarting import and index OSM data $(date)" >> ${setupLogFile} -# Experimentally trying with two threads here -sudo -u ${username} ./utils/setup.php ${osm2pgsqlcache} --osm-file /home/${username}/Nominatim/${osmdatapath} --all --threads 2 >> ${setupLogFile} -# Note: if that step gets interrupted for some reason it can be resumed using: -# (Threads argument is optional, it'll default to one less than number of available cpus.) -# If the reported rank is 26 or higher, you can also safely add --index-noanalyse. -# sudo -u ${username} ./utils/setup.php --index --index-noanalyse --create-search-indices --threads 2 -echo "#\tDone Import and index OSM data $(date)" >> ${setupLogFile} - -# Add special phrases -echo "#\tStarting special phrases $(date)" >> ${setupLogFile} -sudo -u ${username} ./utils/specialphrases.php --countries > specialphrases_countries.sql >> ${setupLogFile} -sudo -u ${username} psql -d nominatim -f specialphrases_countries.sql >> ${setupLogFile} -sudo -u ${username} rm -f specialphrases_countries.sql -sudo -u ${username} ./utils/specialphrases.php --wiki-import > specialphrases.sql >> ${setupLogFile} -sudo -u ${username} psql -d nominatim -f specialphrases.sql >> ${setupLogFile} -sudo -u ${username} rm -f specialphrases.sql -echo "#\tDone special phrases $(date)" >> ${setupLogFile} - -# Set up the website for use with Apache -wwwNominatim=/var/www/nominatim -sudo mkdir -pm 755 ${wwwNominatim} -sudo chown ${username} ${wwwNominatim} -sudo -u ${username} ./utils/setup.php --create-website ${wwwNominatim} - -# Write out a robots file to keep search engines out -sudo -u ${username} cat > ${wwwNominatim}/robots.txt <> ${setupLogFile} -cat > /etc/apache2/sites-available/${nominatimVHfile} << EOF - - ServerName ${websiteurl} - ServerAdmin ${emailcontact} - DocumentRoot ${wwwNominatim} - CustomLog \${APACHE_LOG_DIR}/access.log combined - ErrorLog \${APACHE_LOG_DIR}/error.log - LogLevel warn - - Options FollowSymLinks MultiViews - AllowOverride None - Order allow,deny - Allow from all - - AddType text/html .php - -EOF - -# Enable the VirtualHost and restart Apache -a2ensite ${nominatimVHfile} -/etc/init.d/apache2 reload - -echo "#\tNominatim website created $(date)" >> ${setupLogFile} - -# Setting up the update process -rm -f /home/${username}/Nominatim/settings/configuration.txt -sudo -u ${username} ./utils/setup.php --osmosis-init -echo "#\tDone setup $(date)" >> ${setupLogFile} - -# Enabling hierarchical updates -sudo -u ${username} ./utils/setup.php --create-functions --enable-diff-updates -echo "#\tDone enable hierarchical updates $(date)" >> ${setupLogFile} - -# Adust PostgreSQL to do disk writes -echo "\n#\tRetuning PostgreSQL for disk writes" >> ${setupLogFile} -${nomInstalDir}/configPostgresqlDiskWrites.sh - -# Reload postgres assume the new config -echo "\n#\tReloading PostgreSQL" >> ${setupLogFile} -/etc/init.d/postgresql reload - -# Updating Nominatim -# Using two threads for the upadate will help performance, by adding this option: --index-instances 2 -# Going much beyond two threads is not really worth it because the threads interfere with each other quite a bit. -# If your system is live and serving queries, keep an eye on response times at busy times, because too many update threads might interfere there, too. -sudo -u ${username} ./utils/update.php --import-osmosis-all --no-npi - -# Done -echo "#\tNominatim installation completed $(date)" >> ${setupLogFile} - -# End of file diff --git a/local.php b/local.php index a8d8653..b587c92 100644 --- a/local.php +++ b/local.php @@ -1,11 +1,11 @@ - From 9a4050aff40f321fb9e1958234109f57b833dbdc Mon Sep 17 00:00:00 2001 From: Jan Nonnen Date: Tue, 10 Feb 2015 13:41:26 +0100 Subject: [PATCH 02/17] fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 737dfc6..ebc0cdc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Nominatom Docker +# Nominatim Docker Run [http://wiki.openstreetmap.org/wiki/Nominatim](http://wiki.openstreetmap.org/wiki/Nominatim) in a docker container. Clones the current master and builds it. This is always the latest version, be cautious as it may be unstable. From a0d2bfed1fb0131f96e682297777219e69a114de Mon Sep 17 00:00:00 2001 From: Jan Nonnen Date: Tue, 10 Feb 2015 13:58:51 +0100 Subject: [PATCH 03/17] Change port back to 8080 --- 400-nominatim.conf | 4 ++-- README.md | 8 ++++---- local.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/400-nominatim.conf b/400-nominatim.conf index 58ebad0..4aea773 100644 --- a/400-nominatim.conf +++ b/400-nominatim.conf @@ -1,5 +1,5 @@ -Listen 8072 - +Listen 8080 + ServerName localhost ServerAdmin root@example.com DocumentRoot /var/www/nominatim diff --git a/README.md b/README.md index ebc0cdc..901bf58 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,12 @@ docker build -t nominatim . # Running -By default the container exposes port `8072` To run the container execute +By default the container exposes port `8080` To run the container execute ``` # remove any existing containers docker rm -f nominatim_container || echo "nominatim_container not found, skipping removal" -docker run -p 8072:8072 --name nominatim_container --detach nominatim +docker run -p 8080:8080 --name nominatim_container --detach nominatim ``` Check the logs of the running container @@ -37,8 +37,8 @@ Stop the container docker stop nominatim_container ``` -Connect to the nominatim webserver with curl. If this succeeds, open [http://localhost:8072/](http:/localhost:8072) in a web browser +Connect to the nominatim webserver with curl. If this succeeds, open [http://localhost:8080/](http:/localhost:8080) in a web browser ``` -curl "http://localhost:8072" +curl "http://localhost:8080" ``` diff --git a/local.php b/local.php index b587c92..02c2006 100644 --- a/local.php +++ b/local.php @@ -3,7 +3,7 @@ @define('CONST_Postgresql_Version', '9.3'); @define('CONST_Postgis_Version', '2.1'); // Website settings - @define('CONST_Website_BaseURL', 'http://localhost:8072/'); + @define('CONST_Website_BaseURL', 'http://localhost:8080/'); @define('CONST_Replication_Url', 'http://download.geofabrik.de/europe-updates'); @define('CONST_Replication_MaxInterval', '86400'); // Process each update separately, osmosis cannot merge multiple updates @define('CONST_Replication_Update_Interval', '86400'); // How often upstream publishes diffs From cf8dc34fd10ae0817478fb9ca8b20e2d61a6d2ce Mon Sep 17 00:00:00 2001 From: Jan Nonnen Date: Thu, 30 Apr 2015 14:38:01 +0200 Subject: [PATCH 04/17] configure postgres --- Dockerfile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4eeedbe..d8954e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM ubuntu:14.04 +MAINTAINER jan.nonnen@gmail.com RUN apt-get update @@ -60,7 +61,8 @@ RUN service postgresql start && \ RUN service postgresql start && \ sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='nominatim'" | grep -q 1 || sudo -u postgres createuser -s nominatim && \ sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='www-data'" | grep -q 1 || sudo -u postgres createuser -SDR www-data && \ - sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim" + sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim" && \ + sudo -u postgres psql -c "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf # RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/europe/luxembourg-latest.osm.pbf @@ -84,6 +86,18 @@ RUN ls settings/ RUN cat settings/local.php RUN ./utils/setup.php --create-website /var/www/nominatim + + +# Adjust PostgreSQL configuration so that remote connections to the +# database are possible. +RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf + +# And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf`` +RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf + +# Expose the PostgreSQL port +EXPOSE 5432 + RUN apt-get install -y curl ADD 400-nominatim.conf /etc/apache2/sites-available/400-nominatim.conf ADD httpd.conf /etc/apache2/ @@ -91,9 +105,10 @@ RUN service apache2 start && \ a2ensite 400-nominatim.conf && \ /etc/init.d/apache2 reload - +# Expose the HTTP port EXPOSE 8080 + ADD configPostgresql.sh /app/nominatim/configPostgresql.sh WORKDIR /app/nominatim RUN chmod +x ./configPostgresql.sh From 8ae24f3c08e5debccbbaa9d503fe762c5a9eb5af Mon Sep 17 00:00:00 2001 From: Jan Nonnen Date: Fri, 22 May 2015 15:08:39 +0200 Subject: [PATCH 05/17] streamline maintainer and postgres with 2.4 branch --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d8954e6..9750baa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM ubuntu:14.04 -MAINTAINER jan.nonnen@gmail.com +MAINTAINER Jan Nonnen RUN apt-get update @@ -61,8 +61,7 @@ RUN service postgresql start && \ RUN service postgresql start && \ sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='nominatim'" | grep -q 1 || sudo -u postgres createuser -s nominatim && \ sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='www-data'" | grep -q 1 || sudo -u postgres createuser -SDR www-data && \ - sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim" && \ - sudo -u postgres psql -c "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" + sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim" RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf # RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/europe/luxembourg-latest.osm.pbf From fe7ddb64410b9751c1919ff115d35571b2c0aa27 Mon Sep 17 00:00:00 2001 From: Jan Nonnen Date: Fri, 22 May 2015 15:06:28 +0200 Subject: [PATCH 06/17] for now trust all postgres connections to this docker image due to connection issues with photon while using md5/password --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9750baa..bf776cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -89,7 +89,7 @@ RUN ./utils/setup.php --create-website /var/www/nominatim # Adjust PostgreSQL configuration so that remote connections to the # database are possible. -RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf +RUN echo "host all all 0.0.0.0/0 trust" >> /etc/postgresql/9.3/main/pg_hba.conf # And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf`` RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf From 103abaf59840fb31b3d8e0022964352e38d1d625 Mon Sep 17 00:00:00 2001 From: Raymond Penners Date: Tue, 15 Sep 2015 16:38:03 +0200 Subject: [PATCH 07/17] Build failure: Expat XML Parser (closes #4) --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index bf776cd..4f8c42e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ RUN apt-get -y install build-essential RUN apt-get -y install gcc git osmosis RUN apt-get -y install libxml2-dev libgeos-dev libpq-dev libbz2-dev libtool automake libproj-dev RUN apt-get -y install proj-bin libgeos-c1 libgeos++-dev +RUN apt-get -y install libexpat1-dev # Install Boost (required by osm2pqsql) RUN apt-get -y install autoconf make g++ libboost-dev \ From 35395577b0ad56ebbd3561d816a662388d745476 Mon Sep 17 00:00:00 2001 From: winsent Date: Tue, 8 Mar 2016 14:23:54 +0300 Subject: [PATCH 08/17] Fix private key file permission error after postgres install. --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4f8c42e..35d80f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,8 @@ RUN apt-get -y install php5 php-pear php5-pgsql php5-json php-db # Install Postgres, PostGIS and dependencies RUN apt-get -y install postgresql postgis postgresql-contrib postgresql-9.3-postgis-2.1 postgresql-server-dev-9.3 +# Work around for AUFS bug as per https://github.com/docker/docker/issues/783#issuecomment-56013588 +RUN mkdir /etc/ssl/private-copy; mv /etc/ssl/private/* /etc/ssl/private-copy/; rm -r /etc/ssl/private; mv /etc/ssl/private-copy /etc/ssl/private; chmod -R 0700 /etc/ssl/private; chown -R postgres /etc/ssl/private # Some additional packages that may not already be installed # bc is needed in configPostgresql.sh From 577cceb258977f9c9eb1b2f1130a6e935beb8434 Mon Sep 17 00:00:00 2001 From: winsent Date: Tue, 8 Mar 2016 16:23:48 -0500 Subject: [PATCH 09/17] Remove localhost. --- 400-nominatim.conf | 2 -- Dockerfile | 1 - httpd.conf | 1 - local.php | 2 +- 4 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 httpd.conf diff --git a/400-nominatim.conf b/400-nominatim.conf index 4aea773..7dfadb8 100644 --- a/400-nominatim.conf +++ b/400-nominatim.conf @@ -1,7 +1,5 @@ Listen 8080 - ServerName localhost - ServerAdmin root@example.com DocumentRoot /var/www/nominatim CustomLog /var/log/apache2/access.log combined ErrorLog /var/log/apache2/error.log diff --git a/Dockerfile b/Dockerfile index 35d80f5..bf13a51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -102,7 +102,6 @@ EXPOSE 5432 RUN apt-get install -y curl ADD 400-nominatim.conf /etc/apache2/sites-available/400-nominatim.conf -ADD httpd.conf /etc/apache2/ RUN service apache2 start && \ a2ensite 400-nominatim.conf && \ /etc/init.d/apache2 reload diff --git a/httpd.conf b/httpd.conf deleted file mode 100644 index 873caeb..0000000 --- a/httpd.conf +++ /dev/null @@ -1 +0,0 @@ -ServerName localhost diff --git a/local.php b/local.php index 02c2006..07d0121 100644 --- a/local.php +++ b/local.php @@ -3,7 +3,7 @@ @define('CONST_Postgresql_Version', '9.3'); @define('CONST_Postgis_Version', '2.1'); // Website settings - @define('CONST_Website_BaseURL', 'http://localhost:8080/'); + @define('CONST_Website_BaseURL', '/'); @define('CONST_Replication_Url', 'http://download.geofabrik.de/europe-updates'); @define('CONST_Replication_MaxInterval', '86400'); // Process each update separately, osmosis cannot merge multiple updates @define('CONST_Replication_Update_Interval', '86400'); // How often upstream publishes diffs From 7b588c1ff985df2c5b9564e2f5546fe7ab086fae Mon Sep 17 00:00:00 2001 From: Jan Nonnen Date: Wed, 6 Apr 2016 15:07:55 +0200 Subject: [PATCH 10/17] Use cmake to compile the git sources Cleanup RUN commands as we need other imports for cmake anyway. The compiled code is now under /app/nominatim, the git repository cloned to /app/git This closes #12 --- Dockerfile | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index bf13a51..62cd3cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,15 +8,10 @@ RUN apt-get -y install wget # Note: libgeos++-dev is included here too (the nominatim install page suggests installing it if there is a problem with the 'pear install DB' below - it seems safe to install it anyway) -RUN apt-get -y install build-essential -RUN apt-get -y install gcc git osmosis -RUN apt-get -y install libxml2-dev libgeos-dev libpq-dev libbz2-dev libtool automake libproj-dev -RUN apt-get -y install proj-bin libgeos-c1 libgeos++-dev -RUN apt-get -y install libexpat1-dev +RUN apt-get -y install build-essential gcc git osmosis libxml2-dev libgeos-dev libpq-dev libbz2-dev libtool cmake libproj-dev proj-bin libgeos-c1 libgeos++-dev libexpat1-dev # Install Boost (required by osm2pqsql) -RUN apt-get -y install autoconf make g++ libboost-dev \ - libboost-system-dev libboost-filesystem-dev libboost-thread-dev +RUN apt-get -y install autoconf make g++ libboost-dev libboost-system-dev libboost-filesystem-dev libboost-thread-dev lua5.2 liblua5.2-dev # Install PHP5 RUN apt-get -y install php5 php-pear php5-pgsql php5-json php-db @@ -34,25 +29,25 @@ RUN mkdir /etc/ssl/private-copy; mv /etc/ssl/private/* /etc/ssl/private-copy/; r # bc is needed in configPostgresql.sh RUN apt-get -y install bc - # Install Apache RUN apt-get -y install apache2 # Add Protobuf support RUN apt-get -y install libprotobuf-c0-dev protobuf-c-compiler -RUN apt-get install -y sudo +RUN apt-get -y install sudo # RUN pear install DB RUN useradd -m -p password1234 nominatim +RUN mkdir -p /app/git/ +RUN git clone --recursive https://github.com/twain47/Nominatim.git /app/git/ RUN mkdir -p /app/nominatim -RUN git clone --recursive https://github.com/twain47/Nominatim.git /app/nominatim -RUN cd /app/nominatim + WORKDIR /app/nominatim -RUN ./autogen.sh -RUN ./configure + +RUN cmake /app/git/ RUN make # Configure postgresql From e9c5a9c1f3ed1e77640fe0e4b96f07d412ccdf08 Mon Sep 17 00:00:00 2001 From: Jan Nonnen Date: Wed, 6 Apr 2016 18:33:08 +0200 Subject: [PATCH 11/17] New Feature: Use --build-args to define URL to download OSM extract from during build time --- Dockerfile | 8 ++++++-- README.md | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 62cd3cf..7c07251 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM ubuntu:14.04 MAINTAINER Jan Nonnen +# Define the OSM argument, use monaco as default +ARG OSM=http://download.geofabrik.de/europe/monaco-latest.osm.pbf RUN apt-get update @@ -47,7 +49,7 @@ RUN mkdir -p /app/nominatim WORKDIR /app/nominatim -RUN cmake /app/git/ +RUN cmake /app/git/ RUN make # Configure postgresql @@ -61,7 +63,7 @@ RUN service postgresql start && \ sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='www-data'" | grep -q 1 || sudo -u postgres createuser -SDR www-data && \ sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim" -RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf +RUN wget --output-document=/app/data.pbf $OSM # RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/europe/luxembourg-latest.osm.pbf # RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/north-america-latest.osm.pbf # RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/north-america/us/delaware-latest.osm.pbf @@ -110,4 +112,6 @@ WORKDIR /app/nominatim RUN chmod +x ./configPostgresql.sh ADD start.sh /app/nominatim/start.sh RUN chmod +x /app/nominatim/start.sh + +RUN echo "Using OSM URL: "$OSM CMD /app/nominatim/start.sh diff --git a/README.md b/README.md index 901bf58..de14bff 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Run [http://wiki.openstreetmap.org/wiki/Nominatim](http://wiki.openstreetmap.org Uses Ubuntu 14.04 and PostgreSQL 9.3 # Country -It downloads Europe/Monacco (latest) from geofabrik.de. +As default it downloads Europe/Monacco (latest) from geofabrik.de during build. This can be changed by setting a build arg. If a different country should be used, change the wget line in the Dockerfile to pull a different country file. # Building @@ -16,6 +16,13 @@ To rebuild the image locally execute docker build -t nominatim . ``` +# Changing the OSM url to download and use a different country + +This example downloads the belize data during compilation: +``` +docker build --build-arg OSM=http://download.geofabrik.de/central-america/belize-latest.osm.pbf -t nominatim . +``` + # Running By default the container exposes port `8080` To run the container execute From e34d3ad1485755f866684c18b36a8667d61a6b62 Mon Sep 17 00:00:00 2001 From: Jan Nonnen Date: Wed, 20 Apr 2016 10:21:08 +0200 Subject: [PATCH 12/17] removed unnecessary ls/cat --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7c07251..4323dbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -81,8 +81,6 @@ RUN service postgresql start && \ RUN mkdir -p /var/www/nominatim -RUN ls settings/ -RUN cat settings/local.php RUN ./utils/setup.php --create-website /var/www/nominatim From 757ab5963d9a6d29afe2a2431ad65264f2f3fafd Mon Sep 17 00:00:00 2001 From: Mayank Date: Mon, 3 Oct 2016 08:49:57 +0000 Subject: [PATCH 13/17] index.html not found fixed --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4323dbc..7c54441 100644 --- a/Dockerfile +++ b/Dockerfile @@ -112,4 +112,6 @@ ADD start.sh /app/nominatim/start.sh RUN chmod +x /app/nominatim/start.sh RUN echo "Using OSM URL: "$OSM + +RUN ln -s /app/nominatim/website/search.php /var/www/nominatim/index.php CMD /app/nominatim/start.sh From 18d765c9594ae827a002d5301956c97c3adf93d6 Mon Sep 17 00:00:00 2001 From: Mayank Date: Mon, 3 Oct 2016 09:17:44 +0000 Subject: [PATCH 14/17] enabled reverse_geocoding --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7c54441..f42a788 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:14.04 MAINTAINER Jan Nonnen # Define the OSM argument, use monaco as default -ARG OSM=http://download.geofabrik.de/europe/monaco-latest.osm.pbf +ARG OSM=http://download.geofabrik.de/europe-latest.osm.pbf RUN apt-get update @@ -113,5 +113,7 @@ RUN chmod +x /app/nominatim/start.sh RUN echo "Using OSM URL: "$OSM -RUN ln -s /app/nominatim/website/search.php /var/www/nominatim/index.php +RUN ln -s /app/nominatim/website/search.php /var/www/nominatim/search.php +RUN ln -s /app/nominatim/website/reverse.php /var/www/nominatim/reverse.php + CMD /app/nominatim/start.sh From 8f15097db4e3269c16c4e4b0fa02678f0f988c14 Mon Sep 17 00:00:00 2001 From: chatelao Date: Mon, 31 Oct 2016 11:04:14 +0100 Subject: [PATCH 15/17] Change SUDO to USER --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4323dbc..091f326 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,9 +76,11 @@ ADD local.php /app/nominatim/settings/local.php RUN ./utils/setup.php --help -RUN service postgresql start && \ - sudo -u nominatim ./utils/setup.php --osm-file /app/data.pbf --all --threads 2 +RUN service postgresql start +USER nominatim +WORKDIR /app/nominatim +RUN ./utils/setup.php --osm-file /app/data.pbf --all --threads 2 RUN mkdir -p /var/www/nominatim RUN ./utils/setup.php --create-website /var/www/nominatim From 7492772318ae13d4002cfbb59e5d202af8fb2fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=A9zard?= Date: Wed, 21 Dec 2016 14:42:31 +0100 Subject: [PATCH 16/17] Comment says monaco is default dataset, make it so --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index acf569d..63e352d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:14.04 MAINTAINER Jan Nonnen # Define the OSM argument, use monaco as default -ARG OSM=http://download.geofabrik.de/europe-latest.osm.pbf +ARG OSM=http://download.geofabrik.de/europe/monaco-latest.osm.pbf RUN apt-get update From 0ab65d022823bfd56eb9e95291c5376bc254629a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=A9zard?= Date: Wed, 21 Dec 2016 14:43:12 +0100 Subject: [PATCH 17/17] Wait for Postgre to be ready, adjust website paths Sorry for the combined commit but it is hard to disentangle broken things: - Nominatim update changed the way the website is generate. The setup.php command was superseded by the build. To simplify paths handling settings/ and website/ are copied in /var/www/nominatim and apache root directory is set to website/ - "services start postgresql" returns before the database is ready, making following commands to fail. Use "pg_ctl start -w" instead. Probably fixed #15. --- 400-nominatim.conf | 4 ++-- Dockerfile | 20 ++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/400-nominatim.conf b/400-nominatim.conf index 7dfadb8..bbaaf11 100644 --- a/400-nominatim.conf +++ b/400-nominatim.conf @@ -1,10 +1,10 @@ Listen 8080 - DocumentRoot /var/www/nominatim + DocumentRoot /var/www/nominatim/website CustomLog /var/log/apache2/access.log combined ErrorLog /var/log/apache2/error.log LogLevel debug - + Options FollowSymLinks MultiViews AllowOverride None Order allow,deny diff --git a/Dockerfile b/Dockerfile index 63e352d..aae44c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -58,7 +58,8 @@ RUN service postgresql start && \ RUN service postgresql start && \ pg_createcluster --start -e UTF-8 9.3 main -RUN service postgresql start && \ +RUN sudo -u postgres /usr/lib/postgresql/9.3/bin/pg_ctl start -w -D /etc/postgresql/9.3/main/ && \ + cat /var/log/postgresql/postgresql-9.3-main.log && \ sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='nominatim'" | grep -q 1 || sudo -u postgres createuser -s nominatim && \ sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='www-data'" | grep -q 1 || sudo -u postgres createuser -SDR www-data && \ sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim" @@ -75,16 +76,14 @@ ADD local.php /app/nominatim/settings/local.php RUN ./utils/setup.php --help - -RUN service postgresql start - -USER nominatim -WORKDIR /app/nominatim -RUN ./utils/setup.php --osm-file /app/data.pbf --all --threads 2 +RUN chown -R nominatim:nominatim /app/nominatim +RUN sudo -u postgres /usr/lib/postgresql/9.3/bin/pg_ctl start -w -D /etc/postgresql/9.3/main/ && \ + sudo -u nominatim ./utils/setup.php --osm-file /app/data.pbf --all --threads 2 RUN mkdir -p /var/www/nominatim -RUN ./utils/setup.php --create-website /var/www/nominatim - +RUN cp -R /app/nominatim/website /var/www/nominatim/ +RUN cp -R /app/nominatim/settings /var/www/nominatim/ +RUN chown -R nominatim:www-data /var/www/nominatim # Adjust PostgreSQL configuration so that remote connections to the @@ -115,7 +114,4 @@ RUN chmod +x /app/nominatim/start.sh RUN echo "Using OSM URL: "$OSM -RUN ln -s /app/nominatim/website/search.php /var/www/nominatim/search.php -RUN ln -s /app/nominatim/website/reverse.php /var/www/nominatim/reverse.php - CMD /app/nominatim/start.sh