-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
50 lines (37 loc) · 1.35 KB
/
Dockerfile
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
47
48
49
50
###################################################################################
## Builder
###################################################################################
FROM rust:alpine3.20 AS builder
ENV OPENSSL_STATIC=1
# RUN rustup target add x86_64-unknown-linux-musl
# RUN apt update && apt install -y musl-tools musl-dev pkg-config libssl-dev upx make
RUN apk update && apk add --no-cache musl-dev openssl-dev openssl-libs-static upx
RUN update-ca-certificates
# Create appuser
ENV USER=rust
ENV UID=1001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
WORKDIR /workdir
COPY ./ .
RUN cargo build --target x86_64-unknown-linux-musl --release
RUN upx --best --lzma target/x86_64-unknown-linux-musl/release/az-group-manager
###################################################################################
## Final image
###################################################################################
FROM scratch
WORKDIR /
# Copy from builder.
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
COPY --from=builder /workdir/target/x86_64-unknown-linux-musl/release/az-group-manager/ /
# Use an unprivileged user.
USER 1001:1001
ENTRYPOINT ["./az-group-manager"]