Skip to content
Merged

Dev #44

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build stage
FROM golang:1.24-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder

# Install build dependencies
RUN apk add --no-cache git make
Expand All @@ -16,22 +16,30 @@ RUN go mod download
# Copy source code
COPY . .

# Build the application
RUN go build -v -o telemetry ./cmd/telemetry
# Build args from buildx
ARG TARGETOS
ARG TARGETARCH

# Build static binary for correct platform
RUN CGO_ENABLED=0 \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
go build -trimpath -ldflags="-s -w" \
-o telemetry ./cmd/telemetry

# Runtime stage
FROM alpine:latest

# Set working directory
WORKDIR /app

# Install runtime dependencies
RUN apk --no-cache add ca-certificates tzdata

# Create non-root user
RUN addgroup -g 1000 -S telemetry && \
adduser -u 1000 -S telemetry -G telemetry

# Set working directory
WORKDIR /app

# Copy binary from builder
COPY --from=builder /build/telemetry .
COPY --from=builder /build/configs ./configs
Expand Down