Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Ubuntu, PostgreSQL, Typos fixed #1

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
01c16b1
Updated to Ubuntu 14.04, PostgreSQL 9.3
helvalius Feb 10, 2015
9a4050a
fixed typo
helvalius Feb 10, 2015
a0d2bfe
Change port back to 8080
helvalius Feb 10, 2015
cf8dc34
configure postgres
helvalius Apr 30, 2015
8ae24f3
streamline maintainer and postgres with 2.4 branch
helvalius May 22, 2015
fe7ddb6
for now trust all postgres connections to this docker image due to co…
helvalius May 22, 2015
103abaf
Build failure: Expat XML Parser (closes #4)
pennersr Sep 15, 2015
542f9cc
Merge pull request #5 from pennersr/master
helvalius Sep 17, 2015
3539557
Fix private key file permission error after postgres install.
winsento Mar 8, 2016
0461def
Merge pull request #1 from winsento/fix-ssl-permission
winsento Mar 8, 2016
577cceb
Remove localhost.
winsento Mar 8, 2016
fd01795
Merge pull request #9 from winsento/master
helvalius Mar 11, 2016
7b588c1
Use cmake to compile the git sources
helvalius Apr 6, 2016
e9c5a9c
New Feature: Use --build-args to define URL to download OSM extract f…
helvalius Apr 6, 2016
e34d3ad
removed unnecessary ls/cat
helvalius Apr 20, 2016
757ab59
index.html not found fixed
mayankchutani Oct 3, 2016
18d765c
enabled reverse_geocoding
mayankchutani Oct 3, 2016
8f15097
Change SUDO to USER
chatelao Oct 31, 2016
5a6415b
Merge pull request #17 from mayank-chutani/index_html_fix
helvalius Dec 5, 2016
cf5f6b9
Merge pull request #19 from chatelao/master
helvalius Dec 5, 2016
7492772
Comment says monaco is default dataset, make it so
Dec 21, 2016
0ab65d0
Wait for Postgre to be ready, adjust website paths
Dec 21, 2016
99491fd
Merge pull request #20 from pmezard/pg-startup-and-other-fixes
helvalius Jan 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions 400-nominatim.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
Listen 8080
<VirtualHost *:8080>
ServerName localhost
ServerAdmin root@example.com
DocumentRoot /var/www/nominatim
DocumentRoot /var/www/nominatim/website
CustomLog /var/log/apache2/access.log combined
ErrorLog /var/log/apache2/error.log
LogLevel debug
<Directory /var/www/nominatim>
<Directory /var/www/nominatim/website>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Expand Down
94 changes: 60 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM ubuntu:12.04
FROM ubuntu:14.04
MAINTAINER Jan Nonnen <helvalius@gmail.com>
# Define the OSM argument, use monaco as default
ARG OSM=http://download.geofabrik.de/europe/monaco-latest.osm.pbf

RUN apt-get update

Expand All @@ -7,85 +10,108 @@ 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 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 lua5.2 liblua5.2-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

# 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
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 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 && git pull && git submodule update --init

WORKDIR /app/nominatim
RUN ./autogen.sh
RUN ./configure

RUN cmake /app/git/
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 && \
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"

RUN wget --output-document=/app/data.pbf http://download.geofabrik.de/north-america-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

WORKDIR /app/nominatim
RUN ./utils/setup.php --help

ADD local.php /app/nominatim/settings/local.php

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 ./utils/setup.php --help

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 ls settings/
RUN cat settings/local.php
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
# database are possible.
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

# 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/
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
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
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Nominatom Docker
# Nominatim 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
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

To rebuild the image locally execute
Expand All @@ -16,14 +16,21 @@ 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

```
# 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 8080:8080 --name nominatim_container --detach nominatim
```

Check the logs of the running container
Expand All @@ -32,6 +39,11 @@ Check the logs of the running container
docker logs nominatim_container
```

Stop the container
```
docker stop nominatim_container
```

Connect to the nominatim webserver with curl. If this succeeds, open [http://localhost:8080/](http:/localhost:8080) in a web browser

```
Expand Down
56 changes: 0 additions & 56 deletions config.sh

This file was deleted.

2 changes: 1 addition & 1 deletion configPostgresql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions configPostgresqlDiskWrites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,15 +18,15 @@ 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/" \
$CONFIG_FILE > $TEMP_FILE

# Make the change
mv $TEMP_FILE $CONFIG_FILE
fi
fi

echo "#\tReload postgres for the changes to come into effect"

Expand Down
1 change: 0 additions & 1 deletion httpd.conf

This file was deleted.

Loading