2024-04-04 01:40:26 +00:00
|
|
|
# SPDX-FileCopyrightText: 2023 Sayantan Santra <sayantan.santra689@gmail.com>
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2024-03-25 06:00:25 +00:00
|
|
|
FROM lukemathwalker/cargo-chef:latest-rust-slim AS chef
|
|
|
|
WORKDIR /chhoto-url
|
|
|
|
|
|
|
|
FROM chef as planner
|
2024-08-28 00:04:37 +00:00
|
|
|
COPY ./actix/Cargo.toml ./actix/Cargo.lock ./
|
2024-03-25 06:00:25 +00:00
|
|
|
COPY ./actix/src ./src
|
|
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
|
|
|
|
|
|
|
FROM chef as builder
|
2024-03-25 06:10:09 +00:00
|
|
|
ARG target=x86_64-unknown-linux-musl
|
2024-03-25 06:00:25 +00:00
|
|
|
RUN apt-get update && apt-get install -y musl-tools
|
2024-03-25 06:10:09 +00:00
|
|
|
RUN rustup target add $target
|
2024-03-25 06:00:25 +00:00
|
|
|
|
|
|
|
COPY --from=planner /chhoto-url/recipe.json recipe.json
|
|
|
|
# Build dependencies - this is the caching Docker layer
|
2024-03-25 06:10:09 +00:00
|
|
|
RUN cargo chef cook --release --target=$target --recipe-path recipe.json
|
2024-03-25 06:00:25 +00:00
|
|
|
|
2024-08-28 00:04:37 +00:00
|
|
|
COPY ./actix/Cargo.toml ./actix/Cargo.lock ./
|
2024-03-25 06:00:25 +00:00
|
|
|
COPY ./actix/src ./src
|
|
|
|
# Build application
|
2024-03-25 06:10:09 +00:00
|
|
|
RUN cargo build --release --target=$target --locked --bin chhoto-url
|
2024-08-28 00:12:33 +00:00
|
|
|
RUN cp /chhoto-url/target/$target/release/chhoto-url /chhoto-url/release
|
2024-03-25 06:00:25 +00:00
|
|
|
|
|
|
|
FROM scratch
|
2024-08-28 00:12:33 +00:00
|
|
|
COPY --from=builder /chhoto-url/release /chhoto-url
|
2024-03-25 06:00:25 +00:00
|
|
|
COPY ./resources /resources
|
|
|
|
ENTRYPOINT ["/chhoto-url"]
|