From 7ffc08be2849742ceb92fbdc756b7af3ba6f8f55 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Wed, 19 Jun 2024 07:46:56 +0200 Subject: [PATCH 1/2] Bump versions of TBB, Expat and Lua installed via Conan (#6957) --- CMakeLists.txt | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1876d6b85..eac368946 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,20 +330,12 @@ if(ENABLE_CONAN) set(CONAN_BOOST_VERSION "1.85.0@#14265ec82b25d91305bbb3b30d3357f8") set(CONAN_BZIP2_VERSION "1.0.8@#d1b2d5816f25865acf978501dff1f897") - set(CONAN_EXPAT_VERSION "2.2.10@#916908d4a570ad839edd25322c3268cd") - set(CONAN_LUA_VERSION "5.4.4@#3ec62efc37cd0a5d80b9e5cb35277360") - set(CONAN_TBB_VERSION "2021.3.0@#507ec17cbd51a84167e143b20d170eea") + set(CONAN_EXPAT_VERSION "2.6.2@#2d385d0d50eb5561006a7ff9e356656b") + set(CONAN_LUA_VERSION "5.4.6@#658d6089093cf01992c2737ab2e96763") + set(CONAN_TBB_VERSION "2021.12.0@#e56e5b44be8d690530585dd3634c0106") set(CONAN_SYSTEM_INCLUDES ON) - # TODO: - # if we link TBB dynamically osrm-extract.exe finishes on the first access to any TBB symbol - # with exit code = -1073741515, which means that program cannot load required DLL. - if (MSVC) - set(TBB_SHARED False) - else() - set(TBB_SHARED True) - endif() set(CONAN_ARGS REQUIRES @@ -357,7 +349,6 @@ if(ENABLE_CONAN) KEEP_RPATHS NO_OUTPUT_DIRS OPTIONS boost:filesystem_version=3 # https://stackoverflow.com/questions/73392648/error-with-boost-filesystem-version-in-cmake - onetbb:shared=${TBB_SHARED} boost:without_stacktrace=True # Apple Silicon cross-compilation fails without it BUILD missing ) From 97f676d5a372a8ea6f0e04f8ba4054997a0877fd Mon Sep 17 00:00:00 2001 From: knowname Date: Wed, 19 Jun 2024 14:15:23 +0200 Subject: [PATCH 2/2] add alpine dockerfile (#6958) --- docker/Dockerfile-alpine | 64 ++++++++++++++++++++++++++++++++++++++++ docker/hooks/build | 6 +++- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 docker/Dockerfile-alpine mode change 100644 => 100755 docker/hooks/build diff --git a/docker/Dockerfile-alpine b/docker/Dockerfile-alpine new file mode 100644 index 000000000..c636b1619 --- /dev/null +++ b/docker/Dockerfile-alpine @@ -0,0 +1,64 @@ +FROM alpine:3.20.0 as alpine-mimalloc + +RUN apk add --no-cache mimalloc + +ENV LD_PRELOAD=/usr/lib/libmimalloc.so.2 +ENV MIMALLOC_LARGE_OS_PAGES=1 + + +FROM alpine-mimalloc as builder +ARG DOCKER_TAG +ARG BUILD_CONCURRENCY +RUN mkdir -p /src && mkdir -p /opt + +RUN apk add --no-cache \ + cmake make git clang libbz2 libxml2 \ + boost-dev boost-program_options boost-filesystem boost-iostreams boost-thread \ + lua5.4-dev onetbb-dev expat-dev + +COPY . /src +WORKDIR /src + +RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \ + echo "Building OSRM ${DOCKER_TAG}" && \ + git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \ + echo "Building OSRM gitsha $(cat /opt/OSRM_GITSHA)" && \ + mkdir -p build && \ + cd build && \ + BUILD_TYPE="Release" && \ + ENABLE_ASSERTIONS="Off" && \ + BUILD_TOOLS="Off" && \ + case ${DOCKER_TAG} in *"-debug"*) BUILD_TYPE="Debug";; esac && \ + case ${DOCKER_TAG} in *"-assertions"*) BUILD_TYPE="RelWithDebInfo" && ENABLE_ASSERTIONS="On" && BUILD_TOOLS="On";; esac && \ + echo "Building ${BUILD_TYPE} with ENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} BUILD_TOOLS=${BUILD_TOOLS}" && \ + cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} -DBUILD_TOOLS=${BUILD_TOOLS} -DENABLE_LTO=On && \ + make -j${NPROC} install && \ + cd ../profiles && \ + cp -r * /opt && \ + strip /usr/local/bin/* && \ + rm -rf /src + + +# Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds +# Only the content below ends up in the image, this helps remove /src from the image (which is large) +FROM alpine-mimalloc as runstage + +COPY --from=builder /usr/local /usr/local +COPY --from=builder /opt /opt + +RUN apk add --no-cache \ + boost-program_options boost-regex \ + boost-date_time boost-chrono boost-filesystem \ + boost-iostreams boost-system boost-thread \ + expat lua5.4 onetbb && \ + ldconfig /usr/local/lib + +RUN /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 + +WORKDIR /opt + +EXPOSE 5000 diff --git a/docker/hooks/build b/docker/hooks/build old mode 100644 new mode 100755 index c27c851ad..8756e3e93 --- a/docker/hooks/build +++ b/docker/hooks/build @@ -6,4 +6,8 @@ # ensure that "COPY . /src" is referring to the repo root, not the directory # that contains the Dockerfile. # This script gets executed with a pwd of wherever the Dockerfile is. -docker build --build-arg BUILD_CONCURRENCY=${CONCURRENCY:-1} --build-arg DOCKER_TAG=${DOCKER_TAG} -t $IMAGE_NAME -f Dockerfile .. + +DOCKER_BUILD="docker build --build-arg BUILD_CONCURRENCY=${CONCURRENCY} --build-arg DOCKER_TAG=${DOCKER_TAG:?unset} -t ${IMAGE_NAME:?unset} -f" + +$DOCKER_BUILD Dockerfile .. +$DOCKER_BUILD Dockerfile-alpine ..