Files
Lucas RayanandClaude Opus 5.5 0895e43693
CI / Format and vet (pull_request) Successful in 1m9s
CI / Dependency audit (pull_request) Successful in 32s
CI / Tests (Linux, race detector) (pull_request) Successful in 2m2s
CI / Docker images (build and smoke test) (pull_request) Successful in 50s
Release / Build probe image (arm64) (push) Failing after 21s
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Successful in 2m15s
Release / Build hub image (arm64) (push) Successful in 24s
CI / Format and vet (push) Successful in 1m3s
CI / Tests (Linux, race detector) (push) Successful in 1m46s
CI / Dependency audit (push) Successful in 29s
CI / Docker images (build and smoke test) (push) Skipped
Release / Build hub image (amd64) (push) Successful in 21s
Release / Build probe image (amd64) (push) Failing after 20s
Release / Publish tags (hub) (push) Skipped
Release / Publish tags (probe) (push) Skipped
Release / Gitea release (push) Skipped
fix(probe): dedicated urutau-probe binary for the probe image; CI shellcheck via docker cp
The probe image linked the whole hub (24 MB uncompressed, over the 15 MB
limit). cmd/urutau-probe links only probeagent, tail and wire (6.8 MB);
'urutau probe' still works and shares probeagent.Main. The shellcheck step
bind-mounted the workspace, which the runner's DinD daemon cannot see.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 22:30:18 -03:00

74 lines
3.4 KiB
Docker

# syntax=docker/dockerfile:1
#
# Urutau 2: static binaries (no CGO, standard library only), two images.
# --target hub the hub: dashboard, API, probe ingestion (Alpine), cmd/urutau
# --target probe the probe only (FROM scratch), cmd/urutau-probe: links just the
# probe agent, the tailer and the wire protocol (~7 MB binary)
# The default (last) stage is the hub, so a plain `docker build .` is the hub.
# Build stage.
FROM golang:1.26.11-alpine3.24 AS build
WORKDIR /src
COPY go.mod ./
COPY cmd cmd
COPY internal internal
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/urutau ./cmd/urutau \
&& v=$(sed -n 's/^var Version = "\(.*\)"/\1/p' internal/app/version.go) \
&& CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.version=$v" -o /out/urutau-probe ./cmd/urutau-probe
# Files the scratch image needs: CA certificates (HTTPS to the hub), zoneinfo
# (TZ must match the host's fail2ban log) and an owned empty /state.
FROM alpine:3.24 AS probe-files
RUN apk add --no-cache ca-certificates tzdata \
&& mkdir -p /rootfs/state \
&& chown 10001:10001 /rootfs/state
# Probe image: no shell, no package manager, no listening port. It reads the
# host logs (read-only mounts), sends them to the hub over HTTPS and appends the
# hub's ban decisions to a file. The HEALTHCHECK is the binary itself
# (`urutau probe --check` reads the liveness mark in the state volume).
# Runs unprivileged (uid 10001); the compose file adds the host group adm
# (`group_add: ["4"]`) to read /var/log.
FROM scratch AS probe
COPY --from=probe-files /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=probe-files /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=probe-files --chown=10001:10001 /rootfs/state /state
COPY --from=build /out/urutau-probe /urutau
LABEL org.opencontainers.image.title="Urutau probe" \
org.opencontainers.image.description="Ultra-light Urutau probe: ships host logs to an Urutau hub" \
org.opencontainers.image.source="https://git.lucasrguerra.dev.br/ciberfauna/urutau" \
org.opencontainers.image.licenses="MIT OR Apache-2.0"
ENV URUTAU_STATE_DIR=/state \
SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt \
ZONEINFO=/usr/share/zoneinfo
USER 10001:10001
VOLUME /state
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD ["/urutau", "probe", "--check"]
ENTRYPOINT ["/urutau", "probe"]
# Hub image: CA certificates (hub-to-hub downloads: geo database, Tor lists) and
# tzdata. The HEALTHCHECK is the binary itself (`urutau healthcheck`): no curl in
# the image. The hub reads no log file: the probes bring the lines.
FROM alpine:3.24 AS hub
RUN apk add --no-cache ca-certificates tzdata \
&& addgroup -S -g 10001 urutau \
&& adduser -S -u 10001 -G urutau -h /data -s /sbin/nologin urutau \
&& mkdir -p /data \
&& chown urutau:urutau /data
COPY --from=build /out/urutau /usr/local/bin/urutau
LABEL org.opencontainers.image.title="Urutau" \
org.opencontainers.image.description="Lightweight, always-on threat intelligence for self-hosted servers" \
org.opencontainers.image.source="https://git.lucasrguerra.dev.br/ciberfauna/urutau" \
org.opencontainers.image.licenses="MIT OR Apache-2.0"
ENV URUTAU_BIND=0.0.0.0:8790 \
URUTAU_DATA_DIR=/data
USER urutau
WORKDIR /data
VOLUME /data
EXPOSE 8790
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD ["urutau", "healthcheck"]
ENTRYPOINT ["urutau"]
CMD ["serve"]