Skip to content

Commit 0b75833

Browse files
committed
Updated Dockerization
1 parent a95f814 commit 0b75833

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
2121
COPY --from=builder /etc/passwd /etc/passwd
2222
# Copy our static executable
2323
COPY --from=builder /go/bin/alertmanager-discord /go/bin/alertmanager-discord
24+
25+
EXPOSE 9094
2426
USER appuser
2527
ENTRYPOINT ["/go/bin/alertmanager-discord"]
2628

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
alertmanager-discord
22
===
33

4-
Give this a webhook and point it as a webhook on alertmanager, and it will post your alerts into a discord channel for you as they trigger:
4+
Give this a webhook (with the DISCORD_WEBHOOK environment variable) and point it as a webhook on alertmanager, and it will post your alerts into a discord channel for you as they trigger:
55

66
![](/.github/demo.png)
77

@@ -31,4 +31,4 @@ receivers:
3131
- name: 'discord_webhook'
3232
webhook_configs:
3333
- url: 'http://localhost:9094'
34-
```
34+
```

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"flag"
77
"fmt"
8+
"os"
89
"io/ioutil"
910
"net/http"
1011
"strings"
@@ -44,9 +45,14 @@ type discordOut struct {
4445
}
4546

4647
func main() {
47-
webhookUrl := os.Getenv("webhook")
48+
webhookUrl := os.Getenv("DISCORD_WEBHOOK")
49+
if webhookUrl == "" {
50+
fmt.Fprintf(os.Stderr, "error: environment variable DISCORD_WEBHOOK not found\n")
51+
os.Exit(1)
52+
}
4853
whURL := flag.String("webhook.url", webhookUrl, "")
4954
flag.Parse()
55+
fmt.Fprintf(os.Stdout, "info: Listening on 0.0.0.0:9094\n")
5056
http.ListenAndServe(":9094", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
5157
b, err := ioutil.ReadAll(r.Body)
5258
if err != nil {

0 commit comments

Comments
 (0)