Getting Started - HY-OHTUPROJ-OSRM/osrm-project GitHub Wiki
These instructions detail how to set up the application for local development. There are two main ways of running the application:
- running local executables
- running Docker containers
For local development, it is recommended to run the application as local executables.
In production, the application should be run as Docker containers in a container orchestration platform such as Kubernetes, OpenShift, Docker Compose, etc. For running the application in containers for development purposes, use the instructions below.
- Follow the instructions in the osrm-backend wiki and ensure that the resultant executables (
osrm-extract
,osrm-contract
, etc.) are added to your PATH.
- Follow the instructions on this wiki (build the CLI, not the GUI) and add the executable
Polygonal-Intersections-CLI
to your PATH.
- This can be done using Docker with the following command:
docker run -p 5432:5432 -e POSTGRES_PASSWORD=pass --name postgis postgis/postgis
-
Run routing-api
- Clone the repository.
- Run
npm install
. - Create a
.env
file in the repository root with the following contents (routing-api will load them as environment variables):
DATABASE_HOST=<PostGIS hostname>
DATABASE_PORT=<PostGIS port>
DATABASE_DB=<PostGIS database>
DATABASE_USER=<PostGIS user>
DATABASE_PASSWORD=<PostGIS password>
PROFILES_PATH=<Path to where the osrm-backend profiles (car.lua, bicycle.lua, etc.) are located>
ROUTE_DATA_PATH=<Path to the .osm/.pbf file to use for routing>
- If you started PostGIS with the command above, and you built osrm-backend on Linux, your
.env
file should probably work with the following:
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_DB=postgres
DATABASE_USER=postgres
DATABASE_PASSWORD=pass
PROFILES_PATH=/usr/local/share/osrm/profiles
ROUTE_DATA_PATH=./map_data/route-data.osm
-
Note that the routing-api repository comes with a small portion of Finland in the
route-data.osm
file. If you need the whole Finland, use dr2osm and adjust theROUTE_DATA_PATH
environment variable. If the default port (3000) doesn't work for you, you can set the port by addingPORT=<port>
to the.env
file. -
Start routing-api with
npm start
. If you are running the entire Finland dataset, this could take many minutes.
-
Run routing-front
- Clone the repository.
- Run
npm install
. - Create a
.env
file in the repository root with the following content (the React app builder will set it as an environment variable during build):
REACT_APP_ROUTING_API_URL=<routing-api URL>
- If you started routing-api locally with the default port, you would write:
REACT_APP_ROUTING_API_URL=http://localhost:3000
- Start routing-front with
npm start
.
- This can be done using Docker with the following command:
docker run -p 5432:5432 -e POSTGRES_PASSWORD=pass --name postgis postgis/postgis
-
Run routing-api
- Clone the repository.
- Build the Docker image:
docker build --tag routing-api .
- Run the Docker image:
docker run -it --rm --net="host" \
-e DATABASE_HOST=localhost \
-e DATABASE_PORT=5432 \
-e DATABASE_DB=postgres \
-e DATABASE_USER=postgres \
-e DATABASE_PASSWORD=pass \
routing-api
- Adjust the environment variables if necessary. You can also create a
.env
file with the environment variables (see the instructions for running with local executables) and build the image, so the.env
file gets built into the image. In this case, you can run routing-api with just the command:
docker run -it --rm --net="host" routing-api
-
Run routing-front
- Clone the repository.
- Build the Docker image:
docker build --build-arg ROUTING_API_URL=http://localhost:3000 --tag routing-front .
-
Adjust the
ROUTING_API_URL
build argument if necessary. -
Run the Docker image:
docker run -it --rm -p 8080:8080 routing-front
-
Ensure that the environment variables are correct. For example, in the Docker image for routing-api, the osrm-backend profile folder is
/opt
(which is the default), so be sure that you haven't overridden it to be something else, likePROFILES_PATH=/usr/local/share/osrm/profiles
. -
If routing-api stalls while starting up, sometimes it can be fixed by closing the application and running the command:
rm /tmp/osrm*
- This will remove some shared memory related files, and the application may crash on the next start-up(s), but after a few
npm start
's it should fix it.