Give uploads one path end to end, and serve /uploads/ from Garage first
Test and deploy / deploy (push) Successful in 3m48s
Test and deploy / test (push) Successful in 37s

Frontend: src/uploads.js is the one way to store or show a file
(uploadFile, ACCEPT, kindOf, isUploadUrl, tagFor, mediaSize). Chat,
the box editor, canvas drops and the background editor all use it;
views/home3/upload.js and the chat store's own axios call are gone.

Backend: POST /api/uploads (was /messages/upload) is a thin wrapper over
services.Uploads.Save, which owns validation, naming and storage. The
three per-extension maps are now one UploadTypes table, and a refused
file is an *UploadError whose message is safe to show.

nginx now fetches /uploads/ from Garage first and falls back to the
volume on a 404 or any 5xx, so the bucket is the source of truth and
deleting a file in garage-webui unpublishes it, while a Garage outage
still only affects bucket-only files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-15 21:04:37 +01:00
co-authored by Claude Opus 5.5
parent 422cde4708
commit 65fddfcfa2
26 changed files with 848 additions and 668 deletions
+7 -6
View File
@@ -66,9 +66,9 @@ volumes:
# File upload — PERSISTENT. Written by the backend at /backend/uploads,
# served read-only by nginx at /uploads/. Shared so nginx can serve user
# uploads without proxying through the Go process. Since Garage, it holds
# the uploads from before the bucket, private attachments (always), and any
# upload the backend wrote here because Garage refused it; nginx looks here
# first and only then in the bucket.
# private attachments (always), the uploads from before the bucket, and any
# upload the backend wrote here because Garage refused it. nginx serves
# /uploads/ from the bucket first and only then from here.
uploads:
# Garage object store — PERSISTENT, both. garage_meta is the metadata DB
# (buckets, keys, the object index, the cluster layout); garage_data is the
@@ -629,15 +629,16 @@ services:
# S3-compatible object store holding public uploads (the `uploads` bucket).
# The backend writes to it on :3900 once S3_ENDPOINT is set in .env; nginx
# reads it anonymously on :3902 for /uploads/ files not found on the
# serves /uploads/ from it anonymously on :3902, falling back to the
# `uploads` volume; garage-webui manages it via :3903. Nothing is published
# to the host. Config is garage/garage.toml (no secrets in it); the two
# secrets come from .env through the explicit list below.
#
# Nothing depends on this container being up. nginx is deliberately NOT
# given it in depends_on: its upstream is a variable, so a missing or
# crash-looping garage costs a 502 on bucket-only files, never nginx's
# boot; and the backend falls back to the volume when a write fails.
# crash-looping garage only makes bucket-only files 404 (everything on the
# volume is still served), never nginx's boot; and the backend falls back
# to the volume when a write fails.
#
# FIRST RUN: garage/bootstrap.sh (layout, bucket, key, website access).
# The image is FROM scratch — no shell, so no in-container init script and