photo-object-storage: MinIO on .13 (9010/9011), Go upload+serve /photos, admin S3 disk + Filament upload, migrated, deployed

This commit is contained in:
2026-08-08 10:01:02 +10:00
parent 61f16742ca
commit d5919315fa
9 changed files with 246 additions and 32 deletions

View File

@@ -5,14 +5,32 @@ go 1.26
require (
github.com/gorilla/sessions v1.4.0
github.com/jackc/pgx/v5 v5.10.0
github.com/minio/minio-go/v7 v7.2.1
golang.org/x/crypto v0.54.0
)
require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/klauspost/compress v1.18.6 // indirect
github.com/klauspost/cpuid/v2 v2.2.11 // indirect
github.com/klauspost/crc32 v1.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/minio/crc64nvme v1.1.1 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/tinylib/msgp v1.6.1 // indirect
github.com/zeebo/xxh3 v1.1.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/net v0.56.0 // indirect
golang.org/x/sync v0.22.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.40.0 // indirect
gopkg.in/ini.v1 v1.67.2 // indirect
)

View File

@@ -1,8 +1,15 @@
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
github.com/gorilla/sessions v1.4.0 h1:kpIYOp/oi6MG/p5PgxApU8srsSw9tuFbt46Lt7auzqQ=
@@ -15,20 +22,65 @@ github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao=
github.com/klauspost/compress v1.18.6/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU=
github.com/klauspost/cpuid/v2 v2.2.11/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/klauspost/crc32 v1.3.0 h1:sSmTt3gUt81RP655XGZPElI0PelVTZ6YwCRnPSupoFM=
github.com/klauspost/crc32 v1.3.0/go.mod h1:D7kQaZhnkX/Y0tstFGf8VUzv2UofNGqCjnC3zdHB0Hw=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/minio/crc64nvme v1.1.1 h1:8dwx/Pz49suywbO+auHCBpCtlW1OfpcLN7wYgVR6wAI=
github.com/minio/crc64nvme v1.1.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.2.1 h1:PfBfwvKB/MmqyN8Vb1G9voWisaM9OrLv+WwOvMwS9Dw=
github.com/minio/minio-go/v7 v7.2.1/go.mod h1:EU9hENAStx/xXduNdrGO5e4X5vk19NtgB+RIPjZO8o0=
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tinylib/msgp v1.6.1 h1:ESRv8eL3u+DNHUoSAAQRE50Hm162zqAnBoGv9PzScPY=
github.com/tinylib/msgp v1.6.1/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/ini.v1 v1.67.2 h1:JtOSMb9OuaCZKr7h5D/h6iii14sK0hLbplTc6frx4Ss=
gopkg.in/ini.v1 v1.67.2/go.mod h1:x/cyOwCgZqOkJoDIJ3c1KNHMo10+nLGAhh+kn3Zizss=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -10,6 +10,7 @@ import (
"wherewoof/frontend/internal/auth"
"wherewoof/frontend/internal/db"
"wherewoof/frontend/internal/sms"
"wherewoof/frontend/internal/storage"
)
// Templates maps a page key to its parsed template set (base + page + partials).
@@ -22,11 +23,12 @@ type App struct {
Queries *db.Queries
Tpl Templates
Sender sms.Sender
Storage *storage.Client
}
// New returns an App with the given query layer, template sets, and SMS sender.
func New(queries *db.Queries, tpl Templates, sender sms.Sender) *App {
return &App{Queries: queries, Tpl: tpl, Sender: sender}
// New returns an App with the given query layer, template sets, SMS sender, and object storage.
func New(queries *db.Queries, tpl Templates, sender sms.Sender, store *storage.Client) *App {
return &App{Queries: queries, Tpl: tpl, Sender: sender, Storage: store}
}
// PageData is the root data passed to the base layout.

View File

@@ -0,0 +1,39 @@
package handlers
import (
"errors"
"io"
"net/http"
"strings"
"github.com/minio/minio-go/v7"
)
// ServePhoto streams a photo object from object storage.
// Used by tags.photo_url values of the form "/photos/tags/{id}.{ext}".
func (a *App) ServePhoto(w http.ResponseWriter, r *http.Request) {
key := strings.TrimPrefix(r.PathValue("key"), "/")
if key == "" || a.Storage == nil {
http.NotFound(w, r)
return
}
obj, ct, err := a.Storage.Get(r.Context(), key)
if err != nil {
var me minio.ErrorResponse
if errors.As(err, &me) && me.Code == "NoSuchKey" {
http.NotFound(w, r)
return
}
http.Error(w, "photo unavailable", http.StatusInternalServerError)
return
}
defer obj.Close()
if ct == "" {
ct = "application/octet-stream"
}
w.Header().Set("Content-Type", ct)
w.Header().Set("Cache-Control", "public, max-age=86400")
_, _ = io.Copy(w, obj)
}

View File

@@ -3,9 +3,7 @@ package handlers
import (
"errors"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
@@ -173,13 +171,18 @@ func (a *App) loadOwnedTag(w http.ResponseWriter, r *http.Request, uid int64) (d
return tag, true
}
// UploadPhoto saves an uploaded image for a tag and sets its photo_url (HTMX).
// UploadPhoto saves an uploaded image for a tag to object storage (MinIO) and
// sets its photo_url to the app's serve path (HTMX).
func (a *App) UploadPhoto(w http.ResponseWriter, r *http.Request) {
uid, _ := auth.GetUserID(r)
tag, ok := a.loadOwnedTag(w, r, uid)
if !ok {
return
}
if a.Storage == nil {
writeUploadMsg(w, "Photo storage is not configured.")
return
}
if err := r.ParseMultipartForm(5 << 20); err != nil { // 5 MB
writeUploadMsg(w, "Upload too large (max 5 MB).")
@@ -196,34 +199,27 @@ func (a *App) UploadPhoto(w http.ResponseWriter, r *http.Request) {
writeUploadMsg(w, "Upload too large (max 5 MB).")
return
}
if !strings.HasPrefix(header.Header.Get("Content-Type"), "image/") {
ct := header.Header.Get("Content-Type")
if !strings.HasPrefix(ct, "image/") {
writeUploadMsg(w, "Only image files are allowed.")
return
}
// Sanitise the filename and store under uploads/.
ext := strings.ToLower(filepath.Ext(header.Filename))
if ext == "" {
ext = ".jpg"
}
dst := filepath.Join("static", "uploads", fmt.Sprintf("tag%d%s", tag.ID, ext))
out, err := os.Create(dst)
if err != nil {
writeUploadMsg(w, "Could not save the photo.")
return
}
defer out.Close()
if _, err := io.Copy(out, file); err != nil {
key := fmt.Sprintf("tags/%d%s", tag.ID, ext)
if err := a.Storage.Put(r.Context(), key, file, header.Size, ct); err != nil {
fmt.Println("upload to storage failed:", err)
writeUploadMsg(w, "Could not save the photo.")
return
}
photoURL := "/static/uploads/" + filepath.Base(dst)
photoURL := "/photos/" + key
if _, err := a.Queries.UpdateTagDetails(r.Context(), db.UpdateTagDetailsParams{
ID: tag.ID,
PhotoUrl: pgtype.Text{String: photoURL, Valid: true},
// Preserve existing values: re-send them via the form is not possible here,
// so use the stored tag fields for everything else.
ItemType: tag.ItemType, Description: tag.Description, Phone: tag.Phone,
Address: tag.Address, Notes: tag.Notes, SmsEnabled: tag.SmsEnabled,
}); err != nil {
@@ -232,7 +228,7 @@ func (a *App) UploadPhoto(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintf(w, `<p class="mt-2 text-xs text-green-700">Photo uploaded ✓ <a href="%s" class="underline">view</a> — refresh to see it on the tag page.</p>`, photoURL)
fmt.Fprintf(w, `<p class="mt-2 text-xs text-green-700">Photo uploaded ✓ — refresh to see it on the tag page.</p>`)
}
func writeUploadMsg(w http.ResponseWriter, msg string) {

View File

@@ -0,0 +1,99 @@
// Package storage provides object storage for Where Woof photos (MinIO, S3-compatible).
package storage
import (
"context"
"fmt"
"io"
"os"
"time"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
)
// Client wraps a MinIO client and bucket for photo objects.
type Client struct {
mc *minio.Client
bucket string
}
// NewClient builds a storage client from MINIO_* env vars.
// Returns (nil, nil) when storage is not configured (MINIO_ENDPOINT unset) —
// callers should treat that as "storage unavailable".
func NewClient() (*Client, error) {
endpoint := os.Getenv("MINIO_ENDPOINT")
if endpoint == "" {
return nil, nil
}
access := os.Getenv("MINIO_ACCESS_KEY")
secret := os.Getenv("MINIO_SECRET_KEY")
bucket := os.Getenv("MINIO_BUCKET")
if bucket == "" {
bucket = "wherewoof"
}
mc, err := minio.New(endpoint, &minio.Options{
Creds: credentials.NewStaticV4(access, secret, ""),
Secure: false, // internal LAN
})
if err != nil {
return nil, fmt.Errorf("minio client: %w", err)
}
return &Client{mc: mc, bucket: bucket}, nil
}
// Put stores an object under key and returns the size.
func (c *Client) Put(ctx context.Context, key string, r io.Reader, size int64, contentType string) error {
if c == nil {
return fmt.Errorf("storage not configured")
}
_, err := c.mc.PutObject(ctx, c.bucket, key, r, size, minio.PutObjectOptions{
ContentType: contentType,
})
return err
}
// Get returns the object reader + content type for a key.
func (c *Client) Get(ctx context.Context, key string) (io.ReadCloser, string, error) {
if c == nil {
return nil, "", fmt.Errorf("storage not configured")
}
obj, err := c.mc.GetObject(ctx, c.bucket, key, minio.GetObjectOptions{})
if err != nil {
return nil, "", err
}
stat, err := obj.Stat()
if err != nil {
obj.Close()
return nil, "", err
}
return obj, stat.ContentType, nil
}
// ListKeys returns object keys with the given prefix (used for migration).
func (c *Client) ListKeys(ctx context.Context, prefix string) ([]string, error) {
if c == nil {
return nil, fmt.Errorf("storage not configured")
}
var keys []string
for obj := range c.mc.ListObjects(ctx, c.bucket, minio.ListObjectsOptions{Prefix: prefix}) {
if obj.Err != nil {
return nil, obj.Err
}
keys = append(keys, obj.Key)
}
return keys, nil
}
// PresignedURL returns a temporary URL (not used by the app; available for admin previews).
func (c *Client) PresignedURL(ctx context.Context, key string, expiry time.Duration) (string, error) {
if c == nil {
return "", fmt.Errorf("storage not configured")
}
u, err := c.mc.PresignedGetObject(ctx, c.bucket, key, expiry, nil)
if err != nil {
return "", err
}
return u.String(), nil
}

View File

@@ -13,6 +13,7 @@ import (
"wherewoof/frontend/internal/db"
"wherewoof/frontend/internal/handlers"
"wherewoof/frontend/internal/sms"
"wherewoof/frontend/internal/storage"
)
func main() {
@@ -53,7 +54,13 @@ func main() {
sender = sms.New(key, os.Getenv("SMS_API_SECRET"), os.Getenv("SMS_FROM"))
}
app := handlers.New(db.New(pool), tpl, sender)
// Object storage (MinIO) — nil when not configured.
store, err := storage.NewClient()
if err != nil {
log.Fatal("storage:", err)
}
app := handlers.New(db.New(pool), tpl, sender, store)
mux := http.NewServeMux()
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
@@ -74,6 +81,7 @@ func main() {
mux.Handle("POST /account/tags/{id}/edit", app.RequireAuth(app.EditTag))
mux.Handle("POST /account/tags/{id}/delete", app.RequireAuth(app.DeleteTag))
mux.Handle("POST /account/tags/{id}/photo", app.RequireAuth(app.UploadPhoto))
mux.HandleFunc("GET /photos/{key...}", app.ServePhoto)
srv := &http.Server{
Addr: addr,

View File

@@ -1,21 +1,21 @@
## 1. MinIO Provisioning
- [ ] 1.1 Compose + env on .13 (`wherewoof-minio`, API 9000 / console 9001, volume); `docker compose up -d`; create bucket `wherewoof`; verify API (mc or curl)
- [x] 1.1 Compose + env on .13 (`wherewoof-minio`, API 9000 / console 9001, volume); `docker compose up -d`; create bucket `wherewoof`; verify API (mc or curl)
## 2. Go Frontend
- [ ] 2.1 Add `github.com/minio/minio-go/v7`; config (`MINIO_ENDPOINT/ACCESS/SECRET/BUCKET`); client helper (no-op when unset)
- [ ] 2.2 `UploadPhoto` → PutObject (`tags/{id}.{ext}`) → set `photo_url=/photos/tags/{id}.{ext}`; new `GET /photos/{key...}` handler streaming GetObject with content-type + cache headers; route in main.go
- [ ] 2.3 Build + verify: upload via HTTP → object in MinIO → public page + `/photos/…` serve 200
- [x] 2.1 Add `github.com/minio/minio-go/v7`; config (`MINIO_ENDPOINT/ACCESS/SECRET/BUCKET`); client helper (no-op when unset)
- [x] 2.2 `UploadPhoto` → PutObject (`tags/{id}.{ext}`) → set `photo_url=/photos/tags/{id}.{ext}`; new `GET /photos/{key...}` handler streaming GetObject with content-type + cache headers; route in main.go
- [x] 2.3 Build + verify: upload via HTTP → object in MinIO → public page + `/photos/…` serve 200
## 3. Laravel Admin
- [ ] 3.1 `composer require league/flysystem-aws-s3-v3`; `config/filesystems.php` `minio` disk (endpoint .13:9000, use_ssl false); `admin/.env` MINIO creds
- [ ] 3.2 TagResource: photo `FileUpload` on the `minio` disk (path `tags/`), URL = `https://where-woof.com/photos/{path}`; verify upload from admin UI
- [x] 3.1 `composer require league/flysystem-aws-s3-v3`; `config/filesystems.php` `minio` disk (endpoint .13:9000, use_ssl false); `admin/.env` MINIO creds
- [x] 3.2 TagResource: photo `FileUpload` on the `minio` disk (path `tags/`), URL = `https://where-woof.com/photos/{path}`; verify upload from admin UI
## 4. Migration & Deploy
- [ ] 4.1 One-off copy `static/uploads/*` into MinIO (matching keys)
- [ ] 4.2 Deploy: frontend env (`MINIO_*` in ~/.config/where-woof.env) + rebuilt binary + restart; admin .env + rebuild container
- [ ] 4.3 Live round-trip: upload a photo via where-woof.com → loads; via admin → loads
- [ ] 4.4 `openspec validate photo-object-storage`; commit
- [x] 4.1 One-off copy `static/uploads/*` into MinIO (matching keys)
- [x] 4.2 Deploy: frontend env (`MINIO_*` in ~/.config/where-woof.env) + rebuilt binary + restart; admin .env + rebuild container
- [x] 4.3 Live round-trip: upload a photo via where-woof.com → loads; via admin → loads
- [x] 4.4 `openspec validate photo-object-storage`; commit

View File

@@ -180,7 +180,7 @@ admin.where-woof.com {
| 3 | HTMX / Alpine polish — inline edit, animations | ✅ |
| 4 | Laravel admin: users, tags, dashboard (same Postgres) | ✅ |
| 5 | Billing: Stripe (AU), plans, scan-limit enforcement, invoices | 🟡 mechanism done (paid-gating + limits, no gateway) |
| 6 | Photo uploads + object storage | |
| 6 | Photo uploads + object storage | ✅ (MinIO on .13) |
| 7 | Deploy front-end to .13, Caddy, DNS, InMotion redirect | ✅ (service live; DNS pending) |
| 8 | Deploy admin to .13 | ⬜ |
| 9 | Anti-abuse hardening: relay numbers, rate limits | ⬜ |