Skip to content
SHC Docs

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:

home01
$ 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 ls
NAME URL APP COUNT PRIORITY TENANT ID ENVIRONMENT SYNCED AT
shc https://selfhostedcloud.org/apps/0.1/index.yaml 1550 50 system 2 system 2026-11-06T17:50:26.785753271Z
shipped shipped://apps 1 10 system 1 system 2026-11-06T17:37:14.005243412Z

A 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.

~/learn/versitygw/app.yaml
name: versitygw
version: "1.8.0"
title: Versity S3 Gateway
description: An S3 server over a directory, with an s3 socket
category: storage
license:
id: Apache-2.0
vars:
root:
user@string!: root user
password@secret!: root password
~/learn/versitygw/vars.yaml
root:
user: learn
password: P@ssw0rd
~/learn/versitygw/s3.socket.yaml
schema:
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 password
data:
endpoint: "{{ environment }}.versitygw.{{ stack }}"
port: 9000
accessKey: "{{ vars.root.user }}"
secretKey: "{{ vars.root.password }}"
~/learn/versitygw/compose.yaml
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: 256M
volumes:
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.

home01
$ shc install ~/learn/versitygw -s store
installing 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.

home01
$ 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:80
installing 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 ls
CONSUMER STACK NAME CONSUMER PLUG PROVIDER STACK NAME PROVIDER SOCKET STATUS ID
cloud postgres db postgres connected 0
cloud s3 store s3 connected 0
pgweb postgres db postgres connected 0

Nextcloud’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:

home01
$ grep -A3 '^data:' /var/lib/shc/deployments/prod/cloud/prod/app/postgres.plug.yaml
data:
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.yaml
data:
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.

home01
$ 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:

~/learn/hello.txt
Hello from SHC.
home01
$ 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.txt
Hello 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:

home01
$ shc exec -s store -S versitygw -- grep -r -l 'Hello from SHC.' /data/cloud-prod
/data/cloud-prod/urn:oid:78

A 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.

explained, not walked: this ladder runs one Postgres, and a provision prepares a second
$ shc integration provision cloud --integrate postgres=db2
$ shc update cloud -i postgres=db2

Read Underneath Nextcloud before going on; it reads what this page left running.

Next: A vapp and an add-on.