2024-03-25 01:00:25 -05:00
|
|
|
FROM lukemathwalker/cargo-chef:latest-rust-slim AS chef
|
|
|
|
WORKDIR /chhoto-url
|
|
|
|
|
|
|
|
FROM chef as planner
|
|
|
|
COPY ./actix/Cargo.toml ./actix/Cargo.lock .
|
|
|
|
COPY ./actix/src ./src
|
|
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
|
|
|
|
|
|
|
FROM chef as builder
|
2024-03-25 01:10:09 -05:00
|
|
|
ARG target=x86_64-unknown-linux-musl
|
2024-03-25 01:00:25 -05:00
|
|
|
RUN apt-get update && apt-get install -y musl-tools
|
2024-03-25 01:10:09 -05:00
|
|
|
RUN rustup target add $target
|
2024-03-25 01:00:25 -05:00
|
|
|
|
|
|
|
COPY --from=planner /chhoto-url/recipe.json recipe.json
|
|
|
|
# Build dependencies - this is the caching Docker layer
|
2024-03-25 01:10:09 -05:00
|
|
|
RUN cargo chef cook --release --target=$target --recipe-path recipe.json
|
2024-03-25 01:00:25 -05:00
|
|
|
|
|
|
|
COPY ./actix/Cargo.toml ./actix/Cargo.lock .
|
|
|
|
COPY ./actix/src ./src
|
|
|
|
# Build application
|
2024-03-25 01:10:09 -05:00
|
|
|
RUN cargo build --release --target=$target --locked --bin chhoto-url
|
2024-03-25 01:00:25 -05:00
|
|
|
|
|
|
|
FROM scratch
|
2024-03-25 01:10:09 -05:00
|
|
|
COPY --from=builder /chhoto-url/target/$target/release/chhoto-url /chhoto-url
|
2024-03-25 01:00:25 -05:00
|
|
|
COPY ./resources /resources
|
|
|
|
ENTRYPOINT ["/chhoto-url"]
|