Use docker compose

pull/36/head
Lukas Martinelli 2015-10-15 14:10:32 +02:00
rodzic 40db208da6
commit 91b1768f56
5 zmienionych plików z 76 dodań i 11 usunięć

Wyświetl plik

@ -42,3 +42,20 @@ and it will serve a custom styled OSM map.
## Flow
![High level flow of the two containers](https://cloud.githubusercontent.com/assets/59284/9849871/2a7b56a0-5aef-11e5-8f79-b3fd673bd0e6.jpg)
## Development
We use Docker extensively for development and deployment.
Start up your PostGIS container with the data container attached.
```
docker-compose up -d postgis
```
Import PBF files from the local `import` directory.
The import container will automatically download a PBF of Zurich for testing.
```
docker-compose run imposm3
```

Wyświetl plik

@ -0,0 +1,6 @@
# Imposm 3 based Import Container
The import container reads `PBF` files containing OpenStreetMap data
and imports them into the linked PostGIS container.
https://github.com/omniscale/imposm3

Wyświetl plik

@ -8,6 +8,7 @@ readonly IMPOSM_CACHE_DIR=${IMPOSM_CACHE_DIR:-/data/cache}
readonly IMPOSM_BIN=${IMPOSM_BIN:-/imposm3}
readonly MAPPING_JSON=${MAPPING_JSON:-/usr/src/app/mapping.json}
readonly PBF_DOWNLOAD_URL=${PBF_DOWNLOAD_URL:-false}
readonly OSM_DB=${OSM_DB:-osm}
readonly OSM_USER=${OSM_USER:-osm}
@ -17,10 +18,15 @@ readonly DB_SCHEMA=${OSM_SCHEMA:-public}
readonly DB_HOST=$DB_PORT_5432_TCP_ADDR
readonly PG_CONNECT="postgis://$OSM_USER:$OSM_PASSWORD@$DB_HOST/$OSM_DB"
function download_pbf() {
local pbf_url=$1
wget --directory-prefix "$IMPORT_DATA_DIR" --no-clobber "$pbf_url"
}
function import_pbf() {
local pbf_file=$1
$IMPOSM_BIN import -connection $PG_CONNECT -mapping $MAPPING_JSON \
-overwritecache -cachedir=$IMPOSM_CACHE_DIR \
-appendcache -cachedir=$IMPOSM_CACHE_DIR \
-read $pbf_file \
-write -diff -dbschema-import=${DB_SCHEMA} -optimize
}
@ -33,13 +39,6 @@ function import_change() {
$changes_file
}
function check_persistent_cache_dir() {
if ! [ "$(ls -A $IMPOSM_CACHE_DIR)" ]; then
echo "To support importing OSM chage files you should mount the $IMPOSM_CACHE_DIR to a persistent folder."
exit 400
fi
}
function import_all_changes() {
if [ "$(ls -A $IMPORT_DATA_DIR/*osc.gz 2> /dev/null)" ]; then
echo "OSM change files found. Only changes are imported, initial import is skipped."
@ -68,7 +67,10 @@ function import_single_pbf() {
}
function main() {
check_persistent_cache_dir
if ! [ $PBF_DOWNLOAD_URL = false ]; then
download_pbf $PBF_DOWNLOAD_URL
fi
import_all_changes
import_single_pbf
}

Wyświetl plik

@ -10,7 +10,7 @@ readonly OSM_PASSWORD=${OSM_PASSWORD:-osm}
function create_osm_db() {
echo "Creating database $OSM_DB with owner $OSM_USER"
PGUSER="$POSTGRES_USER" psql --dbname="$POSTGRES_DB" <<-EOSQL
CREATE USER $OSM_DB WITH PASSWORD '$OSM_PASSWORD';
CREATE USER $OSM_USER WITH PASSWORD '$OSM_PASSWORD';
CREATE DATABASE $OSM_DB WITH TEMPLATE template_postgis OWNER $OSM_USER;
EOSQL
}
@ -19,4 +19,4 @@ function main() {
create_osm_db
}
main
main

40
docker-compose.yml 100644
Wyświetl plik

@ -0,0 +1,40 @@
pgdata:
image: "tianon/true"
volumes:
- /var/lib/postgresql/data
import_cache:
image: "tianon/true"
volumes:
- /data/import
postgis:
build: ./database/postgis
volumes_from:
- pgdata
environment:
OSM_DB: "osm_zurich"
OSM_USER: "osm"
OSM_PASSWORD: "suisse"
imposm3:
build: ./database/imposm3
volumes:
- ./import:/data/import
volumes_from:
- import_cache
links:
- postgis:db
environment:
OSM_DB: "osm_zurich"
OSM_USER: "osm"
OSM_PASSWORD: "suisse"
PBF_DOWNLOAD_URL: "https://s3.amazonaws.com/metro-extracts.mapzen.com/zurich_switzerland.osm.pbf"
# tilelive:
# build: ./database/tilelive
# volumes:
# - ./osm-bright-2.tm2source:/data/export
# links:
# - postgis
# environment:
# OSM_DB: "osm_zurich"
# OSM_USER: "osm"
# OSM_PASSWORD: "7G@VNDYa&Zp<726x"