This repository was archived by the owner on Jul 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (36 loc) · 1.33 KB
/
Dockerfile
File metadata and controls
46 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# https://github.com/skerkour/kerkour.com/blob/main/2021/2021_04_06_rust_minimal_docker_image/myip/Dockerfile.scratch
####################################################################################################
## Builder image
####################################################################################################
FROM rust:latest AS builder
WORKDIR /s3d
RUN rustup target add x86_64-unknown-linux-musl
RUN apt update && apt install -y musl-tools musl-dev
RUN update-ca-certificates
# Create user
ENV USER=s3d
ENV UID=10001
RUN adduser \
--uid "${UID}" \
--home "/s3d" \
--shell "/sbin/nologin" \
--gecos "" \
--no-create-home \
--disabled-password \
"${USER}"
COPY ./ .
ENV CARGO_BUILD_TARGET="x86_64-unknown-linux-musl"
RUN make RELEASE=1
####################################################################################################
## Final image
####################################################################################################
FROM scratch
WORKDIR /s3d
# Copy files from builder image
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /s3d/target/x86_64-unknown-linux-musl/release/s3d ./
COPY --from=builder /s3d/target/x86_64-unknown-linux-musl/release/s3 ./
# Use an unprivileged user
USER s3d:s3d
CMD ["/s3d/s3d"]