Skip to content

Roqore/osrm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Here's a complete docker-compose.yml setup for running your own OSRM server with an external map file, using a clean Docker structure.


🧾 Project Structure

osrm-server/
├── docker-compose.yml
├── Dockerfile
├── .stxxl
└── data/
    └── sri-lanka-latest.osm.pbf   # <-- download manually here

📦 Dockerfile

This builds the OSRM server environment:

# Dockerfile
FROM ubuntu:22.04

# Install dependencies
RUN apt-get update && apt-get install -y \
    build-essential git cmake wget curl \
    libboost-all-dev libtbb-dev liblua5.2-dev \
    libluabind-dev libstxxl-dev libxml2-dev \
    libosmpbf-dev libbz2-dev libprotobuf-dev \
    protobuf-compiler libzip-dev ca-certificates nano \
    && apt-get clean

# Clone and build OSRM
RUN git clone https://github.com/Project-OSRM/osrm-backend.git /osrm-backend && \
    cd /osrm-backend && mkdir build && cd build && \
    cmake .. && make -j$(nproc) && make install

# Working directory
WORKDIR /data

# Expose the service port
EXPOSE 5000

CMD ["osrm-routed", "--algorithm", "MLD", "/data/sri-lanka-latest.osrm"]

⚙️ .stxxl file

Required for temporary disk caching:

disk=/tmp/stxxl,10G,syscall

Place this .stxxl file inside your root folder (osrm-server/).


📁 Download the map manually

Run this command in your data/ folder:

wget https://download.geofabrik.de/asia/sri-lanka-latest.osm.pbf

🧩 docker-compose.yml

version: "3.8"

services:
  osrm-extract:
    build: .
    volumes:
      - ./data:/data
      - ./.stxxl:/root/.stxxl
    entrypoint: >
      osrm-extract -p /osrm-backend/profiles/car.lua /data/sri-lanka-latest.osm.pbf

  osrm-partition:
    build: .
    depends_on:
      - osrm-extract
    volumes:
      - ./data:/data
      - ./.stxxl:/root/.stxxl
    entrypoint: >
      osrm-partition /data/sri-lanka-latest.osrm

  osrm-customize:
    build: .
    depends_on:
      - osrm-partition
    volumes:
      - ./data:/data
      - ./.stxxl:/root/.stxxl
    entrypoint: >
      osrm-customize /data/sri-lanka-latest.osrm

  osrm-server:
    build: .
    depends_on:
      - osrm-customize
    volumes:
      - ./data:/data
      - ./.stxxl:/root/.stxxl
    ports:
      - "5000:5000"
    entrypoint: >
      osrm-routed --algorithm MLD /data/sri-lanka-latest.osrm

🚀 Run the OSRM Server

Once everything is in place:

docker-compose up --build

It will:

  1. Build the image
  2. Extract map data
  3. Partition and customize the routing graph
  4. Start the OSRM server at http://localhost:5000

✅ Test the API

curl "http://localhost:5000/route/v1/driving/79.8587,6.9271;80.7718,7.2906?steps=true"

That example is for Colombo to Kandy in Sri Lanka.


Let me know if you'd like to make this support multiple maps, add CH mode, or deploy it to the cloud.

About

This is a complete docker-compose.yml setup for running your own OSRM server with an external map file, using a clean Docker structure.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors