2025-01-25 02:09:37 -05:00
|
|
|
FROM alpine:3.21.2 AS alpine-mimalloc
|
2024-06-19 08:15:23 -04:00
|
|
|
|
2025-01-25 02:09:37 -05:00
|
|
|
RUN apk update && \
|
|
|
|
apk upgrade && \
|
|
|
|
apk add --no-cache \
|
|
|
|
boost-iostreams \
|
|
|
|
boost-program_options \
|
|
|
|
boost-thread \
|
|
|
|
mimalloc
|
2024-06-19 08:15:23 -04:00
|
|
|
|
|
|
|
ENV LD_PRELOAD=/usr/lib/libmimalloc.so.2
|
|
|
|
ENV MIMALLOC_LARGE_OS_PAGES=1
|
|
|
|
|
|
|
|
|
2025-01-12 11:28:56 -05:00
|
|
|
FROM alpine-mimalloc AS builder
|
2024-06-19 08:15:23 -04:00
|
|
|
ARG DOCKER_TAG
|
|
|
|
ARG BUILD_CONCURRENCY
|
|
|
|
|
2025-01-12 11:28:56 -05:00
|
|
|
RUN mkdir -p /src /opt && \
|
|
|
|
apk add --no-cache \
|
|
|
|
boost-dev \
|
|
|
|
boost-filesystem \
|
|
|
|
clang \
|
|
|
|
cmake \
|
|
|
|
expat-dev \
|
|
|
|
git \
|
|
|
|
libbz2 \
|
|
|
|
libxml2 \
|
|
|
|
lua5.4-dev \
|
|
|
|
make \
|
|
|
|
onetbb-dev
|
2024-06-19 08:15:23 -04:00
|
|
|
|
|
|
|
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}" && \
|
2024-06-30 15:07:49 -04:00
|
|
|
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} -DBUILD_TOOLS=${BUILD_TOOLS} -DENABLE_LTO=OFF && \
|
2024-06-19 08:15:23 -04:00
|
|
|
make -j${NPROC} install && \
|
|
|
|
cd ../profiles && \
|
|
|
|
cp -r * /opt && \
|
|
|
|
strip /usr/local/bin/* && \
|
|
|
|
rm -rf /src
|
|
|
|
|
|
|
|
|
2025-01-12 11:28:56 -05:00
|
|
|
# Multistage build to reduce image size - https://docs.docker.com/build/building/multi-stage/#use-multi-stage-builds
|
2024-06-19 08:15:23 -04:00
|
|
|
# Only the content below ends up in the image, this helps remove /src from the image (which is large)
|
2025-01-12 11:28:56 -05:00
|
|
|
FROM alpine-mimalloc AS runstage
|
2024-06-19 08:15:23 -04:00
|
|
|
|
|
|
|
COPY --from=builder /usr/local /usr/local
|
|
|
|
COPY --from=builder /opt /opt
|
|
|
|
|
|
|
|
RUN apk add --no-cache \
|
2025-01-12 11:28:56 -05:00
|
|
|
boost-date_time \
|
|
|
|
expat \
|
|
|
|
lua5.4 \
|
|
|
|
onetbb && \
|
2024-06-19 08:15:23 -04:00
|
|
|
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
|
2025-01-12 11:28:56 -05:00
|
|
|
|