From a9a45c0bcdb766a9544c63b5cad464bd9e2b3ac3 Mon Sep 17 00:00:00 2001 From: Ignacy Kajdan Date: Sun, 21 Sep 2025 14:30:38 +0200 Subject: [PATCH] feat: clean up Dockerfile and reduce image size - Replace ADD with COPY to avoid unnecessary behaviors - Install packages with --no-install-recommends to keep images slim - Clean up apt lists to reduce image size - Simplify user creation and drop redundant ARG --- Dockerfile | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 25fe157..62257ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,22 @@ FROM rust:1-slim-bookworm AS build -ARG DEBIAN_FRONTEND=noninteractive -ADD . /app WORKDIR /app -RUN apt-get update \ - && apt-get install -y pkg-config libssl-dev cmake \ - && cargo build --release +COPY . . + +RUN apt-get update && \ + apt-get install -y --no-install-recommends pkg-config libssl-dev cmake && \ + cargo build --release FROM debian:bookworm-slim -ARG DEBIAN_FRONTEND=noninteractive -RUN adduser --uid 1001 --group --no-create-home --home /app lava-gitlab-runner +RUN apt-get update && \ + apt-get install -y --no-install-recommends libssl3 ca-certificates && \ + rm -rf /var/lib/apt/lists/* && \ + groupadd -g 1001 lava-gitlab-runner && \ + useradd -u 1001 -g lava-gitlab-runner -d /app -M lava-gitlab-runner -RUN apt update && apt install -y libssl3 ca-certificates -COPY --from=build /app/target/release/lava-gitlab-runner /usr/local/bin +COPY --from=build /app/target/release/lava-gitlab-runner /usr/local/bin/ USER lava-gitlab-runner -ENTRYPOINT [ "/usr/local/bin/lava-gitlab-runner" ] +ENTRYPOINT ["/usr/local/bin/lava-gitlab-runner"]