Files
ophion/deploy/docker/Dockerfile.agent
2026-02-06 14:26:15 -03:00

58 lines
1.5 KiB
Docker

# ═══════════════════════════════════════════════════════════
# 🐍 OPHION Agent - Dockerfile
# ═══════════════════════════════════════════════════════════
# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /build
# Install dependencies
RUN apk add --no-cache git ca-certificates
# Copy go modules first (cache layer)
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY cmd/ ./cmd/
COPY internal/ ./internal/
# Build the agent binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-s -w" -o ophion-agent ./cmd/agent
# Runtime stage
FROM alpine:3.19
LABEL org.opencontainers.image.title="OPHION Agent"
LABEL org.opencontainers.image.description="Observability Agent - Metrics, Logs, Traces Collector"
# Install runtime dependencies
RUN apk add --no-cache ca-certificates tzdata
# Create non-root user
RUN addgroup -g 1000 ophion && \
adduser -u 1000 -G ophion -s /bin/sh -D ophion
WORKDIR /app
# Copy binary from builder
COPY --from=builder /build/ophion-agent /app/
USER ophion
# Environment defaults
ENV TZ=America/Sao_Paulo \
OPHION_SERVER=http://localhost:8080 \
OPHION_INTERVAL=30s \
OPHION_DOCKER=true \
OPHION_LOGS=true \
OPHION_OTLP=true \
OPHION_OTLP_PORT=4318
# OTLP receiver port
EXPOSE 4318
ENTRYPOINT ["/app/ophion-agent"]