Breaking: with state.dir set, jobs still waiting when the daemon stops or crashes print after the next start, in order and however old, instead of being marked failed or forgotten; a client that resends such jobs must stop. The Docker image sets state.dir, so a container keeps its jobs in /var/lib/uberbringer, and loses them with the container unless a volume is mounted there. The owner decided that jobs survive a restart and that a restart never prints a receipt twice. When state.dir is set, the daemon now opens the SQLite job store there, jobs.db, and the queue restores it before the subscriptions are made and before anything is served, so restored jobs go ahead of new ones and a second daemon on the directory stops before it reads the subscriptions' state. Without state.dir the queue keeps its jobs in memory, as before. The store closes once the queue has stopped. A job's sending mark is synced before its first byte, so one caught mid write reads uncertain after the restart and is never sent again; a job that had not reached the printer prints once. A store that cannot be opened stops the start with an error naming the file, rather than starting empty and forgetting which receipts are in doubt. The unit gains UMask=0077, so the store's files are its user's alone, and says why systemd's 90 s stop timeout is enough; the Dockerfile and docs/docker.md ask for --stop-timeout 40. design.md replaces "The queue lives in memory" with the store, the state machine, the sync policy, store failures, stage 1a's numbers, and that the ARM builds ship the store untested on ARM hardware. install.md and docker.md say how to set aside a store that will not open; configuration.md, api.md, cli.md and ntfy.md say what survives a restart. The license notices gain the driver's modules. TestServeRestart runs the daemon twice on one directory: jobs queued when the first run stops, its printer refusing connections, print in order after the restart, ahead of a new job, and a job seeded in sending between the runs reads uncertain and never reaches the printer. Part of stage 1d of docs/plans/job-store.md (decisions 14 and 15). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
2.2 KiB
Docker
49 lines
2.2 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
FROM golang:1.27-alpine AS build
|
|
# go.mod's go line may name a newer patch release than this image has; the go
|
|
# command then downloads that release instead of failing.
|
|
ENV GOTOOLCHAIN=auto
|
|
WORKDIR /src
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY . .
|
|
ARG VERSION=dev
|
|
ARG COMMIT=none
|
|
RUN CGO_ENABLED=0 go build -trimpath \
|
|
-ldflags "-s -w -X main.version=${VERSION} -X main.commit=${COMMIT}" \
|
|
-o /out/uberbringer ./cmd/uberbringer
|
|
|
|
FROM alpine:3.24
|
|
# ca-certificates for fetching https images, tzdata for local log times.
|
|
# The user and group have the fixed ID 10001, so that files mounted from the
|
|
# host, such as an ntfy token file or a state directory, can be given to it.
|
|
# /var/lib/uberbringer holds the job store and the state of the ntfy
|
|
# subscriptions; a named volume mounted there takes over its owner, so the
|
|
# daemon can write to it.
|
|
RUN apk add --no-cache ca-certificates tzdata \
|
|
&& addgroup -S -g 10001 uberbringer \
|
|
&& adduser -S -D -H -u 10001 -G uberbringer -h /etc/uberbringer uberbringer \
|
|
&& mkdir -p /var/lib/uberbringer \
|
|
&& chown uberbringer:uberbringer /var/lib/uberbringer \
|
|
&& chmod 0700 /var/lib/uberbringer
|
|
COPY --from=build /out/uberbringer /usr/local/bin/uberbringer
|
|
# Where Alpine's own packages keep their license files.
|
|
COPY LICENSE.txt THIRD-PARTY-LICENSES.md /usr/share/licenses/uberbringer/
|
|
USER uberbringer
|
|
WORKDIR /etc/uberbringer
|
|
# Plain HTTP for a reverse proxy in front, which terminates TLS. Mount
|
|
# config.toml at /etc/uberbringer/config.toml, or set UBERBRINGER_CONFIG to ""
|
|
# and give the settings as UBERBRINGER_* variables. Either way, bind_ip must be
|
|
# 0.0.0.0 and trusted_proxies must hold the proxy's address. The daemon keeps
|
|
# its jobs in /var/lib/uberbringer and does not start if it cannot write
|
|
# there. Mount a volume on it to keep the jobs and the subscriptions' state
|
|
# across containers; there is no VOLUME, so a new container never starts on
|
|
# an empty anonymous one unnoticed. Stop the container with a timeout above
|
|
# printer.write_timeout plus 10 s (--stop-timeout 40), so a receipt being
|
|
# written can finish.
|
|
ENV UBERBRINGER_CONFIG=/etc/uberbringer/config.toml \
|
|
UBERBRINGER_STATE_DIR=/var/lib/uberbringer
|
|
EXPOSE 8080
|
|
ENTRYPOINT ["/usr/local/bin/uberbringer"]
|