Contributing to Nextcloud with Docker
The other day I wanted to debug a Nextcloud app which I am using quite frequently. To have a local environment would be a good start, however I do not like to install everything on my system (as it is described in the Nextcloud docs). So what can we do? Docker, of course. I found two repos on github which were promoting docker Nextcloud development environments, this one and this one.
To make it short: the first one seemed a bit outdated and didn’t work anyway. The second one was working after a few hiccups.
What you need:
docker
docker-compose
git
Have it already? Then let’s go.
1. Clone the project
git clone https://github.com/juliushaertl/nextcloud-docker-dev.git
2. Clone Nextcloud server
cd nextcloud-docker-dev
git clone https://github.com/nextcloud/server.git
cd server
git submodule update --init
pwd
cd ..
3. Set up env for Nextcloud server
Create an .env file in the root folder of nextcloud-docker-dev containing some specific variables:
COMPOSE_PROJECT_NAME=master
REPO_PATH_SERVER=/home/jus/repos/nextcloud/server
ADDITIONAL_APPS_PATH=/home/jus/repos/nextcloud/server/apps-extra
NEXTCLOUD_AUTOINSTALL_APPS="viewer activity"
# can be used to run separate setups besides each other
DOCKER_SUBNET=192.168.15.0/24
PORTBASE=815
# Main dns names for ssl proxy
# This can be used to append a custom domain name to the container names
DOMAIN_SUFFIX=.local
Enter your REPO_PATH_SERVER as per the pwd from step 2. The ADDITIONAL_APPS_PATH is the place where you can put the apps you want to work on.
4. Set up hosts
The reverse proxy is resolving the domain nextcloud.local, add it to your /etc/hosts/ to reach it
127.0.0.1 nextcloud.local
If you forget this step, you will not be able to open Nextcloud from your browser.
5. Spin up the containers
docker-compose up proxy nextcloud
This command starts the revproxy (nginx), nextcloud, the database (postgres) and mailhog (whatever that is for, lol). After a small installation process you are ready to go.
There are some more containers in the docker-compose, which I do not need for developing. That’s why I am ok with the command mentioned above.
6. Open Nextcloud in browser
As set up in step 4, you can simply open nextcloud.local and you are good to go.
Log in with one of the user names mentioned in the set up process. I do not remember all of them, but some are these:
jane
admin
alice
bob
user1
Password is the username.
7. Start developing
Pull the apps you want to develop to the folder described in ADDITIONAL_APPS_PATH.
Make sure you enable them in the Nexctloud app menu using the admin login.
Happy contributing!