forseti/Dockerfile

29 lines
812 B
Docker
Raw Normal View History

2022-01-24 15:10:14 +00:00
# Build the manager binary
2022-10-12 11:01:55 +00:00
FROM golang:alpine as builder
2022-01-24 15:10:14 +00:00
WORKDIR /workspace
# Copy the Go 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
RUN go mod download
# Copy the go source
COPY main.go main.go
2022-10-12 11:01:55 +00:00
# COPY api/ api/
2022-01-24 15:10:14 +00:00
COPY controllers/ controllers/
2022-10-12 11:01:55 +00:00
COPY pkg/ pkg/
2022-01-24 15:10:14 +00:00
# Build
2022-10-12 11:01:55 +00:00
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -a -o forseti main.go
2022-01-24 15:10:14 +00:00
# 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 /
2022-10-12 11:01:55 +00:00
COPY --from=builder /workspace/forseti .
2022-01-24 15:10:14 +00:00
USER 65532:65532
2022-10-12 11:01:55 +00:00
ENTRYPOINT ["/forseti"]