Previous: , Up: Running the Application with docker-compose   [Contents][Index]


8.2.2.1 OpenStreetMap Tile Server

Two other docker-compose files can be used to create a map tile server using the Docker container for OpenStreetMap tile server

One imports the OpenStreetMap data. The other runs the tile server after the data has been imported.

Elevation data can be made available to the container as follows:

  1. Create an external volume for the elevation data. (It is necessary to create the volume, even if no elevation data is available.):
    $ docker volume create elevation-data
    
  2. To copy elevation data files to the volume, stream the data from a tar file via a helper container to the volume as follows:
    $ tar -zcf elevation-data.tar.gz *.tif
    $ CID=$(docker run -d -v \
    elevation-data:/elevation-data busybox true)
    $ cat elevation-data.tar.gz | docker cp - $CID:/elevation-data/
    $ docker container stop $CID
    $ docker container rm $CID
    

    It is necessary to use the tar file method as that seems the only way to copy the data to the root of the volume.

Import map tile data as follows:

  1. The import process temporarily requires a lot of memory. You may need to create and mount a swap file:
    $ sudo dd if=/dev/zero of=/swap bs=1G count=2
    $ sudo chmod 0600 /swap
    $ sudo mkswap /swap
    $ sudo swapon /swap
    
  2. Create Docker volumes for storing any elevation data, the database and caching of map tiles:
    $ docker volume create osm-data
    $ docker volume create osm-tiles
    
  3. It is recommended to use a small region to minimise resource usage.

    The default set in ./.env imports OSM data for Monaco. To import another region, e.g. the Isle of Man, override the environment variables in ./.env, e.g.:

    The run the import with:

    $ DOWNLOAD_PBF=\
    https://download.geofabrik.de/europe/isle-of-man-latest.osm.pbf \
    DOWNLOAD_POLY=\
    https://download.geofabrik.de/europe/isle-of-man.poly \
    docker compose -f docker-compose-map-import.yml up
    

    The process must complete without error. Check the final output carefully. If it fails, it is necessary to delete and re-create the Docker osm-data volume.

    $ docker volume rm osm-data
    $ docker volume create osm-data
    
  4. Once the import completes successfully, run the map tile server:
    $ docker compose -f docker-compose-map-server.yml up -d
    

    To stop the tile server:

    $ docker compose -f docker-compose-map-server.yml down
    

Previous: Running the Application with docker-compose, Up: Running the Application with docker-compose   [Contents][Index]