-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (39 loc) · 1.37 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
FROM rust:slim-bookworm AS builder
# System dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
# Required for tokio and reqwest via `openssl-sys`
libssl-dev \
pkg-config \
# For some reason GCC fails to compile valhalla so we use clang instead
clang \
# Valhalla build dependencies
build-essential \
cmake \
libboost-dev \
liblz4-dev \
libprotobuf-dev \
protobuf-compiler \
zlib1g-dev
ENV CC=clang CXX=clang++
WORKDIR /usr/src/app
# First build a dummy target to cache dependencies in a separate Docker layer
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo 'fn main() { println!("Dummy image called!"); }' > src/main.rs
# And for every other target in the workspace
COPY libvalhalla/Cargo.toml ./libvalhalla/
RUN mkdir -p libvalhalla/src && touch libvalhalla/src/lib.rs
RUN cargo build --release
# Now build the real target
COPY src ./src
COPY libvalhalla ./libvalhalla
# Update modified attribute as otherwise cargo won't rebuild it
RUN touch -a -m ./src/main.rs ./libvalhalla/src/lib.rs
RUN cargo build --release
FROM debian:bookworm-slim AS runner
# Web page with map
WORKDIR /usr
COPY web ./web
# Runtime dependency for tokio and reqwest
RUN apt-get update && apt-get install -y --no-install-recommends libssl3
COPY --from=builder /usr/src/app/target/release/valhalla-debug /usr/local/bin/valhalla-debug
ENTRYPOINT ["valhalla-debug"]