Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andiradulescu committed Dec 12, 2023
0 parents commit c02a918
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tools/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data
**.pbf
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Dynamic Images

To build the Docker image, use the following command:

```docker build -t neobility/osrm-backend-docker dynamic```

To run the Docker image, use the following command:

```docker run -e MAP_URL=https://download.geofabrik.de/europe/romania-latest.osm.pbf -v "./data:/data" neobility/osrm-backend-docker:latest```

## Prebuilt Images

To build a prebuilt image, use the following command:

```docker build --build-arg MAP_URL=https://download.geofabrik.de/europe/romania-latest.osm.pbf -t neobility/osrm-backend-docker:romania prebuilt```

To run the prebuilt image, use the following command:

```docker run neobility/osrm-backend-docker:romania```
10 changes: 10 additions & 0 deletions dynamic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ghcr.io/project-osrm/osrm-backend

# Install curl
RUN apt-get update && apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/*

# Copy the entrypoint script to the container
COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
35 changes: 35 additions & 0 deletions dynamic/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Check if map URL environment variable is set
if [ -z "${MAP_URL}" ]; then
echo "MAP_URL environment variable is not set."
exit 1
fi

# Extract filename from URL
MAP_FILE=$(basename ${MAP_URL})

# Define the base name for the OSRM files
OSRM_BASENAME="/data/${MAP_FILE%.osm.pbf}"

# Download the map file if it doesn't exist
# Run extract, partition, and customize
if [ ! -f "/data/${MAP_FILE}" ]; then
echo "Downloading map data from ${MAP_URL} to /data/${MAP_FILE} ..."

mkdir -p /data
curl -o "/data/${MAP_FILE}" "${MAP_URL}"

echo "Extracting and preparing the map data ${OSRM_BASENAME}.osrm ..."

# Extract the map file
osrm-extract -p /opt/car.lua "/data/${MAP_FILE}"

# Prepare the routing data
osrm-partition "${OSRM_BASENAME}.osrm"
osrm-customize "${OSRM_BASENAME}.osrm"
fi

# Start the OSRM backend
echo "Starting OSRM backend..."
osrm-routed --algorithm mld "${OSRM_BASENAME}.osrm"
15 changes: 15 additions & 0 deletions prebuilt/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ghcr.io/project-osrm/osrm-backend

ARG MAP_URL

ADD ${MAP_URL} /data/map.osm.pbf

RUN osrm-extract -p /opt/car.lua /data/map.osm.pbf

RUN osrm-partition /data/map.osm

RUN osrm-customize /data/map.osm

RUN rm /data/map.osm.pbf

ENTRYPOINT [ "osrm-routed", "--algorithm", "mld", "/data/map.osm" ]
16 changes: 16 additions & 0 deletions tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM osrm/osrm-backend

# ADD http://download.geofabrik.de/north-america/us-northeast-latest.osm.pbf /data/
ADD us-northeast-latest.osm.pbf /data/

RUN osrm-extract -p /opt/car.lua /data/us-northeast-latest.osm.pbf

RUN osrm-partition /data/us-northeast-latest.osm

RUN osrm-customize /data/us-northeast-latest.osm

RUN rm /data/us-northeast-latest.osm.pbf

ENTRYPOINT [ "osrm-routed", "--algorithm", "mld" ]

CMD [ "/data/us-northeast-latest.osm" ]
3 changes: 3 additions & 0 deletions tools/download-pbf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wget https://download.geofabrik.de/north-america/us/pennsylvania-latest.osm.pbf
wget https://download.geofabrik.de/north-america/us/new-york-latest.osm.pbf
wget https://download.geofabrik.de/europe/romania-latest.osm.pbf
1 change: 1 addition & 0 deletions tools/download-world-pbf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wget https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf
1 change: 1 addition & 0 deletions tools/merge-pbf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
osmium cat romania-latest.osm.pbf new-york-latest.osm.pbf pennsylvania-latest.osm.pbf -o merged.osm.pbf
5 changes: 5 additions & 0 deletions tools/preprocess.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/planet-latest.osm.pbf

docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-partition /data/planet-latest.osm

docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-customize /data/planet-latest.osm
1 change: 1 addition & 0 deletions tools/run-osrm-frontend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker run -p 9966:9966 -e OSRM_BACKEND='http://127.0.0.1:5000' osrm/osrm-frontend
3 changes: 3 additions & 0 deletions tools/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# docker run -t -i -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld /data/planet-latest.osm

docker run -d -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld /data/planet-latest.osm

0 comments on commit c02a918

Please sign in to comment.