Merge pull request #31 from geometalab/feature/osm2pgsql

Create osm2pgsql import container
pull/32/head^2
Lukas Martinelli 2015-10-09 14:22:09 +02:00
commit ec3ebb4f59
3 zmienionych plików z 94 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,52 @@
FROM debian:wheezy
MAINTAINER Lukas Martinelli <me@lukasmartinelli.ch>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
autoconf \
automake \
g++ \
git-core \
libboost-dev \
libboost-filesystem-dev \
libboost-system-dev \
libboost-thread-dev \
libbz2-dev \
libgeos++-dev \
libgeos-dev \
liblua5.2-dev \
libpq-dev \
libproj-dev \
libprotobuf-c0-dev \
libtool \
libxml2-dev \
lua5.2 \
make \
protobuf-c-compiler &&\
rm -rf /var/lib/apt/lists/*
ENV HOME /root
ENV OSM2PGSQL_VERSION 0.87.2
RUN mkdir src &&\
cd src &&\
git clone --depth 1 --branch $OSM2PGSQL_VERSION https://github.com/openstreetmap/osm2pgsql.git &&\
cd osm2pgsql &&\
./autogen.sh &&\
./configure &&\
make &&\
make install &&\
cd /root &&\
rm -rf src
COPY import.sh /usr/src/app/
WORKDIR /usr/src/app
VOLUME /data/import
ENV IMPORT_DATA_DIR=/data/import
VOLUME /data/cache
ENV CACHE_DIR=/data/cache
CMD ["./import.sh"]

Wyświetl plik

@ -0,0 +1,8 @@
## Import using different tool
```
docker run --rm --name osm2pgsql \
-v /data/import:/data/import \
--link postgis:db \
osm2vectortiles/osm2pgsql
```

Wyświetl plik

@ -0,0 +1,34 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# connection setup
OSM_HOST=$DB_PORT_5432_TCP_ADDR
OSM_DB=${OSM_DB:-osm}
OSM_USER=${OSM_USER:-osm}
OSM_PASSWORD=${OSM_PASSWORD:-osm}
# mounted data volume containing the pbfs
IMPORT_DATA_DIR=${IMPORT_DATA_DIR:-/data/import}
CACHE_DIR=${CACHE_DIR:-/data/cache}
# use all available cores for import
AVAILABLE_PROC=$(nproc)
PROC_NUM=${PROC_NUM:-$AVAILABLE_PROC}
# choose a big enough cache for the nodes
NODES_CACHE=${NODES_CACHE:-2000}
if [ "$(ls -A $IMPORT_DATA_DIR/*.pbf 2> /dev/null)" ]; then
for PBF_FILE in "$IMPORT_DATA_DIR"/*.pbf; do
PGPASSWORD=$OSM_PASSWORD osm2pgsql -d $OSM_DB -U $OSM_USER -H $OSM_HOST --create --slim --flat-nodes $CACHE_DIR/nodes.bin -C $NODES_CACHE --number-processes $PROC_NUM --hstore $PBF_FILE
echo "Successfully imported $PBF_FILE"
break
done
else
echo "No PBF files for import found."
echo "Please mount the $IMPORT_DATA_DIR volume to a folder containing OSM PBF files."
exit 404
fi