-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
22 lines (17 loc) · 761 Bytes
/
Dockerfile
File metadata and controls
22 lines (17 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
FROM golang:1.24-bookworm AS build-env
RUN go env -w GOCACHE=/go-cache
RUN go env -w GOMODCACHE=/gomod-cache
WORKDIR /go/src/cloud-carbon-exporter
COPY . .
RUN --mount=type=cache,target=/gomod-cache --mount=type=cache,target=/go-cache \
go install honnef.co/go/tools/cmd/staticcheck@latest \
&& go mod download \
&& go vet ./... \
&& staticcheck ./... \
&& go test -v ./... \
&& go build -o /cloud-carbon-exporter -ldflags="-s -w" github.com/superdango/cloud-carbon-exporter/cmd
# Final stage
FROM gcr.io/distroless/cc-debian12:nonroot
ARG TARGET_NAME=cloud-carbon-exporter
COPY --from=build-env /cloud-carbon-exporter /usr/local/bin/cloud-carbon-exporter
ENTRYPOINT ["/usr/local/bin/cloud-carbon-exporter"]