-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
32 lines (24 loc) · 970 Bytes
/
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
FROM rust:latest AS chef
RUN rustup default nightly
RUN cargo -Z sparse-registry install cargo-chef
WORKDIR /music-srv
FROM chef AS planner
COPY ./src ./src
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /music-srv/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json -Z sparse-registry
# Build application
COPY ./src ./src
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
RUN cargo -Z sparse-registry build --release --bin music-srv
RUN objcopy --compress-debug-sections ./target/release/music-srv ./target/release/music-srv-small
FROM debian:11-slim AS runtime
WORKDIR /music-srv
COPY --from=builder /music-srv/target/release/music-srv-small ./music-srv
LABEL org.opencontainers.image.source="https://github.com/chrisheib/rs_music_server"
CMD ["./music-srv"]