Records package viewer: read-only, no account needed

SAM_VIEWER=true (set only by the records package's
viewer/docker-compose.yml) makes the app a read-only copy of an archive,
for whoever receives the records: `docker compose up`, then open
http://localhost:3000.

- At start (bin/docker-entrypoint → sam:viewer:prepare) the package's
  .sam.zip, mounted read-only, is imported once.
- No sign-in: everyone browses as a built-in account. Nothing can be
  changed: any request but GET/HEAD is refused, no role permission
  applies (so no edit buttons), and there's no sign-out or profile. A
  banner names the archive and when it was exported.
- It refuses to start, and every page answers 503, when the database
  has any other account, so turning it on for a real installation stops
  the app instead of exposing its records.
- The viewer listens on 127.0.0.1 only, and skips scheduled jobs
  (reminders, backups, AD searches).
- Docs: the package README (three steps now), Access & sharing, README
  settings and features, the suggested recordkeeping procedures.

Checked end to end with a built image and a real records package: the
archive imported at start, pages browsed without an account, a change
refused, and the container refusing to start once an account existed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-15 20:03:56 -05:00
1 parent 34e3232350
commit d956cfbe83
14 files changed
+229 -33

No files matched your search

+14 -9
View File
@@ -76,30 +76,35 @@ class RecordsPackage
"#{image.sub(/:[^:\/]+\z/, '')}:#{version}"
end
# A ready-to-run local viewer, with its own throwaway secret key (never this
# installation's), plain HTTP on localhost.
# A ready-to-run local viewer of the archive: read-only, no account needed
# (viewer mode, see Viewer), reachable only from that computer, with its own
# throwaway secret key (never this installation's).
def viewer_compose
image = viewer_image
archive = "#{@aircraft.tail_number.downcase}.sam.zip"
<<~YAML
# Simple Aircraft Manager on your own computer, to browse #{@aircraft.tail_number.downcase}.sam.zip.
# 1. docker compose up -d
# 2. Open http://localhost:3000 and create the first (admin) account. It asks
# for a one-time setup code: docker compose logs web | grep "Setup code"
# 3. Fleet -> More -> Import from a .sam.zip archive: choose #{@aircraft.tail_number.downcase}.sam.zip
# Stop: docker compose down (add -v to delete this local copy)
# Simple Aircraft Manager on your own computer, showing #{archive} read-only.
# 1. In this folder: docker compose up
# The first start imports the records; wait for "Viewer ready".
# 2. Open http://localhost:3000 (no account needed).
# Stop: Ctrl+C, then docker compose down (add -v to delete this local copy).
# Prepared with software version #{SystemInfo.new.version_label}.#{" Source: #{repository}" if repository}
services:
web:
#{image ? "image: #{image}" : "build: . # no published image known: build from the source code"}
restart: "no"
ports:
- "3000:80"
- "127.0.0.1:3000:80" # this computer only
environment:
SAM_VIEWER: "true"
SAM_VIEWER_ARCHIVE: /import/#{archive}
SECRET_KEY_BASE: #{SecureRandom.hex(64)} # for this local copy only
APP_HOST: localhost:3000
FORCE_SSL: "false"
SOLID_QUEUE_IN_PUMA: "true"
SOLID_QUEUE_SKIP_RECURRING: "true" # no reminders, backups or AD searches
volumes:
- ../#{archive}:/import/#{archive}:ro # the archive next to this folder, in the package
- viewer_storage:/rails/storage
volumes:
viewer_storage: