S3 storage (MinIO)
S3 storage gives a project its own S3-compatible bucket storage on its server, next to PostgreSQL, so apps can keep uploads, images and files without an outside service.
Create a storage
- Open a project and press New service → S3 storage (MinIO).
- Give it a name, such as
shop-files. Apps in the project reach it athttp://shop-files:9000. - Optionally tick Give it a web address (
shop-files.example.com, with HTTPS). You need one if browsers should load files from public buckets or signed links, or if you want to use S3 tools from your computer. - Name the first bucket (
filesunless you change it) and choose whether anyone with the link may read it, then press Create.
Each storage is its own container running a patched MinIO image (pinned to the digest it pulled), with 256 MB of memory by default and its data in its folder on the server. It has no published port: only the project's services reach it, plus the web address if you turned one on, which Monitoring then watches.
Storage needs the clubctl from the release that added it. On an older server the create fails with a clear message: run the services VM setup again (see Update clubctl), then press Try again.
Buckets
A storage holds up to 20 buckets. Under Buckets on its page:
- Add a bucket: 3 to 63 lowercase letters, digits and hyphens.
- Who can read: Apps only (they use the key, or hand out signed links) or Anyone with the link (for images on a website). A public bucket's files are at
https://shop-files.example.com/<bucket>/<file>. - Remove: only an empty bucket is removed. Delete its files first, from an app or with an S3 tool.
File counts and sizes per bucket are checked every 5 minutes.
Link storage to an app
In the app's settings, under Databases and storage, tick the storage and pick a bucket. The app restarts with:
S3_ENDPOINT=http://shop-files:9000
S3_PUBLIC_URL=https://shop-files.example.com
S3_REGION=us-east-1
S3_BUCKET=uploads
S3_ACCESS_KEY_ID=…
S3_SECRET_ACCESS_KEY=…
S3_FORCE_PATH_STYLE=true
- With no prefix, the app also gets the
AWS_*names (AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION…) that AWS SDKs read, so most S3 libraries work without code changes. - For a second storage or bucket, give it a prefix such as
MEDIA_: the app getsMEDIA_S3_ENDPOINTand so on. - One value in any setting works too:
FILES_URL=${{shop-files.S3_PUBLIC_URL}}.
The secret key is filled in on the server, so it never appears in the app's settings in the console. Use path-style addressing in your S3 client.
// Node, AWS SDK v3
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'
const s3 = new S3Client({
endpoint: process.env.S3_ENDPOINT,
region: process.env.S3_REGION,
forcePathStyle: true,
})
await s3.send(new PutObjectCommand({ Bucket: process.env.S3_BUCKET, Key: 'hello.txt', Body: 'hi' }))
Hand browsers a signed link (or the public URL for a public bucket) built on S3_PUBLIC_URL, since S3_ENDPOINT only works inside the project.
Keys
- Keys are made on the server and never stored by the console.
- Connect shows the values an app needs; Show the secret key reads it over SSH once, and each time is written to the access log.
- New keys rotates the app key and restarts the apps that use it.
Using S3 tools from your computer
With a web address turned on, any S3 tool can use it as the endpoint with the values from Connect:
aws s3 ls s3://uploads --endpoint-url https://shop-files.example.com
mc alias set shop-files https://shop-files.example.com KEY SECRET
Without a web address, only apps in the project can reach the storage.
Quota
Each storage has a soft quota (10 GB by default, under Settings). The alert addresses get an email at 80% and 100%. Writes never stop: the server's disk is the real limit, so keep an eye on it on the Servers page.
Backups and removing
- Storage is backed up with your other services to your backup bucket: every bucket's files, stored once per content and encrypted. Restoring puts the whole storage back as it was, or makes a copy.
- Remove this storage (owners) takes a final backup, then moves its data aside on the server.
The storage's page
Connect, Buckets, About (address, apps using it, size against the quota), Backups, Logs and History, plus Settings for memory (changing it restarts the storage for a few seconds), quota, web address and notes. On the project diagram, storage sits in the bottom row (now called Data) with its own icon, and apps have lines to the storage they use.