Use osm2pgsql.sh to import osm data into the database with the portal image
- Added POSTGRES env-vars to the portal (only handled by osm2pgsql.sh until now) - Added ./data/pbf:/pbf as host volume mount to the portal - Added osm2pgsql.sh, which ueses the env-vars and pbf-mount to import the osm data into the database
This commit is contained in:
parent
e5e5bc11ca
commit
429df474a0
|
@ -91,7 +91,8 @@ ADD api/obs /opt/obs/api/obs/
|
|||
ADD api/tools /opt/obs/api/tools/
|
||||
RUN pip install -e /opt/obs/api/
|
||||
|
||||
ADD roads_import.lua /opt/obs/api/roads_import.lua
|
||||
ADD roads_import.lua /opt/obs/api/tools
|
||||
ADD osm2pgsql.sh /opt/obs/api/tools
|
||||
|
||||
COPY --from=frontend-builder /opt/obs/frontend/build /opt/obs/frontend/build
|
||||
COPY --from=osm2pgsql-builder /usr/local/bin/osm2pgsql /usr/local/bin/osm2pgsql
|
||||
|
|
|
@ -78,22 +78,30 @@ sure to configure:
|
|||
|
||||
### Prepare database
|
||||
|
||||
Follow the procedure outlined in [README.md](../README.md) under "Prepare
|
||||
database". Whenever the docker-compose service `api` is referenced, replace it
|
||||
with `portal`, which contains the same python code as the development `api`
|
||||
service, but also the frontend. For example:
|
||||
Run the following two scripts to prepare the database:
|
||||
|
||||
```bash
|
||||
# development
|
||||
docker-compose run --rm api tools/prepare_sql_tiles.py
|
||||
# production
|
||||
docker-compose run --rm portal tools/reset_database.py
|
||||
docker-compose run --rm portal tools/prepare_sql_tiles.py
|
||||
```
|
||||
|
||||
For more details, see [README.md](../README.md) under "Prepare database".
|
||||
|
||||
### Import OpenStreetMap data
|
||||
|
||||
Follow the procedure outlined in [README.md](../README.md) under "Import OpenStreetMap data".
|
||||
First of all, download the area(s) you would like to import from [GeoFabrik](https://download.geofabrik.de) into `data/pbf`, for example:
|
||||
|
||||
```bash
|
||||
wget https://download.geofabrik.de/europe/germany/schleswig-holstein-latest.osm.pbf -P data/pbf
|
||||
```
|
||||
|
||||
Afterwards,run the following script:
|
||||
|
||||
```
|
||||
docker-compose run --rm portal tools/osm2pgsql.sh
|
||||
```
|
||||
|
||||
For more details. see [README.md](../README.md) under "Import OpenStreetMap data".
|
||||
|
||||
### Configure portal
|
||||
|
||||
|
|
|
@ -23,10 +23,16 @@ services:
|
|||
image: openbikesensor-portal
|
||||
build:
|
||||
context: ./source
|
||||
environment:
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_USER: obs
|
||||
POSTGRES_PASSWORD: obs
|
||||
POSTGRES_DB: obs
|
||||
volumes:
|
||||
- ./data/api-data:/data
|
||||
- ./config/config.py:/opt/obs/api/config.py
|
||||
- ./data/tiles/:/tiles
|
||||
- ./data/pbf/:/pbf
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
- postgres
|
||||
|
|
3
osm2pgsql.sh
Executable file
3
osm2pgsql.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo $POSTGRES_PASSWORD | osm2pgsql --create --hstore --style tools/roads_import.lua -O flex -H $POSTGRES_HOST -d $POSTGRES_DB -U $POSTGRES_USER -W /pbf/*.osm.pbf
|
Loading…
Reference in a new issue