From 07d6ed2d69509cc0994f5af127e1a245576f9b56 Mon Sep 17 00:00:00 2001 From: Elshan Date: Tue, 8 Jul 2025 13:22:15 +0330 Subject: [PATCH 1/6] add compose --- docker_comopse/docker-compose.yml | 65 +++++++++++++++++++++++++++++++ docker_comopse/prepare_osrm.sh | 12 ++++++ 2 files changed, 77 insertions(+) create mode 100644 docker_comopse/docker-compose.yml create mode 100755 docker_comopse/prepare_osrm.sh diff --git a/docker_comopse/docker-compose.yml b/docker_comopse/docker-compose.yml new file mode 100644 index 00000000000..494910d7b73 --- /dev/null +++ b/docker_comopse/docker-compose.yml @@ -0,0 +1,65 @@ +services: + osrm-extract_partition_customize: + image: ghcr.io/project-osrm/osrm-backend:v6.0.0 + volumes: + - /mnt/graid/projects/osrm:/data + - ./prepare_osrm.sh:/prepare_osrm.sh + command: /prepare_osrm.sh + + restart: "no" + networks: + - osrm_osrm-network + + + osrm-routed: + hostname: osrm-routed + image: ghcr.io/project-osrm/osrm-backend:v6.0.0 + ports: + - "5050:5000" + volumes: + - /mnt/graid/projects/osrm:/data + command: > + osrm-routed + --algorithm mld + --max-matching-size 100 + --max-trip-size 100 + --max-table-size 100 + --max-nearest-size 100 + --max-alternatives 3 + --ip 0.0.0.0 + --port 5000 + /data/iran-latest.osrm + networks: + - nginx-network + - osrm_osrm-network + restart: always + + depends_on: + osrm-frontend: + condition: service_healthy + + osrm-frontend: + hostname: osrm-frontend + image: osrm/osrm-frontend + #ports: + # - "9966:9966" + restart: always + environment: + - OSRM_BACKEND_URL=https://osrmapi.buluttakin.com:443 + networks: + - nginx-network + - osrm_osrm-network + volumes: + - /mnt/graid/projects/osrm:/data + healthcheck: + test: ["CMD", "test", "-f", "/data/osrm_map_generated"] + interval: 6s + timeout: 600s + retries: 60000 + + +networks: + nginx-network: + external: true + osrm_osrm-network: + driver: bridge diff --git a/docker_comopse/prepare_osrm.sh b/docker_comopse/prepare_osrm.sh new file mode 100755 index 00000000000..8092a9fe728 --- /dev/null +++ b/docker_comopse/prepare_osrm.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ -f /data/osrm_map_generated ]; then + echo "OSRM data already prepared, skipping." +else + echo "OSRM data not found, preparing..." + osrm-extract -p /opt/car.lua /data/iran-latest.osm.pbf && + osrm-partition /data/iran-latest.osrm && + osrm-customize /data/iran-latest.osrm && + touch /data/osrm_map_generated +fi + From 0622cd61f6e041d721d911b231af17165c254b97 Mon Sep 17 00:00:00 2001 From: elshan2000 <86655492+elshan2000@users.noreply.github.com> Date: Tue, 8 Jul 2025 15:07:32 +0330 Subject: [PATCH 2/6] Create README2.ME readme --- README2.ME | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 README2.ME diff --git a/README2.ME b/README2.ME new file mode 100644 index 00000000000..27bc10dc897 --- /dev/null +++ b/README2.ME @@ -0,0 +1,104 @@ +# Docker Compose Setup for Project OSRM + +This directory contains a **Docker Compose configuration** to simplify running [Project OSRM](https://github.com/Project-OSRM/osrm-backend). + +With this way: + +* Only use docker compose up -dย ย  +* It launches a **frontend service** with health checks. +* Don't need to ensure services start in the correct order. + +--- + +## ๐Ÿ“‚ Directory Structure + +``` +osrm-backend/ +โ”œโ”€โ”€ docker-compose.yml +โ”œโ”€โ”€ prepare_osrm.sh +``` + +--- + +## Quick Start + +### Clone this repository + +```bash +git clone https://github.com/elshan2000/osrm-backend.git +cd osrm-backend +``` + +### + +``` +### How It Works +``` + +### Init Service + +* Checks for the marker file `osrm_is_created`. +* If not present, runs: + + * `osrm-extract` + * `osrm-partition` + * `osrm-customize` +* Creates the marker file. +* Exits after preparation. + +### Backend Service + +* Depends on the **frontend healthcheck**. +* Starts `osrm-routed` serving prepared data. + +### Frontend Service + +* Periodically checks for the presence of the marker file `osrm_is_created`. +* Reports `healthy` when the preparation is complete. +* This readiness allows the backend service to start safely. + +--- + +## ๏ฟฝํžบ Health Check Logic + +The **frontend** container performs a health check by verifying: + +``` +/data/osrm_is_created +``` + +Once the file exists, the health check reports `healthy`. This ensures that: + +โœ… Data preparation is complete before routing starts. + +--- + +## ๐Ÿงน Clean Up + +To stop and remove all containers: + +```bash +docker compose down +``` + +To force re-preparation of the data (for example, if you want to regenerate `.osrm` files): + +```bash +docker compose down +rm ./data/osrm_is_created +docker compose up -d +``` + +--- + +## โœจ Contribution + +This Docker Compose configuration was contributed by [elshan2000](https://github.com/elshan2000). + +Feel free to open issues or submit improvements! + +--- + +## ๐Ÿ“„ License + +This project follows the [Project OSRM](https://github.com/Project-OSRM/osrm-backend) license (BSD-2-Clause). From 3f27911b13b1513264f028b9443f9b0e88220ddd Mon Sep 17 00:00:00 2001 From: elshan2000 <86655492+elshan2000@users.noreply.github.com> Date: Tue, 8 Jul 2025 15:08:12 +0330 Subject: [PATCH 3/6] Rename README2.ME to README2.MD --- README2.ME => README2.MD | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README2.ME => README2.MD (100%) diff --git a/README2.ME b/README2.MD similarity index 100% rename from README2.ME rename to README2.MD From 90d9ecb51cee715b62b66791dd2a21936b698517 Mon Sep 17 00:00:00 2001 From: elshan2000 <86655492+elshan2000@users.noreply.github.com> Date: Tue, 8 Jul 2025 15:08:42 +0330 Subject: [PATCH 4/6] Update README2.MD --- README2.MD | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README2.MD b/README2.MD index 27bc10dc897..e5bd36e5df5 100644 --- a/README2.MD +++ b/README2.MD @@ -10,7 +10,7 @@ With this way: --- -## ๐Ÿ“‚ Directory Structure +## Directory Structure ``` osrm-backend/ @@ -59,7 +59,7 @@ cd osrm-backend --- -## ๏ฟฝํžบ Health Check Logic +## Health Check Logic The **frontend** container performs a health check by verifying: @@ -69,11 +69,11 @@ The **frontend** container performs a health check by verifying: Once the file exists, the health check reports `healthy`. This ensures that: -โœ… Data preparation is complete before routing starts. + Data preparation is complete before routing starts. --- -## ๐Ÿงน Clean Up +## Clean Up To stop and remove all containers: @@ -91,7 +91,7 @@ docker compose up -d --- -## โœจ Contribution +## Contribution This Docker Compose configuration was contributed by [elshan2000](https://github.com/elshan2000). @@ -99,6 +99,6 @@ Feel free to open issues or submit improvements! --- -## ๐Ÿ“„ License +## License This project follows the [Project OSRM](https://github.com/Project-OSRM/osrm-backend) license (BSD-2-Clause). From 3096050a4bbbae030d97a5a2e9ad0d2e5d44ca81 Mon Sep 17 00:00:00 2001 From: elshan2000 <86655492+elshan2000@users.noreply.github.com> Date: Thu, 10 Jul 2025 08:57:36 +0330 Subject: [PATCH 5/6] Update README2.MD --- README2.MD | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README2.MD b/README2.MD index e5bd36e5df5..e48b18813b6 100644 --- a/README2.MD +++ b/README2.MD @@ -31,9 +31,8 @@ cd osrm-backend ### -``` -### How It Works -``` + +## How It Works ### Init Service From 561c1936a487a670769add68feeef6b3e8c8b95a Mon Sep 17 00:00:00 2001 From: elshan2000 <86655492+elshan2000@users.noreply.github.com> Date: Thu, 10 Jul 2025 09:01:38 +0330 Subject: [PATCH 6/6] Update docker-compose.yml --- docker_comopse/docker-compose.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker_comopse/docker-compose.yml b/docker_comopse/docker-compose.yml index 494910d7b73..d72f48ec132 100644 --- a/docker_comopse/docker-compose.yml +++ b/docker_comopse/docker-compose.yml @@ -15,7 +15,7 @@ services: hostname: osrm-routed image: ghcr.io/project-osrm/osrm-backend:v6.0.0 ports: - - "5050:5000" + #- "5050:5000" volumes: - /mnt/graid/projects/osrm:/data command: > @@ -45,7 +45,8 @@ services: # - "9966:9966" restart: always environment: - - OSRM_BACKEND_URL=https://osrmapi.buluttakin.com:443 + # - OSRM_BACKEND_URL=https://osrmapi.buluttakin.com:443 + - OSRM_BACKEND_URL=osrm-routed:5000 networks: - nginx-network - osrm_osrm-network