Build Docker container FROM scratch

This commit is contained in:
Jordan Doyle 2023-11-27 20:06:32 +00:00
parent 7c0bb9f220
commit c2678219d8
No known key found for this signature in database
GPG Key ID: 1EA6BAE6F66DC49A
2 changed files with 5 additions and 4 deletions

View File

@ -1 +1,2 @@
target
Dockerfile

View File

@ -1,14 +1,14 @@
FROM rust:1-slim-bookworm AS builder
RUN apt update && apt install -y libclang-dev
FROM rust:1-alpine AS builder
RUN apk add --no-cache musl-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