forked from mtusi2026/mtusi2026lab4
lab4: вложения в приватном S3 (SeaweedFS), метаданные в PostgreSQL
- compose: сервис s3 (SeaweedFS 4.46 по digest, volume s3data, внутренняя сеть storage,
web-интерфейсы только на 127.0.0.1 внутри контейнера), одноразовый s3-init;
- три пары ключей S3: admin (только bootstrap), api (Read+Write своего bucket),
reconciler (+List); bootstrap идемпотентен и проверяет приватность и права;
- миграция 0004: attachments (pending -> ready, случайный object_key), message_attachments,
post_message_v2 с проверкой вложений в той же транзакции;
- POST /chats/{id}/attachments: лимиты до чтения/декодирования, потоковая проверка PNG
(CRC + zlib до точного размера), JPEG через djpeg -strict, семафор загрузок;
- GET метаданных и /content (стриминг из S3, без redirect), readiness с S3,
HAProxy: деградированный режим без S3 через /health/ready/core;
- janitor незавершённых загрузок с grace period.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d916d09f7b
commit
335df4b2b2
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# Entry point of the compose service `s3` (SeaweedFS 4.46, one container: master + volume +
|
||||
# filer + S3 gateway). Renders the S3 identities from Docker secrets, then execs `weed`.
|
||||
#
|
||||
# Identities (SeaweedFS s3.json, actions scoped to the bucket):
|
||||
# bootstrap-admin Admin (create bucket) -> only s3-init has these keys
|
||||
# messenger-api Read + Write on S3_BUCKET -> API replicas (no List, no Admin)
|
||||
# messenger-reconciler Read + Write + List on S3_BUCKET -> reconciler CLI (needs the listing)
|
||||
# There is NO anonymous identity, so every unsigned request is refused: the bucket is private.
|
||||
#
|
||||
# Exposure: master (9333), volume (8080), filer (8888) with their web UIs and gRPC listen on
|
||||
# 127.0.0.1 INSIDE the container only (-ip.bind); only the S3 API port 8333 listens on the
|
||||
# container network `storage` (internal, not published on the host). Telemetry is off.
|
||||
set -eu
|
||||
umask 077
|
||||
secret() { tr -d '\r\n' < "/run/secrets/$1"; }
|
||||
bucket="${S3_BUCKET:?S3_BUCKET is required}"
|
||||
cat > /tmp/s3.json <<EOF
|
||||
{
|
||||
"identities": [
|
||||
{"name": "bootstrap-admin",
|
||||
"credentials": [{"accessKey": "$(secret s3_admin_access_key_id)", "secretKey": "$(secret s3_admin_secret_access_key)"}],
|
||||
"actions": ["Admin", "Read", "Write", "List", "Tagging"]},
|
||||
{"name": "messenger-api",
|
||||
"credentials": [{"accessKey": "$(secret s3_api_access_key_id)", "secretKey": "$(secret s3_api_secret_access_key)"}],
|
||||
"actions": ["Read:${bucket}", "Write:${bucket}"]},
|
||||
{"name": "messenger-reconciler",
|
||||
"credentials": [{"accessKey": "$(secret s3_reconciler_access_key_id)", "secretKey": "$(secret s3_reconciler_secret_access_key)"}],
|
||||
"actions": ["Read:${bucket}", "Write:${bucket}", "List:${bucket}"]}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
exec weed server \
|
||||
-dir=/data \
|
||||
-ip=127.0.0.1 -ip.bind=127.0.0.1 \
|
||||
-master.telemetry=false \
|
||||
-master.volumeSizeLimitMB=1024 -volume.max=0 \
|
||||
-filer -filer.disableDirListing \
|
||||
-s3 -s3.ip.bind=0.0.0.0 -s3.port=8333 -s3.config=/tmp/s3.json \
|
||||
-s3.iam=false -s3.autoCreateBucket=false -s3.port.iceberg=0 -s3.port.lance=0
|
||||
Reference in New Issue
Block a user