From 59f679a1c2df7b7b5cd5fd623347cd5a4ee174c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abd=C3=BCrrahim=20YILMAZ?= Date: Wed, 28 Aug 2024 03:04:37 +0300 Subject: [PATCH 1/3] fix: copy destination path Error message before the fix: Step 4/19 : COPY ./actix/Cargo.toml ./actix/Cargo.lock . When using COPY with more than one source file, the destination must be a directory and end with a / --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b04f42a..a4bdc1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ 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/Cargo.toml ./actix/Cargo.lock ./ COPY ./actix/src ./src RUN cargo chef prepare --recipe-path recipe.json @@ -18,7 +18,7 @@ COPY --from=planner /chhoto-url/recipe.json recipe.json # Build dependencies - this is the caching Docker layer RUN cargo chef cook --release --target=$target --recipe-path recipe.json -COPY ./actix/Cargo.toml ./actix/Cargo.lock . +COPY ./actix/Cargo.toml ./actix/Cargo.lock ./ COPY ./actix/src ./src # Build application RUN cargo build --release --target=$target --locked --bin chhoto-url From 855145d4d7e3ac12b38359564e98f0d70a226a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abd=C3=BCrrahim=20YILMAZ?= Date: Wed, 28 Aug 2024 03:12:33 +0300 Subject: [PATCH 2/3] fix: argument was not being passed Argument was not being passed, although it is declared. So changed to a static path in "FROM scratch" part Error message before the fix: Step 17/19 : COPY --from=builder /chhoto-url/target/$target/release/chhoto-url /chhoto-url COPY failed: stat chhoto-url/target//release/chhoto-url: file does not exist --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a4bdc1a..05482af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,9 @@ COPY ./actix/Cargo.toml ./actix/Cargo.lock ./ COPY ./actix/src ./src # Build application RUN cargo build --release --target=$target --locked --bin chhoto-url +RUN cp /chhoto-url/target/$target/release/chhoto-url /chhoto-url/release FROM scratch -COPY --from=builder /chhoto-url/target/$target/release/chhoto-url /chhoto-url +COPY --from=builder /chhoto-url/release /chhoto-url COPY ./resources /resources ENTRYPOINT ["/chhoto-url"] From 4a8b62446c9ce8d2384951234fa650538f920300 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Wed, 28 Aug 2024 11:37:45 -0500 Subject: [PATCH 3/3] fix: Case mismatch --- Dockerfile | 4 ++-- Dockerfile.multiarch | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 05482af..e8ac570 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,12 @@ FROM lukemathwalker/cargo-chef:latest-rust-slim AS chef WORKDIR /chhoto-url -FROM chef as planner +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 +FROM chef AS builder ARG target=x86_64-unknown-linux-musl RUN apt-get update && apt-get install -y musl-tools RUN rustup target add $target diff --git a/Dockerfile.multiarch b/Dockerfile.multiarch index fdad813..a5b079a 100644 --- a/Dockerfile.multiarch +++ b/Dockerfile.multiarch @@ -1,13 +1,13 @@ # SPDX-FileCopyrightText: 2023 Sayantan Santra # SPDX-License-Identifier: MIT -FROM scratch as builder-amd64 +FROM scratch AS builder-amd64 COPY ./actix/target/x86_64-unknown-linux-musl/release/chhoto-url /chhoto-url -FROM scratch as builder-arm64 +FROM scratch AS builder-arm64 COPY ./actix/target/aarch64-unknown-linux-musl/release/chhoto-url /chhoto-url -FROM scratch as builder-arm +FROM scratch AS builder-arm COPY ./actix/target/armv7-unknown-linux-musleabihf/release/chhoto-url /chhoto-url ARG TARGETARCH