Skip to content

Commit 30318d6

Browse files
committed
Use Alpine image
1 parent 4750231 commit 30318d6

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

Dockerfile

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
# Build the manager binary
21
FROM golang:1.13 as builder
32

43
WORKDIR /workspace
5-
# Copy the Go Modules manifests
4+
5+
# copy modules manifests
66
COPY go.mod go.mod
77
COPY go.sum go.sum
8-
# cache deps before building and copying source so that we don't need to re-download as much
9-
# and so that source changes don't invalidate our downloaded layer
8+
9+
# cache modules
1010
RUN go mod download
1111

12-
# Copy the go source
12+
# copy source code
1313
COPY main.go main.go
1414
COPY api/ api/
1515
COPY controllers/ controllers/
16+
COPY pkg/ pkg/
17+
18+
# build
19+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o source-watcher main.go
20+
21+
FROM alpine:3.12
22+
23+
RUN apk add --no-cache ca-certificates tini
24+
25+
COPY --from=builder /workspace/source-watcher /usr/local/bin/
1626

17-
# Build
18-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
27+
RUN addgroup -S controller && adduser -S -g controller controller
1928

20-
# Use distroless as minimal base image to package the manager binary
21-
# Refer to https://github.com/GoogleContainerTools/distroless for more details
22-
FROM gcr.io/distroless/static:nonroot
23-
WORKDIR /
24-
COPY --from=builder /workspace/manager .
25-
USER nonroot:nonroot
29+
USER controller
2630

27-
ENTRYPOINT ["/manager"]
31+
ENTRYPOINT [ "/sbin/tini", "--", "source-watcher" ]

0 commit comments

Comments
 (0)