This repository was archived by the owner on May 14, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +78
-9
lines changed Expand file tree Collapse file tree 3 files changed +78
-9
lines changed Original file line number Diff line number Diff line change @@ -59,15 +59,12 @@ COPY third_party/ third_party/
5959# build metacontroller binary
6060RUN make bins
6161
62- # Use debian as minimal base image to package the final binary
63- FROM debian:stretch-slim
62+ # Use a distroless image
63+ # Sort the instructions to be more effective for caching
6464
65- WORKDIR /
66-
67- RUN apt-get update && \
68- apt-get install --no-install-recommends -y ca-certificates && \
69- rm -rf /var/lib/apt/lists/*
70-
71- COPY --from=builder /go/src/openebs.io/metac/metac /usr/bin/
65+ FROM gcr.io/distroless/base-debian10:nonroot
7266
67+ WORKDIR /
68+ USER nonroot:nonroot
7369CMD ["/usr/bin/metac" ]
70+ COPY --from=builder --chown=nonroot /go/src/openebs.io/metac/metac /usr/bin/
Original file line number Diff line number Diff line change 1+ # Tester image
2+ FROM golang:1.13.5 as tester
3+
4+ WORKDIR /go/src/openebs.io/metac/
5+
6+ # copy go modules manifests
7+ COPY go.mod go.mod
8+ COPY go.sum go.sum
9+
10+ # copy build manifests
11+ COPY Makefile Makefile
12+
13+ # ensure vendoring is up-to-date by running make vendor in your local
14+ # setup
15+ #
16+ # we cache the vendored dependencies before building and copying source
17+ # so that we don't need to re-download when source changes don't invalidate
18+ # our downloaded layer
19+ RUN make vendor
20+
21+ # copy build manifests
22+ COPY . .
23+
24+ RUN make integration-test
25+
26+ # Build metac binary
27+ FROM golang:1.13.5 as builder
28+
29+ WORKDIR /go/src/openebs.io/metac/
30+
31+ # copy go modules manifests
32+ COPY go.mod go.mod
33+ COPY go.sum go.sum
34+
35+ # copy build manifests
36+ COPY Makefile Makefile
37+
38+ # ensure vendoring is up-to-date by running make vendor in your local
39+ # setup
40+ #
41+ # we cache the vendored dependencies before building and copying source
42+ # so that we don't need to re-download when source changes don't invalidate
43+ # our downloaded layer
44+ RUN make vendor
45+
46+ # copy source files
47+ COPY *.go ./
48+ COPY apis/ apis/
49+ COPY client/ client/
50+ COPY config/ config/
51+ COPY hack/ hack/
52+ COPY controller/ controller/
53+ COPY dynamic/ dynamic/
54+ COPY hooks/ hooks/
55+ COPY server/ server/
56+ COPY start/ start/
57+ COPY third_party/ third_party/
58+
59+ # build metacontroller binary
60+ RUN make bins
61+
62+ # Use a distroless image
63+ # Sort the instructions to be more effective for caching
64+
65+ FROM gcr.io/distroless/base-debian10:debug-nonroot
66+
67+ WORKDIR /
68+ USER nonroot:nonroot
69+ CMD ["/usr/bin/metac"]
70+ COPY --from=builder --chown=nonroot /go/src/openebs.io/metac/metac /usr/bin/
Original file line number Diff line number Diff line change @@ -71,10 +71,12 @@ vendor: go.mod go.sum
7171.PHONY : image
7272image :
7373 docker build -t $(REGISTRY ) /$(IMG_NAME ) :$(PACKAGE_VERSION ) .
74+ docker build -t $(REGISTRY ) /$(IMG_NAME ) :$(PACKAGE_VERSION ) _debug -f Dockerfile.debug .
7475
7576.PHONY : push
7677push : image
7778 docker push $(REGISTRY ) /$(IMG_NAME ) :$(PACKAGE_VERSION )
79+ docker push $(REGISTRY ) /$(IMG_NAME ) :$(PACKAGE_VERSION ) _debug
7880
7981.PHONY : unit-test
8082unit-test : generated_files
You can’t perform that action at this time.
0 commit comments