File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 11# Start with the official Golang image for building the binary
2- FROM golang:1.23 as builder
2+ FROM --platform=${TARGETPLATFORM} golang:1.23 as builder
33
44# Set the working directory inside the container
55WORKDIR /app
66
7+ ENV CGO_ENABLED=0
8+
79# Copy go.mod and go.sum first to cache dependencies
810COPY go.mod go.sum ./
9- RUN go mod download
11+ RUN go mod download -x
1012
1113# Copy the source code
1214COPY . .
1315
1416# Build the application
15- RUN go build -o vmhub5_exporter .
17+ # RUN go build -ldflags="-s -w" -o vmhub5_exporter .
18+ RUN go build -ldflags="-s -w -extldflags '-static'" -o vmhub5_exporter .
19+
1620
1721# Start a new minimal image for running the application
18- FROM alpine:latest
22+ FROM --platform=${TARGETPLATFORM} alpine:latest
1923
2024# Install CA certificates to allow HTTPS connections
2125RUN apk --no-cache add ca-certificates
2226
2327# Copy the compiled binary from the builder stage
24- COPY --from=builder /app/vmhub5_exporter /usr/local/bin/vmhub5_exporter
28+ COPY --chmod=755 -- from=builder /app/vmhub5_exporter /usr/local/bin/vmhub5_exporter
2529
2630# Set the port the container will expose
2731EXPOSE 8080
Original file line number Diff line number Diff line change 1- linux/arm/v7
21linux/arm64
32linux/amd64
Original file line number Diff line number Diff line change 1- 0.0.0.2
1+ 0.0.0.5
You can’t perform that action at this time.
0 commit comments