SphereFiles
A SphereFiles volume is shared storage. When you deploy, the new spherelet starts before the old one stops, so for a short time both have the volume mounted. Don't keep a database's data directory (PostgreSQL, MySQL, MongoDB, SQLite) on a SphereFiles volume: two copies writing the same files can lose or corrupt data. Use SphereDB for PostgreSQL.
SphereFiles gives your environment a file volume that several services can mount at once. Use it for user uploads, media, shared assets, or a folder of files that a web service writes and a worker reads.
A service's own filesystem is lost on restart. A SphereFiles volume is shared: up to 63 mounts across the services of one environment.
Regions: US East and Sweden.
Sizes and prices
You pay a fixed monthly price for the size you pick: $0.25 per GB a month. Billed yearly, a size costs ten times its monthly price.
| Size | Per month | Per year |
|---|---|---|
| Files 10 GB | $2.50 | $25 |
| Files 50 GB | $12.50 | $125 |
| Files 100 GB | $25 | $250 |
| Files 250 GB | $62.50 | $625 |
| Files 500 GB | $125 | $1,250 |
What each plan can create:
| Plan | Volumes per environment | Largest size |
|---|---|---|
| Hobby | 1 | Files 10 GB |
| Pro | 5 | Files 1 TB |
| Team | 10 | Files 4 TB |
| Enterprise | Any | Files 16 TB |
Sizes above Files 500 GB aren't offered in any region right now.
Create a volume
From the environment's options menu, choose Storage management. Under SphereFiles volumes, choose New volume, pick a name and a size, and choose Create volume. The dialog shows what the volume adds to your bill. Billing starts when it's created, monthly or yearly, matching your plan.
Mount it into a service
Open the volume, and under Mounts choose Add mount: pick the service and the Mount path where the files appear in the service, for example /data/uploads, then choose Mount volume. Every service that mounts the same volume sees the same files. A volume can have up to 63 mounts.
Only services in the volume's own environment can mount it. Adding or removing a mount, or changing its path, restarts that service's spherelets one at a time: a new spherelet is ready before an old one stops, so there's no downtime.
Read-only mounts: mark a mount read-only, and that service can read the files but its writes fail.
Mount a folder: instead of the whole volume, mount one folder inside it, for example uploads/images. Each folder name uses letters, numbers, ., _ and -, starts with a letter, a number or _, and is at most 128 characters; . and .. aren't allowed. A folder can be at most 16 folders deep.
You can't mount a volume at /etc/computesphere or inside it: that path is reserved for the platform. Each path on a service takes one volume.
File ownership: files written as root are stored as user 1000; other users keep their own user ID. New files and folders take group 1000. Make sure the users your services run as can read and write the folders they use.
Images that start as root
Some images start as root and change the owner of their data folder before switching to their own user. The official postgres image works this way. On a volume, root can't change who owns a file, so these images stop at startup: the deploy fails, the deploy logs show an error like chown: changing ownership of '/var/lib/postgresql/18/docker': Operation not permitted, and the mount shows The service didn't start with this volume mounted.
For a database, use SphereDB rather than a volume.
To run an image like this on a volume anyway, start it as user 1000, which owns the volume's folders, and keep its data in a folder of the mount. For the official postgres image as a private service:
- Mount the volume, or a folder of it, at
/data. - Set the environment variables
PGDATAto/data/pgandPOSTGRES_PASSWORDto a password of your own. - Set the Start command (
start_commandin the API) to:
sh -c 'getent passwd 1000 >/dev/null || echo "postgres1000:x:1000:1000::/tmp:/bin/sh" >> /etc/passwd; getent group 1000 >/dev/null || echo "postgres1000:x:1000:" >> /etc/group; exec gosu 1000:1000 docker-entrypoint.sh postgres'
The command adds user 1000 to the image and starts the image's own entrypoint as that user. The logs show chmod: changing permissions of '/run/postgresql': Operation not permitted at startup; it's harmless, and the database starts.
Until the volume is mounted, the service keeps restarting with mkdir: cannot create directory '/data': Permission denied and writes nothing. Adding the mount restarts the service, and from then on the database starts on the volume, and later deploys find it there.
Several services writing at once
Every service that mounts a volume read-write can change its files at the same time, even from different spherelets. If two services might write the same file at the same moment, use standard file locks in your app, or give each service its own folder. A lock file that holds only a process ID, as a database's does, doesn't stop the old and new spherelets of a deploy from writing at the same time. One writer with many readers, or services that each write their own files, needs nothing extra.
A volume is shared network storage, built for files, uploads and media. Run databases on SphereDB, not on a volume.
Browse the files
Open the volume, and under Files choose Browse files to browse, upload and download its files from the console. See File browser.
Grow a volume
Open the volume, and under Size choose Make larger. You can grow a volume once any change it's making has finished; it shows Growing until the new size is ready. You don't need to remove its mounts. Growing pauses the volume, usually for a few minutes: services using it can't read or write its files during the pause, then carry on. If a larger size isn't available, the console says Larger sizes aren't offered in this region right now. You can't shrink a volume: create a smaller one and copy your files over.
Restore points
SphereFiles doesn't take restore points. Keep a copy of files you can't lose: download them with the file browser, or have a job copy them somewhere else.
Delete a volume
Open the volume, and in the Danger zone choose Delete volume. Unmount it from every service first: a volume that's still mounted can't be deleted. Deleting a volume deletes every file in it, and it can't be undone.
Limits
- Up to 63 mounts per volume, in one environment.
- SphereFiles volumes don't offer high availability.