3 Commits
4 changed files with 26 additions and 10 deletions
+10 -5
View File
@@ -1,20 +1,25 @@
# syntax=docker/dockerfile:1.7
# ---- Stage 1: build the web frontend ----
FROM node:20-alpine AS web-builder
# Build toolchains run natively on the BuildKit host. Without BUILDPLATFORM,
# the arm64 branch executes npm and the Go compiler through QEMU, which is much
# slower and makes npm ci appear to hang despite producing no progress output.
# ---- Stage 1: build the web frontend once on the native builder ----
FROM --platform=$BUILDPLATFORM node:20-alpine AS web-builder
WORKDIR /web
COPY web/package.json web/package-lock.json* ./
RUN npm ci
COPY web/ ./
RUN npm run build
# ---- Stage 2: build the Go binary ----
FROM golang:1.25-alpine AS go-builder
# ---- Stage 2: cross-compile the Go binary on the native builder ----
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS go-builder
RUN apk add --no-cache git
WORKDIR /src
ARG VERSION=0.1.0-dev
ARG BUILD_TIME=""
ARG TARGETOS
ARG TARGETARCH
COPY go.mod go.sum ./
RUN go mod download
@@ -23,7 +28,7 @@ COPY . .
# Overlay the freshly built frontend so go:embed web/dist picks it up.
COPY --from=web-builder /web/dist ./web/dist
RUN CGO_ENABLED=0 GOOS=linux go build \
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build \
-trimpath \
-ldflags "-s -w -X vocat/internal/buildinfo.Version=${VERSION} -X vocat/internal/buildinfo.BuildTime=${BUILD_TIME}" \
-o /out/vocat \
+4
View File
@@ -248,6 +248,10 @@ func run(logger *slog.Logger, logs *loghub.Hub) error {
case <-signalContext.Done():
logger.Info("shutdown signal received")
}
// Long-lived SSE and polling handlers use this context. Stop them before
// http.Server.Shutdown so they do not consume the entire graceful-shutdown
// deadline while waiting for a stream that is intentionally still active.
cancelPolling()
shutdownContext, cancelShutdown := context.WithTimeout(
context.Background(),
+6 -3
View File
@@ -7,8 +7,8 @@
// Trust model: GitHub TLS guarantees the channel; the repository owner controls
// which assets are published; SHA256SUMS guards integrity. There is no GPG
// signature verification — an accepted trade-off for a closed-network testing
// tool. The web UI's check-update button remains an intentional no-op; only the
// CLI performs code replacement.
// tool. Both the CLI and authenticated web UI use this same verified replacement
// path.
package update
import (
@@ -232,7 +232,10 @@ func RestartService(logger *slog.Logger) error {
if _, err := exec.LookPath("systemctl"); err != nil {
return fmt.Errorf("systemctl not found in PATH")
}
cmd := exec.Command("systemctl", "restart", "vocat")
// Queue the restart and let systemctl exit before systemd stops this unit.
// A blocking restart command becomes part of vocat.service's own cgroup and
// waits for that same cgroup to terminate, creating a stop-timeout cycle.
cmd := exec.Command("systemctl", "restart", "--no-block", "vocat")
if out, err := cmd.CombinedOutput(); err != nil {
logger.Warn("systemctl restart failed", "error", err, "output", string(out))
return fmt.Errorf("systemctl restart vocat: %w", err)
+6 -2
View File
@@ -216,7 +216,9 @@ ExecStart=${BINARY_PATH}
Restart=on-failure
RestartSec=3s
TimeoutStartSec=30s
TimeoutStopSec=20s
# HTTP, VoWiFi, and modem cleanup have bounded shutdown contexts totalling up
# to 30 seconds. Leave a small margin before systemd resorts to SIGKILL.
TimeoutStopSec=40s
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW
@@ -229,7 +231,9 @@ ProtectKernelLogs=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectControlGroups=true
ReadWritePaths=/opt/vocat/data
# The web/CLI self-updater verifies a release in this directory and atomically
# renames it over the running binary. Keep the rest of the host read-only.
ReadWritePaths=/opt/vocat/data /opt/vocat/bin
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
RestrictRealtime=true
LockPersonality=true