|
| 1 | +FROM debian:bookworm-slim as builder |
| 2 | +ARG DOCKER_TAG |
| 3 | +ARG BUILD_CONCURRENCY |
| 4 | +RUN mkdir -p /src && mkdir -p /opt |
| 5 | + |
| 6 | +RUN apt-get update && \ |
| 7 | + apt-get -y --no-install-recommends install ca-certificates cmake make git gcc g++ libbz2-dev libxml2-dev wget \ |
| 8 | + libzip-dev libboost1.81-all-dev lua5.4 liblua5.4-dev pkg-config -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 |
| 9 | + |
| 10 | +RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \ |
| 11 | + ldconfig /usr/local/lib && \ |
| 12 | + git clone --branch v2021.12.0 --single-branch https://github.com/oneapi-src/oneTBB.git && \ |
| 13 | + cd oneTBB && \ |
| 14 | + mkdir build && \ |
| 15 | + cd build && \ |
| 16 | + cmake -DTBB_TEST=OFF -DCMAKE_BUILD_TYPE=Release .. && \ |
| 17 | + cmake --build . && \ |
| 18 | + cmake --install . |
| 19 | + |
| 20 | +COPY . /src |
| 21 | +WORKDIR /src |
| 22 | + |
| 23 | +RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \ |
| 24 | + export CXXFLAGS="-Wno-array-bounds -Wno-uninitialized" && \ |
| 25 | + echo "Building OSRM ${DOCKER_TAG}" && \ |
| 26 | + git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \ |
| 27 | + echo "Building OSRM gitsha $(cat /opt/OSRM_GITSHA)" && \ |
| 28 | + mkdir -p build && \ |
| 29 | + cd build && \ |
| 30 | + BUILD_TYPE="Release" && \ |
| 31 | + ENABLE_ASSERTIONS="Off" && \ |
| 32 | + BUILD_TOOLS="Off" && \ |
| 33 | + case ${DOCKER_TAG} in *"-debug"*) BUILD_TYPE="Debug";; esac && \ |
| 34 | + case ${DOCKER_TAG} in *"-assertions"*) BUILD_TYPE="RelWithDebInfo" && ENABLE_ASSERTIONS="On" && BUILD_TOOLS="On";; esac && \ |
| 35 | + echo "Building ${BUILD_TYPE} with ENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} BUILD_TOOLS=${BUILD_TOOLS}" && \ |
| 36 | + cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} -DBUILD_TOOLS=${BUILD_TOOLS} -DENABLE_LTO=On && \ |
| 37 | + make -j${NPROC} install && \ |
| 38 | + cd ../profiles && \ |
| 39 | + cp -r * /opt && \ |
| 40 | + strip /usr/local/bin/* && \ |
| 41 | + rm -rf /src |
| 42 | + |
| 43 | + |
| 44 | +# Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds |
| 45 | +# Only the content below ends up in the image, this helps remove /src from the image (which is large) |
| 46 | +FROM debian:bookworm-slim as runstage |
| 47 | + |
| 48 | +COPY --from=builder /usr/local /usr/local |
| 49 | +COPY --from=builder /opt /opt |
| 50 | + |
| 51 | +RUN apt-get update && \ |
| 52 | + apt-get install -y --no-install-recommends libboost-program-options1.81.0 libboost-regex1.81.0 \ |
| 53 | + libboost-date-time1.81.0 libboost-chrono1.81.0 libboost-filesystem1.81.0 \ |
| 54 | + libboost-iostreams1.81.0 libboost-system1.81.0 libboost-thread1.81.0 \ |
| 55 | + expat liblua5.4-0 && \ |
| 56 | + rm -rf /var/lib/apt/lists/* && \ |
| 57 | +# add /usr/local/lib to ldconfig to allow loading libraries from there |
| 58 | + ldconfig /usr/local/lib |
| 59 | + |
| 60 | +RUN /usr/local/bin/osrm-extract --help && \ |
| 61 | + /usr/local/bin/osrm-routed --help && \ |
| 62 | + /usr/local/bin/osrm-contract --help && \ |
| 63 | + /usr/local/bin/osrm-partition --help && \ |
| 64 | + /usr/local/bin/osrm-customize --help |
| 65 | + |
| 66 | +WORKDIR /opt |
| 67 | + |
| 68 | +EXPOSE 5000 |
0 commit comments