thek4n.ru/Dockerfile

37 lines
1.0 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Chef
FROM rust:1.94 AS chef
RUN apt-get update && apt-get install -y --no-install-recommends musl-tools && rm -rf /var/lib/apt/lists/*
RUN rustup target add x86_64-unknown-linux-musl
RUN cargo install --locked cargo-chef
WORKDIR /app
COPY Cargo.toml Cargo.lock .
RUN mkdir src && touch src/main.rs
# Если у вас workspace или несколько крейтов, скопируйте их манифесты тоже:
# COPY crates/*/Cargo.toml ./crates/*/
RUN cargo chef prepare --recipe-path /app/recipe.json
# Builder
FROM chef AS builder
COPY --from=chef /app/recipe.json /app/recipe.json
RUN cargo chef cook --target x86_64-unknown-linux-musl --release --recipe-path /app/recipe.json
## Если есть rust-toolchain.toml
# COPY rust-toolchain.toml rust-toolchain.toml
# RUN cargo fetch
COPY . .
RUN cargo build --target x86_64-unknown-linux-musl --release
# Runtime
FROM scratch
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/example /usr/local/bin/example
CMD ["/usr/local/bin/example"]