-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.test
50 lines (40 loc) · 1.31 KB
/
Dockerfile.test
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
46
47
48
49
50
# An isolated environment for tests and sanity checks on CI
FROM rust:slim-bookworm AS builder
# Rust tools
RUN rustup component add rustfmt clippy
# 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
ENV 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
RUN mkdir -p libvalhalla/src && echo '' > libvalhalla/src/lib.rs
COPY libvalhalla/Cargo.toml ./libvalhalla/
RUN cargo build
# 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
RUN touch -a -m ./libvalhalla/src/lib.rs
RUN cargo build
# Check formatting before building to avoid unnecessary rebuilds
RUN cargo fmt --all -- --check
RUN cargo clippy -- -Dwarnings
RUN cargo test