From de44838f3a616d66e646292cc304a39d7f756a85 Mon Sep 17 00:00:00 2001 From: Peter Zam Date: Sun, 23 Jun 2024 12:10:37 +0000 Subject: [PATCH 1/2] change image to scratch & build image to alpine --- Dockerfile | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0a6c07e..716e51a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,17 @@ -FROM rust:slim as BUILD +FROM rust:alpine as BUILD -WORKDIR /app/ +RUN apk add --no-cache nasm git g++ -COPY . . +RUN git clone https://github.com/TeamPiped/piped-proxy.git /app -RUN --mount=type=cache,target=/var/cache/apt \ - apt-get update && \ - apt-get install -y --no-install-recommends \ - nasm && \ - rm -rf /var/lib/apt/lists/* +WORKDIR /app RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/app/target/ \ - cargo build --release && \ - mv target/release/piped-proxy . - -FROM debian:stable-slim + cargo build --release --target=$(rustc -vV | grep host | cut -d ' ' -f2) && \ + mv target/$(rustc -vV | grep host | cut -d ' ' -f2)/release/piped-proxy . -RUN --mount=type=cache,target=/var/cache/apt \ - apt-get update && \ - apt-get install -y --no-install-recommends \ - ca-certificates && \ - rm -rf /var/lib/apt/lists/* +FROM scratch WORKDIR /app/ From 578bb48283c1669e00847124c93a32c3dc470f03 Mon Sep 17 00:00:00 2001 From: Peter Zam Date: Mon, 24 Jun 2024 13:51:50 +0000 Subject: [PATCH 2/2] rm build target specifier --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 716e51a..06dbb79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,12 +8,12 @@ WORKDIR /app RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/app/target/ \ - cargo build --release --target=$(rustc -vV | grep host | cut -d ' ' -f2) && \ - mv target/$(rustc -vV | grep host | cut -d ' ' -f2)/release/piped-proxy . + cargo build --release && \ + mv target/release/piped-proxy . FROM scratch -WORKDIR /app/ +WORKDIR /app COPY --from=BUILD /app/piped-proxy .