2024-03-25 00:12:38 +00:00
|
|
|
ARG target=x86_64-unknown-linux-musl
|
|
|
|
ENV target=$target
|
|
|
|
|
2024-03-07 01:24:36 +00:00
|
|
|
FROM lukemathwalker/cargo-chef:latest-rust-slim AS chef
|
2024-02-11 00:29:50 +00:00
|
|
|
WORKDIR /chhoto-url
|
2020-02-14 19:17:56 +00:00
|
|
|
|
2024-03-07 01:24:36 +00:00
|
|
|
FROM chef as planner
|
|
|
|
COPY ./actix/Cargo.toml ./actix/Cargo.lock .
|
|
|
|
COPY ./actix/src ./src
|
|
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
2024-02-08 17:33:26 +00:00
|
|
|
|
2024-03-07 01:24:36 +00:00
|
|
|
FROM chef as builder
|
|
|
|
RUN apt-get update && apt-get install -y musl-tools
|
|
|
|
RUN rustup target add x86_64-unknown-linux-musl
|
2020-02-14 19:17:56 +00:00
|
|
|
|
2024-03-07 01:24:36 +00:00
|
|
|
COPY --from=planner /chhoto-url/recipe.json recipe.json
|
|
|
|
# Build dependencies - this is the caching Docker layer
|
2024-03-25 00:12:38 +00:00
|
|
|
RUN cargo chef cook --release --target=$target --recipe-path recipe.json
|
2020-02-14 19:17:56 +00:00
|
|
|
|
2024-03-07 01:24:36 +00:00
|
|
|
COPY ./actix/Cargo.toml ./actix/Cargo.lock .
|
2023-04-03 03:26:23 +00:00
|
|
|
COPY ./actix/src ./src
|
2024-03-07 01:24:36 +00:00
|
|
|
# Build application
|
2024-03-25 00:12:38 +00:00
|
|
|
RUN cargo build --release --target=$target --locked --bin chhoto-url
|
2023-04-02 21:53:55 +00:00
|
|
|
|
2024-02-08 17:33:26 +00:00
|
|
|
FROM scratch
|
2024-03-25 00:12:38 +00:00
|
|
|
COPY --from=builder /chhoto-url/target/$target/release/chhoto-url /chhoto-url
|
2024-03-08 16:41:52 +00:00
|
|
|
COPY ./resources /resources
|
2024-03-07 01:24:36 +00:00
|
|
|
ENTRYPOINT ["/chhoto-url"]
|
2023-04-03 03:26:23 +00:00
|
|
|
|