Skip to content
Draft
Show file tree
Hide file tree
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
49 changes: 49 additions & 0 deletions Dockerfile.alertmanager
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Multi-stage Dockerfile for Alertmanager
FROM golang:1.23-alpine AS builder

# Install build dependencies
RUN apk add --no-cache git make bash nodejs npm

# Set working directory
WORKDIR /app

# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download

# Copy source code
COPY . .

# Build the binaries (skip UI build for faster compilation)
# Force native architecture build
RUN CGO_ENABLED=0 GOOS=linux go build -o alertmanager ./cmd/alertmanager
RUN CGO_ENABLED=0 GOOS=linux go build -o amtool ./cmd/amtool

# Final stage
FROM alpine:latest

# Install ca-certificates for TLS with retry logic
RUN apk update && apk --no-cache add ca-certificates tzdata || \
(sleep 5 && apk update && apk --no-cache add ca-certificates tzdata)

# Create alertmanager user
RUN addgroup -S alertmanager && adduser -S alertmanager -G alertmanager

# Copy binaries from builder stage
COPY --from=builder /app/alertmanager /bin/alertmanager
COPY --from=builder /app/amtool /bin/amtool

# Copy default configuration
COPY examples/ha/alertmanager.yml /etc/alertmanager/alertmanager.yml

# Create directories and set permissions
RUN mkdir -p /alertmanager && \
chown -R alertmanager:alertmanager /etc/alertmanager /alertmanager

USER alertmanager
EXPOSE 9093
VOLUME ["/alertmanager"]
WORKDIR /alertmanager
ENTRYPOINT ["/bin/alertmanager"]
CMD ["--config.file=/etc/alertmanager/alertmanager.yml", \
"--storage.path=/alertmanager"]
28 changes: 28 additions & 0 deletions Dockerfile.webhook
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Dockerfile for webhook echo server
FROM golang:1.23-alpine AS builder

# Set working directory
WORKDIR /app

# Copy the echo.go file
COPY examples/webhook/echo.go .

# Build the binary
RUN CGO_ENABLED=0 go build -o webhook-server echo.go

# Final stage
FROM alpine:latest

# Install ca-certificates for TLS with retry logic
RUN apk update && apk --no-cache add ca-certificates || \
(sleep 5 && apk update && apk --no-cache add ca-certificates)

# Create webhook user
RUN addgroup -S webhook && adduser -S webhook -G webhook

# Copy binary from builder stage
COPY --from=builder /app/webhook-server /bin/webhook-server

USER webhook
EXPOSE 5001
ENTRYPOINT ["/bin/webhook-server"]
16 changes: 16 additions & 0 deletions alertmanager-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
route:
group_by: ['alertname']
group_wait: 30s
group_interval: 5m
repeat_interval: 1h
receiver: 'web.hook'
receivers:
- name: 'web.hook'
webhook_configs:
- url: 'http://webhook-server:5001/'
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
16 changes: 16 additions & 0 deletions alertmanager-2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
route:
group_by: ['alertname']
group_wait: 30s
group_interval: 5m
repeat_interval: 1h
receiver: 'web.hook'
receivers:
- name: 'web.hook'
webhook_configs:
- url: 'http://webhook-server:5001/'
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
16 changes: 16 additions & 0 deletions alertmanager-3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
route:
group_by: ['alertname']
group_wait: 30s
group_interval: 5m
repeat_interval: 1h
receiver: 'web.hook'
receivers:
- name: 'web.hook'
webhook_configs:
- url: 'http://webhook-server:5001/'
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
Loading