I am trying to build a docker that imports the OSRM backend server, but then immediately imports and extracts the correct osm.pbf file. Now I am somehow not getting anywhere. My Dockerfile so far:
# import docker file
FROM osrm/osrm-backend:v5.25.0
# define variables
ARG OSM_FILE=/data/berlin-latest.osm.pbf
ARG OSRM_FILE=/data/berlin-latest.osrm
ARG DOWNLOAD_URL=http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
# transform variables
ENV OSM_FILE=$OSM_FILE
ENV OSRM_FILE=$OSRM_FILE
ENV DOWNLOAD_URL=$DOWNLOAD_URL
# install wget
RUN apt-get update
RUN apt install -y wget
# download data
RUN wget $DOWNLOAD_URL
# import the file
RUN -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua $OSM_FILE
RUN -t -v "${PWD}:/data" osrm/osrm-backend osrm-partition $OSRM_FILE
RUN -t -v "${PWD}:/data" osrm/osrm-backend osrm-customize $OSRM_FILE
# start docker
RUN -t -i -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld $OSRM_FILE
I've only ever run Docker until now, but haven't built one myself. Thanks for the help!!
So here is my working Dockerfile
# import docker file
FROM osrm/osrm-backend:v5.25.0
# define variables
ARG DOWNLOAD_URL=http://download.geofabrik.de/europe/germany-latest.osm.pbf
ARG OSM_FILE=germany-latest.osm.pbf
ARG OSRM_FILE=germany-latest.osrm
# transform variables
ENV OSM_FILE=$OSM_FILE
ENV OSRM_FILE=$OSRM_FILE
ENV DOWNLOAD_URL=$DOWNLOAD_URL
# install wget
RUN apt-get update
RUN apt install -y wget
# download data
RUN mkdir data
RUN cd data
RUN wget $DOWNLOAD_URL
# extract the osm file
RUN osrm-extract -p /opt/car.lua $OSM_FILE
# delete the osm file
RUN rm -rf $OSM_FILE
# create other formats
RUN osrm-partition $OSRM_FILE
RUN osrm-customize $OSRM_FILE
# Start the docker
CMD osrm-routed --algorithm mld $OSRM_FILE
EXPOSE 5000
The build takes a long time though, just under 45 minutes on an 8 core PC with 16 GB.