mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-19 06:59:56 +02:00
The CLI up path only tolerated a not-yet-ready daemon via a 10s blocking dial, so "netbird service start" immediately followed by "netbird up" (e.g. a container entrypoint) failed with a generic "daemon not running" error. The container entrypoint worked around this with a shell poll loop (status --check live) before running up. Move the readiness wait into the CLI, mirroring how the GUI already dials: - DialClientGRPCServer now uses grpc.NewClient with a tuned reconnect backoff and waits for the connection to reach READY (retrying on TRANSIENT_FAILURE) up to a 30s deadline, instead of grpc.DialContext + WithBlock with a hard 10s timeout. - up now polls Status via waitForDaemonStatus, retrying while the RPC is Unavailable (socket up but service not yet registered). Add an explicit daemon-ready signal so clients can wait deterministically instead of heuristically: - New optional StatusResponse.daemonReady field (field 5, wire-compatible with older GUIs/daemons which leave it unset). Regenerated with the pinned protoc v33.1 toolchain so no version churn leaks into the diff. - The server sets ready once Start succeeds and the DaemonService is registered (SetReady, called from the service controller). - waitForDaemonStatus waits for daemonReady=true (or an already-Connected status), with a bounded grace window so older daemons that never set the field are not blocked. Simplify the container entrypoint accordingly: drop the readiness poll loop (up now waits) and the now-dead NB_ENTRYPOINT_SERVICE_TIMEOUT env, keeping only the daemon+up process glue and SIGTERM forwarding for clean shutdown.
24 lines
1.0 KiB
Docker
24 lines
1.0 KiB
Docker
# Multistage build for the NetBird client used in e2e tests. The repo has no
|
|
# source-building client Dockerfile (client/Dockerfile packages a goreleaser
|
|
# artifact), so this mirrors its alpine runtime + entrypoint while compiling the
|
|
# CGO-free client inline. BuildKit cache mounts keep rebuilds incremental.
|
|
|
|
FROM golang:1.25-bookworm AS builder
|
|
WORKDIR /src
|
|
COPY go.mod go.sum ./
|
|
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
|
COPY . .
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
CGO_ENABLED=0 GOOS=linux go build -o /out/netbird ./client
|
|
|
|
FROM alpine:3.24
|
|
RUN apk add --no-cache bash ca-certificates ip6tables iproute2 iptables
|
|
ENV NETBIRD_BIN="/usr/local/bin/netbird" \
|
|
NB_LOG_FILE="console,/var/log/netbird/client.log" \
|
|
NB_DAEMON_ADDR="unix:///var/run/netbird.sock" \
|
|
NB_ENABLE_CAPTURE="false"
|
|
ENTRYPOINT [ "/usr/local/bin/netbird-entrypoint.sh" ]
|
|
COPY client/netbird-entrypoint.sh /usr/local/bin/netbird-entrypoint.sh
|
|
COPY --from=builder /out/netbird /usr/local/bin/netbird
|