parent
16cf5dc79b
commit
42bfc2540b
19
Dockerfile
19
Dockerfile
|
@ -1,20 +1,11 @@
|
|||
FROM rust:latest as builder
|
||||
|
||||
# Make a fake Rust app to keep a cached layer of compiled crates
|
||||
RUN USER=root cargo new app
|
||||
WORKDIR /usr/src/app
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
# Needs at least a main.rs file with a main function
|
||||
RUN mkdir src && echo "fn main(){}" > src/main.rs
|
||||
# Will build all dependent crates in release mode
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/usr/src/app/target \
|
||||
cargo build --release
|
||||
|
||||
# Copy the rest
|
||||
COPY . .
|
||||
# Build (install) the actual binaries
|
||||
RUN cargo install --path .
|
||||
# Will build and cache the binary and dependent crates in release mode
|
||||
RUN --mount=type=cache,target=/usr/local/cargo,from=rust:latest,source=/usr/local/cargo \
|
||||
--mount=type=cache,target=target \
|
||||
cargo build --release && mv ./target/release/dzmedia ./dzmedia
|
||||
|
||||
# Runtime image
|
||||
FROM debian:bullseye-slim
|
||||
|
@ -26,6 +17,6 @@ USER app
|
|||
WORKDIR /app
|
||||
|
||||
# Get compiled binaries from builder's cargo install directory
|
||||
COPY --from=builder /usr/local/cargo/bin/dzmedia /app/dzmedia
|
||||
COPY --from=builder /usr/src/app/dzmedia /app/dzmedia
|
||||
|
||||
# No CMD or ENTRYPOINT, see fly.toml with `cmd` override.
|
Loading…
Reference in New Issue