Skip to content

Commit 6f235cc

Browse files
authored
Use libtbb-dev/libtbb12 packages in Dockerfile-debian, sort packages alphabetically in both Dockerfiles (#7095)
* - Use libtbb-dev in builder stage and libtbb12 package in the runstage instead of building oneTBB v2021.12.0 from source code - Remove wget package from builder stage, because it is not used - Uppercase "FROM ... as" -> "FROM ... AS" to silence a "docker build" warning - Sort packages alphabetically and put them on separate lines for easier comparison * - Fix the warning "FromAsCasing: 'as' and 'FROM' keywords' casing do not match" - Sort packages alphabetically and put them on separate lines for easier comparison * Revert -Wno-stringop-overflow * Update the link to multi staged builds in the comment * Update alpine:3.20.0 -> alpine:3.20.5
1 parent 3614af7 commit 6f235cc

File tree

2 files changed

+58
-32
lines changed

2 files changed

+58
-32
lines changed

docker/Dockerfile-alpine

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
1-
FROM alpine:3.20.0 as alpine-mimalloc
1+
FROM alpine:3.20.5 AS alpine-mimalloc
22

33
RUN apk add --no-cache mimalloc
44

55
ENV LD_PRELOAD=/usr/lib/libmimalloc.so.2
66
ENV MIMALLOC_LARGE_OS_PAGES=1
77

88

9-
FROM alpine-mimalloc as builder
9+
FROM alpine-mimalloc AS builder
1010
ARG DOCKER_TAG
1111
ARG BUILD_CONCURRENCY
12-
RUN mkdir -p /src && mkdir -p /opt
1312

14-
RUN apk add --no-cache \
15-
cmake make git clang libbz2 libxml2 \
16-
boost-dev boost-program_options boost-filesystem boost-iostreams boost-thread \
17-
lua5.4-dev onetbb-dev expat-dev
13+
RUN mkdir -p /src /opt && \
14+
apk add --no-cache \
15+
boost-dev \
16+
boost-filesystem \
17+
boost-iostreams \
18+
boost-program_options \
19+
boost-thread \
20+
clang \
21+
cmake \
22+
expat-dev \
23+
git \
24+
libbz2 \
25+
libxml2 \
26+
lua5.4-dev \
27+
make \
28+
onetbb-dev
1829

1930
COPY . /src
2031
WORKDIR /src
@@ -39,16 +50,21 @@ RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \
3950
rm -rf /src
4051

4152

42-
# Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds
53+
# Multistage build to reduce image size - https://docs.docker.com/build/building/multi-stage/#use-multi-stage-builds
4354
# Only the content below ends up in the image, this helps remove /src from the image (which is large)
44-
FROM alpine-mimalloc as runstage
55+
FROM alpine-mimalloc AS runstage
4556

4657
COPY --from=builder /usr/local /usr/local
4758
COPY --from=builder /opt /opt
4859

4960
RUN apk add --no-cache \
50-
boost-program_options boost-date_time boost-iostreams boost-thread \
51-
expat lua5.4 onetbb && \
61+
boost-date_time \
62+
boost-iostreams \
63+
boost-program_options \
64+
boost-thread \
65+
expat \
66+
lua5.4 \
67+
onetbb && \
5268
ldconfig /usr/local/lib
5369

5470
RUN /usr/local/bin/osrm-extract --help && \
@@ -60,3 +76,4 @@ RUN /usr/local/bin/osrm-extract --help && \
6076
WORKDIR /opt
6177

6278
EXPOSE 5000
79+

docker/Dockerfile-debian

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
FROM debian:bookworm-slim as builder
1+
FROM debian:bookworm-slim AS builder
22
ARG DOCKER_TAG
33
ARG BUILD_CONCURRENCY
4-
RUN mkdir -p /src && mkdir -p /opt
54

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 .
5+
RUN mkdir -p /src /opt && \
6+
apt-get update && \
7+
apt-get -y --no-install-recommends --no-install-suggests install \
8+
ca-certificates \
9+
cmake \
10+
g++ \
11+
gcc \
12+
git \
13+
libboost1.81-all-dev \
14+
libbz2-dev \
15+
liblua5.4-dev \
16+
libtbb-dev \
17+
libxml2-dev \
18+
libzip-dev \
19+
lua5.4 \
20+
make \
21+
pkg-config
1922

2023
COPY . /src
2124
WORKDIR /src
@@ -41,19 +44,24 @@ RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \
4144
rm -rf /src
4245

4346

44-
# Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds
47+
# Multistage build to reduce image size - https://docs.docker.com/build/building/multi-stage/#use-multi-stage-builds
4548
# 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
49+
FROM debian:bookworm-slim AS runstage
4750

4851
COPY --from=builder /usr/local /usr/local
4952
COPY --from=builder /opt /opt
5053

5154
RUN apt-get update && \
52-
apt-get install -y --no-install-recommends \
53-
libboost-program-options1.81.0 libboost-date-time1.81.0 libboost-iostreams1.81.0 libboost-thread1.81.0 \
54-
expat liblua5.4-0 && \
55+
apt-get install -y --no-install-recommends --no-install-suggests \
56+
expat \
57+
libboost-date-time1.81.0 \
58+
libboost-iostreams1.81.0 \
59+
libboost-program-options1.81.0 \
60+
libboost-thread1.81.0 \
61+
liblua5.4-0 \
62+
libtbb12 && \
5563
rm -rf /var/lib/apt/lists/* && \
56-
# add /usr/local/lib to ldconfig to allow loading libraries from there
64+
# Add /usr/local/lib to ldconfig to allow loading libraries from there
5765
ldconfig /usr/local/lib
5866

5967
RUN /usr/local/bin/osrm-extract --help && \
@@ -65,3 +73,4 @@ RUN /usr/local/bin/osrm-extract --help && \
6573
WORKDIR /opt
6674

6775
EXPOSE 5000
76+

0 commit comments

Comments
 (0)