Closed msschl closed 1 year ago
Here is my Dockerfile
ARG OSRM_RELEASE
FROM ghcr.io/project-osrm/osrm-backend:$OSRM_RELEASE as osrm
# Source code from vroom builder stage - vroom uses debian:bullseye-slim image for building
# https://github.com/VROOM-Project/vroom-docker/blob/master/Dockerfile
FROM debian:bullseye-slim as vroom-builder
ARG OSRM_RELEASE
########################################################################################################################
# START: Source Code from osrm build production stage #
# https://github.com/Project-OSRM/osrm-backend/blob/master/docker/Dockerfile#L47-L63 #
########################################################################################################################
RUN echo "Copy osrm binaries from ghcr.io/project-osrm/osrm-backend:${OSRM_RELEASE}"
COPY --from=osrm /usr/local /usr/local
COPY --from=osrm /opt /opt
RUN echo "Updating apt-get and installing osrm-backend dependencies..." && \
apt-get update && \
apt-get install -y --no-install-recommends \
libboost-program-options1.74.0 \
libboost-regex1.74.0 \
libboost-date-time1.74.0 \
libboost-chrono1.74.0 \
libboost-filesystem1.74.0 \
libboost-iostreams1.74.0 \
libboost-system1.74.0 \
libboost-thread1.74.0 \
expat \
liblua5.4-0 && \
# add /usr/local/lib to ldconfig to allow loading libraries from there
echo "Add /usr/local/lib to ldconfig to allow loading libraries from there" && \
ldconfig /usr/local/lib
RUN echo "Test compiled osrm binaries..." && \
/usr/local/bin/osrm-extract --help && \
/usr/local/bin/osrm-routed --help && \
/usr/local/bin/osrm-contract --help && \
/usr/local/bin/osrm-partition --help && \
/usr/local/bin/osrm-customize --help
########################################################################################################################
# END: Source Code from osrm build production stage #
# https://github.com/Project-OSRM/osrm-backend/blob/master/docker/Dockerfile#L47-L63 #
########################################################################################################################
# ----------------------------------------------------------------------------------------------------------------------
########################################################################################################################
# START: Source code from vroom build stage #
# https://github.com/VROOM-Project/vroom-docker/blob/master/Dockerfile#L4-L36 #
########################################################################################################################
WORKDIR /
RUN echo "Installing vroom dependencies..." && \
apt-get -y install \
git-core \
build-essential \
g++ \
libssl-dev \
libasio-dev \
libglpk-dev \
pkg-config
ARG VROOM_RELEASE
# TODO(msschl): Debugging code! Remove!!!
RUN pkg-config --libs libosrm
RUN pkg-config --cflags libosrm
RUN echo "Cloning and installing vroom release ${VROOM_RELEASE}..." && \
git clone --recurse-submodules https://github.com/VROOM-Project/vroom.git && \
cd vroom && \
git fetch --tags && \
git checkout -q $VROOM_RELEASE && \
make -C /vroom/src -j$(nproc) && \
cd /
ARG VROOM_EXPRESS_RELEASE
RUN echo "Cloning and installing vroom-express release ${VROOM_EXPRESS_RELEASE}..." && \
git clone https://github.com/VROOM-Project/vroom-express.git && \
cd vroom-express && \
git fetch --tags && \
git checkout $VROOM_EXPRESS_RELEASE
FROM node:12-bullseye-slim as runstage
COPY --from=vroom-builder /vroom-express/. /vroom-express
COPY --from=vroom-builder /vroom/bin/vroom /usr/local/bin
########################################################################################################################
# END: Source code from vroom build stage #
# https://github.com/VROOM-Project/vroom-docker/blob/master/Dockerfile#L4-L36 #
########################################################################################################################
# ----------------------------------------------------------------------------------------------------------------------
########################################################################################################################
# START: Source Code from osrm build production stage #
# https://github.com/Project-OSRM/osrm-backend/blob/master/docker/Dockerfile#L47-L63 #
########################################################################################################################
RUN echo "Copy osrm binaries from ghcr.io/project-osrm/osrm-backend:$OSRM_RELEASE"
COPY --from=osrm /usr/local /usr/local
COPY --from=osrm /opt /opt
RUN echo "Updating apt-get and installing osrm-backend dependencies..." && \
apt-get update && \
apt-get install -y --no-install-recommends \
libboost-program-options1.74.0 \
libboost-regex1.74.0 \
libboost-date-time1.74.0 \
libboost-chrono1.74.0 \
libboost-filesystem1.74.0 \
libboost-iostreams1.74.0 \
libboost-system1.74.0 \
libboost-thread1.74.0 \
expat \
liblua5.4-0 && \
# add /usr/local/lib to ldconfig to allow loading libraries from there
echo "Add /usr/local/lib to ldconfig to allow loading libraries from there" && \
ldconfig /usr/local/lib
RUN echo "Test compiled osrm binaries..." && \
/usr/local/bin/osrm-extract --help && \
/usr/local/bin/osrm-routed --help && \
/usr/local/bin/osrm-contract --help && \
/usr/local/bin/osrm-partition --help && \
/usr/local/bin/osrm-customize --help
########################################################################################################################
# END: Source Code from osrm build production stage #
# https://github.com/Project-OSRM/osrm-backend/blob/master/docker/Dockerfile#L47-L63 #
########################################################################################################################
# ----------------------------------------------------------------------------------------------------------------------
########################################################################################################################
# START: Source code from vroom build stage #
# https://github.com/VROOM-Project/vroom-docker/blob/master/Dockerfile#L38-L36 #
########################################################################################################################
WORKDIR /vroom-express
RUN echo "Installing vroom dependencies..." && \
apt-get install -y --no-install-recommends \
libssl1.1 \
curl \
libglpk40 && \
rm -rf /var/lib/apt/lists/* && \
# Install vroom-express
npm config set loglevel error && \
npm install && \
# To share the config.yml & access.log file with the host
mkdir /conf
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
# NOTE(msschl): Modified router to use libosrm with shared memory
ENV VROOM_ROUTER=libosrm
ENV VROOM_LOG=/conf
########################################################################################################################
# END: Source code from vroom build stage #
# https://github.com/VROOM-Project/vroom-docker/blob/master/Dockerfile#L38-L56 #
########################################################################################################################
# NOTE(msschl): Running this container with k8s as a non root user
RUN groupmod -g 2000 node && usermod -u 1000 -g 2000 node
USER node
RUN chown -R 1000:2000 /vroom-express
RUN chown -R 1000:2000 /conf
########################################################################################################################
# START: Source code from vroom build stage #
# https://github.com/VROOM-Project/vroom-docker/blob/master/Dockerfile#L58-L62 #
########################################################################################################################
HEALTHCHECK --start-period=10s CMD curl --fail -s http://localhost:3000/health || exit 1
EXPOSE 3000
ENTRYPOINT ["/bin/bash"]
CMD ["/docker-entrypoint.sh"]
This is a linking problem: the vroom
compilation works fine but the files required to use OSRM as a library are not found on the system.
It looks like you're using prebuilt binaries for OSRM. This provides the osrm-*
executables but probably does not offer the files you get when properly installing libosrm
by running the usual sudo cmake --build . --target install
after a regular OSRM build.
I think it should all be inside the /usr/local dir he’s copying from OSRM. Strange that it can’t link, since vroom builds fine (ie the OSRM headers are there).
Your setup would be interesting for vroom-docker as well. I’d like an image that’s based on libosrm (and eventually libvalhalla), instead of HTTP.
I found the issue I was having while compiling vroom with the /usr/local dir copied from the original OSRM image.
In the original OSRM Dockerfile on line 39 and 40 they remove the libosrm libraries and only leave the osrm-* executables.
I now compile first osrm on my own and then vroom on top.
To your point @nilsnolde I think this would be interesting for vroom-docker.
I‘ll close this issue since the compilation now works
I think we should keep the libs in the OSRM image. It’s a really nice and lean image, but the library itself wouldn’t add thaaat much to it. Having the full build artifacts in the docker image would be great for downstream/consuming projects. Let me poke there.