-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (25 loc) · 791 Bytes
/
Dockerfile
File metadata and controls
36 lines (25 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
FROM golang:alpine AS builder
# Install git and necessary packages
RUN apk add --no-cache git ca-certificates
# Set the working directory
WORKDIR /app
# Download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code
COPY . .
# Build the application statically
RUN CGO_ENABLED=0 GOOS=linux go build -o prometheus-fe2-exporter .
# Stage 2: Runtime
FROM scratch
# Copy the CA certificates from the builder stage
# This is crucial for validating SSL/TLS connections
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Use a non-root user
USER 1000:1000
# Copy the statically linked binary
COPY --from=builder /app/prometheus-fe2-exporter /
# Expose the metrics port
EXPOSE 9865
# Start the exporter
ENTRYPOINT ["/prometheus-fe2-exporter"]