diff --git a/Dockerfile b/Dockerfile index 8ac900d..3abb2f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ LABEL \ org.opencontainers.image.vendor="https://peterevans.dev" \ org.opencontainers.image.licenses="MIT" -ENV OSRM_VERSION 5.22.0 +ENV OSRM_VERSION 5.26.0 # Let the container know that there is no TTY ARG DEBIAN_FRONTEND=noninteractive @@ -33,9 +33,9 @@ RUN apt-get -y update \ pkg-config \ gcc \ python-dev \ + python-pip \ python-setuptools \ && apt-get clean \ - && easy_install -U pip \ && pip install -U crcmod \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /tmp/* /var/tmp/* @@ -56,6 +56,10 @@ RUN mkdir /osrm-src \ && cp -r /osrm-src/osrm-backend-$OSRM_VERSION/profiles/* /osrm-profiles \ && rm -rf /osrm-src +# allows for adding prebuilt files to the image for faster use in dev without egress charges +# expects data in same format as on gs, so prebuilt/$OSRM_DATA_LABEL/*.osrm* +COPY prebuilt/ /prebuilt/ + # Set the entrypoint COPY docker-entrypoint.sh / RUN chmod +x /docker-entrypoint.sh diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 5632ae7..c93ecc8 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -26,7 +26,7 @@ trap _sig SIGKILL SIGTERM SIGHUP SIGINT EXIT if [ "$OSRM_MODE" == "CREATE" ]; then # Retrieve the PBF file - curl -L $OSRM_PBF_URL --create-dirs -o $OSRM_DATA_PATH/$OSRM_DATA_LABEL.osm.pbf + curl -k -L $OSRM_PBF_URL --create-dirs -o $OSRM_DATA_PATH/$OSRM_DATA_LABEL.osm.pbf # Build the graph osrm-extract $OSRM_DATA_PATH/$OSRM_DATA_LABEL.osm.pbf -p /osrm-profiles/$OSRM_GRAPH_PROFILE.lua @@ -45,8 +45,13 @@ if [ "$OSRM_MODE" == "CREATE" ]; then fi else - - if [ ! -z "$OSRM_SA_KEY_PATH" ] && [ ! -z "$OSRM_PROJECT_ID" ] && [ ! -z "$OSRM_GS_BUCKET" ]; then + if [ -d /prebuilt ] && [ -d /prebuilt/$OSRM_DATA_LABEL ] ; then + cd $OSRM_DATA_PATH || exit + for i in /prebuilt/"$OSRM_DATA_LABEL"/*; do + echo ln -s "$i" + ln -s "$i" . + done + elif [ -n "$OSRM_SA_KEY_PATH" ] && [ -n "$OSRM_PROJECT_ID" ] && [ -n "$OSRM_GS_BUCKET" ]; then # Activate the service account to access storage gcloud auth activate-service-account --key-file $OSRM_SA_KEY_PATH