From c2678219d8e8fcd826763b6a0485f53171bf6da2 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Mon, 27 Nov 2023 20:06:32 +0000 Subject: [PATCH] Build Docker container FROM scratch --- .dockerignore | 1 + Dockerfile | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index eb5a316..a099dca 100644 --- a/.dockerignore +++ a/.dockerignore @@ -1,1 +1,2 @@ target +Dockerfile diff --git a/Dockerfile b/Dockerfile index 0a9e759..c71b0c1 100644 --- a/Dockerfile +++ a/Dockerfile @@ -1,14 +1,14 @@ -FROM rust:1-slim-bookworm AS builder +FROM rust:1-alpine AS builder +RUN apk add --no-cache musl-dev -RUN apt update && apt install -y libclang-dev - COPY . /sources WORKDIR /sources RUN cargo build --release RUN chown nobody:nogroup /sources/target/release/bin -FROM gcr.io/distroless/cc-debian12 +FROM scratch COPY --from=builder /sources/target/release/bin /pastebin +COPY --from=builder /etc/passwd /etc/passwd USER nobody EXPOSE 8000 -- rgit 0.1.3