Federated Nextcloud Development Environment
November 28, 2024 • #Docker #Nextcloud
Verifying one feature I had to implement requires two Nextcloud development instances talking to each other. This is how I figured it out.
This may mark the first post in a slight adjustment of course in regard to the content I write about. I started a new job as an iOS developer at Nextcloud and hence will be much more active in that context. I figured it is an opportunity to extend the scope of my articles.
In its core, Nextcloud can be quite simple and straight forward, in my opinion. It can be stripped down to a bare minimum. But if you like to, a Nextcloud deployment can be extended to a complicated swiss army knife. I still know Nextcloud from when it was only a ZIP you can throw on a shared hosting space. By now, with all the features, it is much more complicated and I am glad that the offering of Nextcloud All-in-One exists. It turns a deployment into pure joy.
Such All-in-One deployment is sufficient on most occassions when you are working on native client apps. You have an easy to manage and secure instance safe to deploy on a public virtual private server.
Local Development Environments
Though, at some point, it can become inevitable to have a local development environment of Nextcloud. Maybe independence from the internet connection matters, maybe you want to save the cost of a virtual private server, maybe you need to develop a Nextcloud server app in conjunction with your client app.
There are multiple solutions out there already, some by Nextcloud developers themselves. In example the Nextcloud easy test instance which is a good and straightforward choice in case you need a temporary and local server to run integration tests against in Xcode. But it is rather stripped down to the most important parts.
A much more feature complete offering is nextcloud-docker-dev maintained by Julius Knorr. It has its own expansive documentation showing how to easily set up different stable major versions or how to prepare self-signed certificates. This project is the starting point.
Federation
Being new to the whole topic, I did not find the information of how to set up multiple instances in parallel immediately. Only after asking and being pointed to the Nextcloud Talk API documentation which describes a federated setup explicitly, things fell together for me.
The bootstrap script of the nextcloud-docker-dev
project sets up a lot of local domains but also a proxy server which takes care of necessary routing for multiple Nextcloud instances.
So, running these two shell commands in the nextcloud-docker-dev
directory spins up two independent Nextcloud instances:
docker compose up nextcloud
docker compose up nextcloud2
They are available on nextcloud.local
and nextcloud2.local
.
In the end I could not tell anymore whether the manual installation of the notifications app or the self-signed certificates made the difference but the federated sharing between these two local instances worked after that.
Setting up a rather complex Nextcloud development environment can be daunting at first when you are new to the topic.