Skip to content

Commit

Permalink
Fix docker compose health check
Browse files Browse the repository at this point in the history
Update docker compose healthcheck for bufstream to call the status CLI
instead of using `nc` which isn't available in the distroless image.

Update the docker consumer and producer to use the same distroless
nonroot image used by the bufstream container.

Fixes #21.
  • Loading branch information
pkwarren committed Nov 13, 2024
1 parent 0cb43a4 commit 5e81129
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
8 changes: 2 additions & 6 deletions Dockerfile.consume
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# This allows users to try out this demo without needing to have Go installed, as well
# as makes the demo runnable within docker compose.
FROM --platform=$BUILDPLATFORM golang:1.23-alpine3.20 AS builder
FROM --platform=$BUILDPLATFORM golang:1.23-bookworm AS builder

ARG TARGETOS TARGETARCH
ENV CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH
Expand All @@ -16,11 +16,7 @@ RUN go mod download
COPY . /app
RUN go build -ldflags "-s -w" -trimpath -buildvcs=false -o /go/bin/bufstream-demo-consume ./cmd/bufstream-demo-consume

FROM alpine:3.20.3

RUN apk add --update --no-cache \
ca-certificates && \
rm -rf /var/cache/apk/*
FROM gcr.io/distroless/static-debian12:nonroot

COPY --from=builder /go/bin/bufstream-demo-consume /bufstream-demo-consume
ENTRYPOINT ["/bufstream-demo-consume"]
8 changes: 2 additions & 6 deletions Dockerfile.produce
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# This allows users to try out this demo without needing to have Go installed, as well
# as makes the demo runnable within docker compose.
FROM --platform=$BUILDPLATFORM golang:1.23-alpine3.20 AS builder
FROM --platform=$BUILDPLATFORM golang:1.23-bookworm AS builder

ARG TARGETOS TARGETARCH
ENV CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH
Expand All @@ -16,11 +16,7 @@ RUN go mod download
COPY . /app
RUN go build -ldflags "-s -w" -trimpath -buildvcs=false -o /go/bin/bufstream-demo-produce ./cmd/bufstream-demo-produce

FROM alpine:3.20.3

RUN apk add --update --no-cache \
ca-certificates && \
rm -rf /var/cache/apk/*
FROM gcr.io/distroless/static-debian12:nonroot

COPY --from=builder /go/bin/bufstream-demo-produce /bufstream-demo-produce
ENTRYPOINT ["/bufstream-demo-produce"]
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
# We'll expose bufstream on the host at port 9092.
- "9092:9092"
healthcheck:
test: nc -z bufstream 9092 || exit -1
test: ["CMD", "/usr/local/bin/bufstream", "admin", "status", "--exit-code", "--url", "http://127.0.0.1:9089"]
start_period: 15s
interval: 5s
timeout: 10s
Expand Down

0 comments on commit 5e81129

Please sign in to comment.