38 lines
1.1 KiB
Docker
38 lines
1.1 KiB
Docker
# 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 должен содержать
|
||
## targets = ["x86_64-unknown-linux-musl"]
|
||
COPY 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/thek4n-ru /usr/local/bin/thek4n-ru
|
||
|
||
CMD ["/usr/local/bin/thek4n-ru", "--host", "0.0.0.0", "--port", "80", "--config", "/configs/config.toml"]
|