Nextcloud on Postgres
Nextcloud keeps its records in Postgres and its files in an S3 bucket. The
Postgres is db from the earlier pages. The S3 server is the Versity S3
Gateway, from a directory you write, with a socket like the one Postgres
offers.
Nextcloud is in the public app catalogue, the repository shc that
shc init registered. On a cluster that removed it, as the cluster ladder’s
repositories page does, this line adds it back; on one that has it, the same
line answers the repository that is there:
$ shc repo add shc https://selfhostedcloud.org/apps/0.1/index.yaml✔ added repository "shc" from https://selfhostedcloud.org/apps/0.1/index.yaml$ shc repo lsNAME URL APP COUNT PRIORITY TENANT ID ENVIRONMENT SYNCED ATshc https://selfhostedcloud.org/apps/0.1/index.yaml 1550 50 system 2 system 2026-11-06T17:50:26.785753271Zshipped shipped://apps 1 10 system 1 system 2026-11-06T17:37:14.005243412ZA repository added without -t serves the whole cluster, like shipped.
Create these four files on home01. The socket tells a plug where the gateway answers and which user to sign in as.
name: versitygwversion: "1.8.0"title: Versity S3 Gatewaydescription: An S3 server over a directory, with an s3 socketcategory: storagelicense: id: Apache-2.0vars: root: user@string!: root user password@secret!: root passwordroot: user: learn password: P@ssw0rdschema: plug: bucket@string!: bucket the plug writes to accessKey@string: user the plug signs in as secretKey@secret: that user's password socket: endpoint@string!: host the gateway answers on port@port!: port the gateway answers on accessKey@string!: root user secretKey@secret!: root passworddata: endpoint: "{{ environment }}.versitygw.{{ stack }}" port: 9000 accessKey: "{{ vars.root.user }}" secretKey: "{{ vars.root.password }}"services: versitygw: image: versity/versitygw:v1.8.0 command: ["--port", ":9000", "--health", "/health", "posix", "/data"] environment: ROOT_ACCESS_KEY: "{{ vars.root.user }}" ROOT_SECRET_KEY: "{{ vars.root.password }}" expose: - "9000" volumes: - data:/data healthcheck: test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:9000/health"] interval: 10s retries: 6 deploy: resources: limits: cpus: "0.5" memory: 256Mvolumes: data:s3.socket.yaml is a socket named s3. Its schema says what a plug sends
(plug) and what the socket answers (socket), and data is that answer,
filled from this deployment’s own names and variables. A socket can also
carry jobs, as Postgres’s does; this one needs none. See
Plugs and sockets. The other
three files take the shape pgweb’s did.
$ shc install ~/learn/versitygw -s storeinstalling deployment "store"[store] Healthy 1/1✔ versitygw healthy✔ installed deployment "store"Nextcloud’s plug s3 connects to store, and its plug postgres to db.
The plug sends its own user and password to the gateway, so give it the
gateway’s. The admin password is set too, for the WebDAV check below.
$ shc install nextcloud -s cloud -i postgres=db -i s3=store --var s3.accessKey=learn --var s3.secretKey=P@ssw0rd --var admin.password=P@ssw0rd --expose 8082=nextcloud:80installing deployment "cloud"[cloud] Healthy 5/5✔ nextcloud healthy✔ nextcloud-cron healthy✔ nextcloud-pgclient healthy✔ notify-push healthy✔ valkey healthy✔ installed deployment "cloud"exposure: lan$ shc integration lsCONSUMER STACK NAME CONSUMER PLUG PROVIDER STACK NAME PROVIDER SOCKET STATUS IDcloud postgres db postgres connected 0cloud s3 store s3 connected 0pgweb postgres db postgres connected 0Nextcloud’s two plugs are catalogue files. The leader keeps a copy of the
package each deployment was installed from, and their data blocks are what
each plug sends:
$ grep -A3 '^data:' /var/lib/shc/deployments/prod/cloud/prod/app/postgres.plug.yamldata: database: "{{ vars.postgres.database | default((stack ~ '_' ~ environment) | replace('-', '_')) }}" username: "{{ vars.postgres.username | default((stack ~ '_' ~ environment) | replace('-', '_')) }}" password: "{{ vars.postgres.password }}"$ grep -A3 '^data:' /var/lib/shc/deployments/prod/cloud/prod/app/s3.plug.yamldata: bucket: "{{ vars.s3.bucket | default((stack ~ '-' ~ environment) | replace('_', '-')) }}" accessKey: "{% if vars.s3.ownKey %}GK{{ vars.s3.ownKeyId }}{% elif vars.s3.minioKey %}{{ vars.s3.minioKeyId }}{% else %}{{ vars.s3.accessKey }}{% endif %}" secretKey: "{% if vars.s3.ownKey %}{{ vars.s3.ownKeySecret }}{% elif vars.s3.minioKey %}{{ vars.s3.minioKeySecret }}{% else %}{{ vars.s3.secretKey }}{% endif %}"The s3 plug sends vars.s3.accessKey and vars.s3.secretKey, which is why
the install set them to the gateway’s user and password.
Run the curl command again if the published port is not answering yet.
$ curl -s http://localhost:8082/status.php{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"34.0.2.1","versionstring":"34.0.2","edition":"","productname":"Nextcloud","extendedSupport":false}Write a file through WebDAV and read it back:
Hello from SHC.$ curl -s -u admin:P@ssw0rd -T ~/learn/hello.txt http://localhost:8082/remote.php/dav/files/admin/hello.txt$ curl -s -u admin:P@ssw0rd http://localhost:8082/remote.php/dav/files/admin/hello.txtHello from SHC.Nextcloud made bucket cloud-prod on the gateway, which keeps a bucket as a
directory and an object as a file in it. The object holding hello.txt:
$ shc exec -s store -S versitygw -- grep -r -l 'Hello from SHC.' /data/cloud-prod/data/cloud-prod/urn:oid:78A plug can move to another provider of its socket. shc integration provision
prepares the new provider first: it runs the socket’s provision jobs there
with the plug data the deployment’s own vars render. For Postgres that
creates the database and its login role, sets the role’s password from the
deployment’s vault var, and matches the encoding and collation of the
database the plug is on now. cloud stays bound to db meanwhile. Restore
its data into the new provider, then shc update cloud -i postgres=db2
moves the plug and finds db2 prepared.
$ shc integration provision cloud --integrate postgres=db2$ shc update cloud -i postgres=db2Read Underneath Nextcloud before going on; it reads what this page left running.
Next: A vapp and an add-on.