feat: add packaging, deployment, error pages, and project docs

Phase 7 — Polish:
- Error page template with styled 404/403/500 pages
- Error rendering helper on Renderer

Phase 8 — Packaging & Deployment:
- Containerfile: multi-stage build, non-root user, health check,
  OCI labels with build date and git revision
- Makefile: build, test, cross-compile, deb, rpm, container,
  tarballs, checksums targets
- nfpm.yaml: .deb and .rpm package config
- systemd service: hardened with NoNewPrivileges, ProtectSystem,
  ProtectHome, PrivateTmp, RestrictSUIDSGID
- Default environment file with commented examples
- postinstall/preremove scripts (shellcheck validated)
- compose.yaml: example Podman/Docker Compose
- Caddyfile.example: subdomain, subpath, and remote proxy configs
- CHANGELOG.md for release notes
- CLAUDE.md with architecture, conventions, and quick reference

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2026-03-29 16:34:32 +02:00
commit 1fc42bf1b2
16 changed files with 435 additions and 2 deletions

42
Containerfile Normal file
View file

@ -0,0 +1,42 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# Build: BUILDAH_FORMAT=docker podman build \
# --build-arg BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
# --build-arg GIT_REVISION="$(git describe --always --dirty)" \
# -t favoritter .
FROM docker.io/library/golang:1.23-bookworm AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG VERSION=dev
ARG BUILD_DATE=unknown
RUN CGO_ENABLED=0 go build \
-ldflags="-s -w -X main.version=${VERSION} -X main.buildDate=${BUILD_DATE}" \
-o /favoritter ./cmd/favoritter
FROM docker.io/library/debian:bookworm-slim
ARG BUILD_DATE
ARG GIT_REVISION
LABEL org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${GIT_REVISION}" \
org.opencontainers.image.source="https://kode.naiv.no/olemd/favoritter" \
org.opencontainers.image.licenses="AGPL-3.0-or-later" \
org.opencontainers.image.title="Favoritter" \
org.opencontainers.image.description="Self-hosted favorites web app"
RUN printf 'build_date=%s\ngit_revision=%s\n' "${BUILD_DATE}" "${GIT_REVISION}" > /etc/build-info
RUN useradd -r -s /usr/sbin/nologin favoritter \
&& mkdir -p /data/uploads \
&& chown -R favoritter:favoritter /data
USER favoritter
COPY --from=builder /favoritter /usr/local/bin/favoritter
ENV FAVORITTER_DB_PATH=/data/favoritter.db \
FAVORITTER_UPLOAD_DIR=/data/uploads \
FAVORITTER_LISTEN=:8080
EXPOSE 8080
VOLUME ["/data"]
HEALTHCHECK --interval=30s --timeout=3s CMD ["/usr/local/bin/favoritter", "-healthcheck"]
ENTRYPOINT ["/usr/local/bin/favoritter"]