diff --git a/docker-compose-web.yml b/docker-compose-web.yml index eb1f0a0..0112e78 100644 --- a/docker-compose-web.yml +++ b/docker-compose-web.yml @@ -14,17 +14,18 @@ storage: db: # About the postgresql version, it should match in the dockerfile of docker-imposm3 - image: kartoza/postgis:9.4-2.1 - # image: kartoza/postgis:10.0-2.4 + image: kartoza/postgis:9.6-2.4 container_name: dockerosm_db hostname: db environment: - - USERNAME=docker - - PASS=docker + - POSTGRES_USER=docker + - POSTGRES_PASS=docker + - POSTGRES_DBNAME=gis volumes_from: - storage - ports: - - "5432:5432" +# Uncomment to use the postgis database from outside the docker network +# ports: +# - "5432:5432" imposm: build: docker-imposm3 @@ -34,11 +35,11 @@ imposm: links: - db:db environment: - - USER=docker - - PASSWORD=docker - - PORT=5432 - - HOST=db - - DATABASE=gis + - POSTGRES_USER=docker + - POSTGRES_PASS=docker + - POSTGRES_DBNAME=gis + - POSTGRES_PORT=5432 + - POSTGRES_HOST=db # seconds between 2 executions of the script # if 0, then no update will be done, only the first initial import from the PBF - TIME=120 diff --git a/docker-compose.yml b/docker-compose.yml index a077cd5..31b123f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,17 +14,18 @@ storage: db: # About the postgresql version, it should match in the dockerfile of docker-imposm3 - image: kartoza/postgis:9.4-2.1 - # image: kartoza/postgis:10.0-2.4 + image: kartoza/postgis:9.6-2.4 container_name: dockerosm_db hostname: db environment: - - USERNAME=docker - - PASS=docker + - POSTGRES_USER=docker + - POSTGRES_PASS=docker + - POSTGRES_DBNAME=gis volumes_from: - storage - ports: - - "5432:5432" +# Uncomment to use the postgis database from outside the docker network +# ports: +# - "5432:5432" imposm: build: docker-imposm3 @@ -34,11 +35,11 @@ imposm: links: - db:db environment: - - USER=docker - - PASSWORD=docker - - PORT=5432 - - HOST=db - - DATABASE=gis + - POSTGRES_USER=docker + - POSTGRES_PASS=docker + - POSTGRES_DBNAME=gis + - POSTGRES_PORT=5432 + - POSTGRES_HOST=db # seconds between 2 executions of the script # if 0, then no update will be done, only the first initial import from the PBF - TIME=120 diff --git a/docker-imposm3/importer.py b/docker-imposm3/importer.py index ab9c384..2d45ead 100644 --- a/docker-imposm3/importer.py +++ b/docker-imposm3/importer.py @@ -34,11 +34,11 @@ class Importer(object): # Default values which can be overwritten by environment variable. self.default = { 'TIME': 120, - 'USER': 'docker', - 'PASSWORD': 'docker', - 'DATABASE': 'gis', - 'HOST': 'db', - 'PORT': '5432', + 'POSTGRES_USER': 'docker', + 'POSTGRES_PASS': 'docker', + 'POSTGRES_DBNAME': 'gis', + 'POSTGRES_HOST': 'db', + 'POSTGRES_PORT': '5432', 'SETTINGS': 'settings', 'CACHE': 'cache', 'IMPORT_DONE': 'import_done', @@ -189,28 +189,28 @@ class Importer(object): try: connection = connect( "dbname='%s' user='%s' host='%s' password='%s'" % ( - self.default['DATABASE'], - self.default['USER'], - self.default['HOST'], - self.default['PASSWORD'])) + self.default['POSTGRES_DBNAME'], + self.default['POSTGRES_USER'], + self.default['POSTGRES_HOST'], + self.default['POSTGRES_PASS'])) self.cursor = connection.cursor() except OperationalError as e: print >> stderr, e exit() self.postgis_uri = 'postgis://%s:%s@%s/%s' % ( - self.default['USER'], - self.default['PASSWORD'], - self.default['HOST'], - self.default['DATABASE']) + self.default['POSTGRES_USER'], + self.default['POSTGRES_PASS'], + self.default['POSTGRES_HOST'], + self.default['POSTGRES_DBNAME']) def import_custom_sql(self): """Import the custom SQL file into the database.""" self.info('Running the post import SQL file.') command = ['psql'] - command += ['-h', self.default['HOST']] - command += ['-U', self.default['USER']] - command += ['-d', self.default['DATABASE']] + command += ['-h', self.default['POSTGRES_HOST']] + command += ['-U', self.default['POSTGRES_USER']] + command += ['-d', self.default['POSTGRES_DBNAME']] command += ['-f', self.post_import_file] call(command) @@ -218,9 +218,9 @@ class Importer(object): """Import the QGIS styles into the database.""" self.info('Installing QGIS styles.') command = ['psql'] - command += ['-h', self.default['HOST']] - command += ['-U', self.default['USER']] - command += ['-d', self.default['DATABASE']] + command += ['-h', self.default['POSTGRES_HOST']] + command += ['-U', self.default['POSTGRES_USER']] + command += ['-d', self.default['POSTGRES_DBNAME']] command += ['-f', self.qgis_style] call(command) @@ -231,9 +231,9 @@ class Importer(object): """ self.info('Import clip function.') command = ['psql'] - command += ['-h', self.default['HOST']] - command += ['-U', self.default['USER']] - command += ['-d', self.default['DATABASE']] + command += ['-h', self.default['POSTGRES_HOST']] + command += ['-U', self.default['POSTGRES_USER']] + command += ['-d', self.default['POSTGRES_DBNAME']] command += ['-f', self.clip_sql_file] call(command) self.info('!! Be sure to run \'make import_clip\' !!') @@ -243,9 +243,9 @@ class Importer(object): if self.count_table('clip') == 1: self.info('Clipping') command = ['psql'] - command += ['-h', self.default['HOST']] - command += ['-U', self.default['USER']] - command += ['-d', self.default['DATABASE']] + command += ['-h', self.default['POSTGRES_HOST']] + command += ['-U', self.default['POSTGRES_USER']] + command += ['-d', self.default['POSTGRES_DBNAME']] command += ['-c', 'SELECT clean_tables();'] call(command) diff --git a/readme.md b/readme.md index 3529e94..b9047ef 100644 --- a/readme.md +++ b/readme.md @@ -155,10 +155,10 @@ The container will look for an OSM file (*.pbf) and its state file With -e, you can add some settings : - TIME = 120, seconds between 2 executions of the script - - USER = docker, default user - - PASSWORD = docker, default password - - HOST = db - - PORT = 5432 + - POSTGRES_USER = docker, default user + - POSTGRES_PASS = docker, default password + - POSTGRES_HOST = db + - POSTGRES_PORT = 5432 - SETTINGS = settings, folder for settings (with *.json and *.sql) - CACHE = cache, folder for caching - BASE_PBF = base_pbf, folder the OSM file