Skip to content

Commit 752b2e6

Browse files
authored
feat(docker): migrate base image from Alpine to Debian (#7606)
1 parent e0f3220 commit 752b2e6

7 files changed

Lines changed: 35 additions & 51 deletions

File tree

.github/workflows/osrm-backend-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
if: github.repository == 'Project-OSRM/osrm-backend'
1919
strategy: &docker-base-image-matrix
2020
matrix:
21-
docker-base-image: ["alpine"]
21+
docker-base-image: ["debian"]
2222
runs-on: ubuntu-latest
2323
steps:
2424
- name: Check out the repo

.github/workflows/osrm-backend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
docker-build-extract-test:
216216
strategy:
217217
matrix:
218-
docker-base-image: ['alpine']
218+
docker-base-image: ['debian']
219219
needs: [format-taginfo-docs, vcpkg-smoke-prereq]
220220
if: github.repository == 'Project-OSRM/osrm-backend'
221221
runs-on: ubuntu-latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ If you want to use the CH pipeline instead replace `osrm-partition` and `osrm-cu
6262

6363
### Using Docker
6464

65-
We base our Docker images ([backend](https://github.com/Project-OSRM/osrm-backend/pkgs/container/osrm-backend), [frontend](https://hub.docker.com/r/osrm/osrm-frontend/)) on Alpine Linux and make sure they are as lightweight as possible. Older backend versions can be found on [Docker Hub](https://hub.docker.com/r/osrm/osrm-backend/).
65+
We base our Docker images ([backend](https://github.com/Project-OSRM/osrm-backend/pkgs/container/osrm-backend), [frontend](https://hub.docker.com/r/osrm/osrm-frontend/)) on Debian Linux and make sure they are as lightweight as possible. Older backend versions can be found on [Docker Hub](https://hub.docker.com/r/osrm/osrm-backend/).
6666

6767
Download OpenStreetMap extracts for example from [Geofabrik](http://download.geofabrik.de/)
6868

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Dockerfile-alpine
1+
Dockerfile-debian
Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,36 @@
11
# syntax=docker/dockerfile:1.7
2-
FROM alpine:3.23.4 AS alpine-mimalloc
3-
4-
RUN apk update && \
5-
apk upgrade && \
6-
apk add --no-cache mimalloc
7-
8-
ENV LD_PRELOAD=/usr/lib/libmimalloc.so.2
9-
ENV MIMALLOC_LARGE_OS_PAGES=1
10-
11-
12-
FROM alpine-mimalloc AS builder
2+
FROM debian:trixie-slim AS builder
133
ARG DOCKER_TAG
144
ARG BUILD_CONCURRENCY
155
# Pinned vcpkg baseline; keep in sync with vcpkg-configuration.json at the repo root.
16-
ARG VCPKG_COMMIT=d015e31e90838a4c9dfa3eed45979bc70d9357fc
6+
ARG VCPKG_COMMIT=c3867e714dd3a51c272826eea77267876517ed99
177

18-
# vcpkg needs system-provided build tools on musl — VCPKG_FORCE_SYSTEM_BINARIES
19-
# prevents it from downloading glibc-built cmake/ninja that would fail on Alpine.
20-
RUN apk add --no-cache \
8+
RUN apt-get update && \
9+
apt-get -y --no-install-recommends --no-install-suggests install \
2110
autoconf \
2211
automake \
23-
bash \
24-
build-base \
12+
build-essential \
2513
ca-certificates \
2614
ccache \
2715
cmake \
2816
curl \
29-
curl-dev \
30-
g++ \
31-
gcc \
3217
git \
3318
libtool \
34-
linux-headers \
3519
make \
36-
musl-dev \
37-
ninja \
38-
perl \
39-
pkgconfig \
20+
ninja-build \
21+
pkg-config \
4022
tar \
4123
unzip \
42-
zip
24+
zip && \
25+
rm -rf /var/lib/apt/lists/*
4326

4427
# NOTE: VCPKG_ROOT lives outside /opt so the runstage's COPY --from=builder /opt
4528
# /opt doesn't drag the ~5 GB vcpkg tree along.
4629
ENV VCPKG_ROOT=/vcpkg \
4730
VCPKG_FORCE_SYSTEM_BINARIES=1
48-
RUN git clone --no-checkout https://github.com/microsoft/vcpkg.git ${VCPKG_ROOT} && \
49-
git -C ${VCPKG_ROOT} checkout ${VCPKG_COMMIT} && \
31+
RUN mkdir -p ${VCPKG_ROOT} && \
32+
curl -fsSL https://github.com/microsoft/vcpkg/archive/${VCPKG_COMMIT}.tar.gz | \
33+
tar -xz --strip-components=1 -C ${VCPKG_ROOT} && \
5034
${VCPKG_ROOT}/bootstrap-vcpkg.sh -disableMetrics
5135

5236
WORKDIR /src
@@ -82,10 +66,13 @@ RUN --mount=type=cache,target=/root/.cache/vcpkg/archives,sharing=locked \
8266
--clean-buildtrees-after-build \
8367
--clean-packages-after-build
8468

69+
# Now copy the rest of the source tree. This layer is the one that gets
70+
# invalidated by code changes — everything above stays cached.
8571
COPY . /src
8672

8773
RUN --mount=type=cache,target=/root/.ccache \
8874
NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \
75+
export CXXFLAGS="-Wno-array-bounds -Wno-uninitialized -Wno-stringop-overflow" && \
8976
export CCACHE_DIR=/root/.ccache && \
9077
export CCACHE_MAXSIZE=2G && \
9178
export CCACHE_COMPRESSLEVEL=6 && \
@@ -102,11 +89,16 @@ RUN --mount=type=cache,target=/root/.ccache \
10289
-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake \
10390
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
10491
-DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} \
105-
-DENABLE_LTO=OFF \
92+
-DENABLE_LTO=On \
10693
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
10794
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache && \
10895
ninja -j${NPROC} install && \
10996
ccache -s && \
97+
# Copy the TBB shared lib out of vcpkg so the runstage image can load it
98+
# without bringing in the whole vcpkg tree. Boost, expat, bzip2, lua, fmt
99+
# etc. all link statically under the x64-linux triplet, so only TBB needs
100+
# runtime shipping. In manifest mode vcpkg installs per-build under
101+
# build/vcpkg_installed/<triplet>/, not $VCPKG_ROOT/installed/.
110102
mkdir -p /opt/vcpkg-runtime-libs && \
111103
find vcpkg_installed -name 'libtbb*.so*' -exec cp -a {} /opt/vcpkg-runtime-libs/ \; && \
112104
cd ../profiles && \
@@ -116,18 +108,20 @@ RUN --mount=type=cache,target=/root/.ccache \
116108

117109

118110
# Multistage build to reduce image size - https://docs.docker.com/build/building/multi-stage/#use-multi-stage-builds
119-
# Only the content below ends up in the image, this helps remove /src from the image (which is large)
120-
FROM alpine-mimalloc AS runstage
111+
# Only the content below ends up in the image, this helps remove /src and vcpkg from the image.
112+
FROM debian:trixie-slim AS runstage
121113

122114
COPY --from=builder /usr/local /usr/local
123115
COPY --from=builder /opt /opt
124116
COPY --from=builder /opt/vcpkg-runtime-libs/ /usr/local/lib/
125117

126-
RUN apk add --no-cache \
127-
libcap-setcap \
128-
libgcc \
129-
libstdc++ && \
130-
ldconfig /usr/local/lib || true
118+
RUN apt-get update && \
119+
apt-get install -y --no-install-recommends --no-install-suggests \
120+
libgcc-s1 \
121+
libstdc++6 && \
122+
rm -rf /var/lib/apt/lists/* && \
123+
# Add /usr/local/lib to ldconfig so TBB (and any other shared vcpkg libs) load
124+
ldconfig /usr/local/lib
131125

132126
RUN /usr/local/bin/osrm-extract --help && \
133127
/usr/local/bin/osrm-routed --help && \
@@ -137,4 +131,4 @@ RUN /usr/local/bin/osrm-extract --help && \
137131

138132
WORKDIR /opt
139133

140-
EXPOSE 5000
134+
EXPOSE 5000

docker/hooks/build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@
1010
DOCKER_BUILD="docker build --build-arg BUILD_CONCURRENCY=${CONCURRENCY} --build-arg DOCKER_TAG=${DOCKER_TAG:?unset} -t ${IMAGE_NAME:?unset} -f"
1111

1212
$DOCKER_BUILD Dockerfile ..
13-
$DOCKER_BUILD Dockerfile-alpine ..

src/python/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@ sudo dnf install -y \
5050
tbb-devel libxml2-devel libzip-devel
5151
```
5252

53-
**Alpine**
54-
55-
```
56-
apk add --no-cache \
57-
cmake clang make git pkgconf \
58-
boost-dev bzip2-dev lua5.4-dev \
59-
onetbb-dev libxml2-dev libzip-dev expat-dev
60-
```
61-
6253
**macOS (Homebrew)**
6354

6455
```

0 commit comments

Comments
 (0)