Skip to content

Commit

Permalink
Use Alpine as container image
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Jul 9, 2020
1 parent b94dcca commit 14e5bd9
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
# Build the manager binary
FROM golang:1.13 as builder

WORKDIR /workspace
# Copy the Go Modules manifests

# copy modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer

# cache modules
RUN go mod download

# Copy the go source
# copy source code
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
# build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o helm-controller main.go

FROM alpine:3.12

RUN apk add --no-cache ca-certificates tini

COPY --from=builder /workspace/helm-controller /usr/local/bin/

RUN addgroup -S controller && adduser -S -g controller controller

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

ENTRYPOINT ["/manager"]
ENTRYPOINT [ "/sbin/tini", "--", "helm-controller" ]

0 comments on commit 14e5bd9

Please sign in to comment.