-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
85 lines (67 loc) · 2.08 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# --------------------------
# Test cstorpoolauto binary
# --------------------------
FROM golang:1.13.5 as tester
LABEL type=intermediate-container
WORKDIR /mayadata.io/cstorpoolauto/
# copy go modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# ensure vendoring is up-to-date by running make vendor
# in your local setup
#
# we cache the vendored dependencies before building and
# copying source so that we don't need to re-download when
# source changes don't invalidate our downloaded layer
RUN go mod download
RUN go mod tidy
RUN go mod vendor
# copy build manifests
COPY Makefile Makefile
# copy source files
COPY cmd/ cmd/
COPY unstruct/ unstruct/
COPY types/ types/
COPY common/ common/
COPY controller/ controller/
# test cstorpoolauto
RUN make test
# --------------------------
# Build cstorpoolauto binary
# --------------------------
FROM golang:1.13.5 as builder
LABEL type=intermediate-container
WORKDIR /mayadata.io/cstorpoolauto/
# copy go modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# ensure vendoring is up-to-date by running make vendor
# in your local setup
#
# we cache the vendored dependencies before building and
# copying source so that we don't need to re-download when
# source changes don't invalidate our downloaded layer
RUN go mod download
RUN go mod tidy
# copy build manifests
COPY Makefile Makefile
# copy source files
COPY cmd/ cmd/
COPY unstruct/ unstruct/
COPY types/ types/
COPY common/ common/
COPY controller/ controller/
# build cstorpoolauto binary
RUN make cstorpoolauto
# ---------------------------
# Use distroless as minimal base image to package the final binary
# Refer https://github.com/GoogleContainerTools/distroless
# ---------------------------
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY config/metac.yaml /etc/config/metac/metac.yaml
COPY config/localdevice/metac.yaml /etc/config/metac/localdevice/metac.yaml
COPY config/localdevice/v1alpha1/metac.yaml /etc/config/metac/localdevice/v1alpha1/metac.yaml
COPY --from=builder /mayadata.io/cstorpoolauto/cstorpoolauto /usr/bin/
USER nonroot:nonroot
CMD ["/usr/bin/cstorpoolauto"]