-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile
59 lines (43 loc) · 1.61 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM rust:slim-bookworm AS builder-1
WORKDIR /app
RUN apt-get update && apt-get install --no-install-recommends -y cmake pkg-config openssl libssl-dev build-essential wget && rm -rf /var/lib/apt/lists/*;
ENV SCCACHE_VERSION=0.5.0
RUN ARCH= && alpineArch="$(dpkg --print-architecture)" \
&& case "${alpineArch##*-}" in \
amd64) \
ARCH='x86_64' \
;; \
arm64) \
ARCH='aarch64' \
;; \
*) ;; \
esac \
&& wget -O sccache.tar.gz https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-${ARCH}-unknown-linux-musl.tar.gz \
&& tar xzf sccache.tar.gz \
&& mv sccache-v*/sccache /usr/local/bin/sccache \
&& chmod +x /usr/local/bin/sccache
ENV RUSTC_WRAPPER=/usr/local/bin/sccache
RUN rustup default nightly
RUN rustup update
FROM builder-1 as builder-2
# Pre-compile dependencies
WORKDIR /build
RUN cargo init --name rust-docker
COPY Cargo.toml Cargo.lock ./
COPY rust-toolchain.toml ./
RUN --mount=type=cache,target=/root/.cache cargo fetch && \
cargo build && \
cargo build --release && \
rm src/*.rs
# Build the project
COPY src src
COPY migrations migrations
COPY .sqlx .sqlx
ENV SQLX_OFFLINE=true
RUN --mount=type=cache,target=/root/.cache touch src/main.rs && \
cargo build --release
FROM debian:bookworm-slim as release
RUN apt-get update && apt-get install --no-install-recommends -y libssl3 ca-certificates && rm -rf /var/lib/apt/lists/*;
WORKDIR /app
COPY --link --from=builder-2 /build/target/release/hzpp_delay_stats /app/hzpp_delay_stats
ENTRYPOINT ["/app/hzpp_delay_stats"]