Skip to content

Commit d4cfdea

Browse files
authored
build: Use gcr/distroless for better scratch image (#99)
* build: air.toml ignore examples directory * chore: Debug log failed webhook destination publish response * build: air.toml exclude dist directory * build: Use gcr/distroless for better scratch image
1 parent 536f884 commit d4cfdea

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

.air.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ tmp_dir = "tmp"
55
cmd = "go build -o tmp/main cmd/outpost/main.go"
66
bin = "tmp/main"
77
delay = 100
8-
exclude_dir = ["internal/portal/node_modules"]
8+
exclude_dir = ["examples", "dist", "internal/portal/node_modules"]
99
include_ext = ["go"]
1010
include_file = ["go.mod", "go.sum", ".env"]

build/Dockerfile.goreleaser

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
FROM scratch
2-
COPY outpost /bin/outpost
3-
ENTRYPOINT ["/bin/outpost"]
1+
FROM gcr.io/distroless/base
2+
COPY outpost outpost
3+
ENTRYPOINT ["./outpost"]

internal/destinationadapter/adapters/webhook/webhook.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"context"
66
"encoding/json"
77
"errors"
8+
"io"
9+
"log"
810
"net/http"
911

1012
"github.com/hookdeck/outpost/internal/destinationadapter/adapters"
@@ -77,6 +79,12 @@ func makeRequest(ctx context.Context, url string, event *adapters.Event) error {
7779

7880
if resp.StatusCode >= 400 {
7981
// TODO: improve error handling to store response value
82+
// TODO: improve logger
83+
log.Println(resp)
84+
if bodyBytes, err := io.ReadAll(resp.Body); err == nil {
85+
bodyString := string(bodyBytes)
86+
log.Println("request error body:", bodyString)
87+
}
8088
return errors.New("request failed")
8189
}
8290

0 commit comments

Comments
 (0)