-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
executable file
·47 lines (36 loc) · 1.47 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
ARG ARCHITECTURE
#######################################################################################################################
# Build static binary
#######################################################################################################################
FROM multiarch/alpine:${ARCHITECTURE}-v3.11 as builder
# Add unprivileged user
RUN echo nfs-client-provisioner:x:1000:1000:nfs-client-provisioner:/: > /etc_passwd
# eudev: needed for udevadm binary
RUN apk --no-cache add \
git \
build-base \
go \
upx
# Add nfs-client-provisioner
COPY nfs-client /nfs-client
WORKDIR /nfs-client
# Build like the makefile: https://github.com/kubernetes-incubator/external-storage/blob/master/nfs-client/Makefile#L30
RUN go build -a -ldflags '-extldflags -static' provisioner.go
# Minify binaries
# no upx: 50.5M
# --best: 31.6M
# --brute: does not work
RUN upx --best provisioner && \
upx -t provisioner
#######################################################################################################################
# Final scratch image
#######################################################################################################################
FROM scratch
# Add description
LABEL org.label-schema.description="NFS Client Provisioner for Kubernetes"
# Copy the unprivileged user
COPY --from=builder /etc_passwd /etc/passwd
# Add provisioner
COPY --from=builder /nfs-client/provisioner /provisioner
USER nfs-client-provisioner
ENTRYPOINT ["/provisioner"]