Hello all. I am following the tutorials at Develop for Nextcloud: App development tutorials to lean a little about NextCloud app development and have ran in to a number of issues that makes me think I am missing something. My OS is Kubuntu.
I think I got through the first step of setting up a development environment without much issue. I skipped the docker desktop as I would rather just use the terminal. I also installed VS code and started a project at nextcloud-docker-dev/workspace/server/.
I then went ahead told it open using dev container. I was thinking that should simplify environment set up but now I am not sure.
After starting dev container I could not access the NextCloud webpage. I eventually figure out it was because apache failed to start and that was because of permission issues with data folder. I am not sure why that would have permission issues as I never touched it. I wonder now if there was an install error and I manually ran the bootstrap.sh script as sudo. Not sure if that was it.
I ran into issues with it wanting database config information but that went way once I got permissions on the data folder correct. Or maybe it was something else. I tried a lot of things.
Then I installed the helloworld app and ran into issues with it not showing up. That ended having to do with permission on the app-exta folder. Most of the other folders permission were fine.
Some were along the line I found I had to run npm install and npm run build on the hello world app. The tutorial says nothing about that.
Also, all the host file mappings like http://nextcloud.local do not work but localhost does.
I have not found a fix for the next issue yet. I am unable to enable or disable apps through the Nextcloud webpage. The occ command works. It is a permission error and the best I can tell is that apache is stripping or failing to forward the Authorization header required by Nextcloud.
AI thinks it is because mod_rewrite is not loaded. Does all this sound like reasonable set up issues or am I going the wrong way trying to use dev container?
I personally use the dev containers for developing on the cookbook app (I am the maintainer) and to do some jacks on the server or other apps. I do not remember having serious problems. At least no permission stuff afaik.
Last time, I installed a new user, I had to clone the git to from Julius, run the bootstrap once, adjust the environment file and die up textbook and the reverse proxy. Letting the helper script adjust the file /etc/hosts (this is the only time I need for rights using sudo if I am correct) letās me directly access the instances as I need.
A server is installed as part of the bootstrap process. It needs some time to setup and you must not interrupt this process. Opening the website will eventually show you some progress logs (or look at the docket logs).
So, you try to work within the dev container using the vs code plug-in? I would not do that. All files are intentionally mounted from the project folder to allow access to those files that you need access to (server and app code). Only when doing step debugging, you need to adjust some paths.
At least this is how I use it without problems.
Yeah, most apps need building the frontend using vite or similar to show any useful content. Also the backend might need dependencies using composer. If that was mentioned in the tutorial, I have not checked. @edward maybe this is done feedback for you.
What happens in a terminal outside of vs code when you type curl -v http://nextcloud.local?
Before using the dev env, I would fix any issues. So, letās postpone the curl app enabling for the moment, okay?
I am not sure about the VS Code plug-in but as I use dev containers they are a VS Code or IDE thing. Instead of running docker compose up nextcloud and starting docker containers out side of the development environment, I tell VS Code to restart in dev container and it start up a dev container (a docker container) as defined in workspace/server/.devcontainer/devcontainer.json and runs the VS Code environment inside the container.
On my host accessing http://nextcloud.local it says āAccess through untrusted domainā. I know that would be easy to fix but the way I think of it, the whole point of a dev container is all that stuff is define already.
I spend so much time trying to get this to work that I feel kind of invested, but I should just go back do it the normal docker way.
Also, thanks for your reply. It is valuable to hear from someone that has more experience with NextCloud development.
First, I am unsure if that config actually uses or starts a DB server (MariaDB/PostgreSQL) or plainly assumes SQLite.
Further, this is intended to be used in a web-based session (e.g. on GitHub) to configure a session. It is not intended as a base config for local development, although it might work out.
Third and most important, this is a config of the server. It is not Julius config. You are sort of intermixing and creating kind of 2 dev environments. One on Julius containers and one inside the containers of VS code. The one in .devcontainer.json will not know of the setup from Julius and not use the fancy bells and whistles.
At least it will use its own config which might conflict with the default settings from Julius.
What I would do in your situation:
Stop all related containers. Disable VS code (shut down or use new profile). Checkout Julius Repo in a different location (just for testing). Check the bootstrap if it will start the containers immediately. Eventually disable the single line with docker compose up. Run it. Change the compose project name in .env file. Bring the relevant containers up. Wait for it and directly open the browser.
Once this works, you can see in VS code to access the folder again.
I did some more testing. I cloned a new repo and used docker compose up nextcloud to start NextCloud and ran my development environment locally. It mostly worked as expected. I had to install nvm, npm, and node on my host system and was able to add the helloworld app and build it.
So then I tried another clone and started a dev container again. I started it up and it worked perfectly this time! Of course, I did not have to install dev tools or some VS Code extension because they was in the dev container. I installed hello world app and that even worked without building so it may be a lack of tools on my host system that made it not work without building.
If that was the end of the story, then I would be back to using dev container but it is not. As soon as I rebuilt the dev container it broke again and started asking me set up an account and provide the database credentials. Copilot thinks it is because it was generating a new database username and password on each start so it would think it was initialized but not be able to access the database (my understanding). I tested a few things and it seems that is correct. Explicitly setting the database credentials seemed to fix it but on my final test I cleaned up some other changes I had made, including removing the :z from one of the mounts and it broke again with a permission error.
I have used dev container before in another large project I work on and it has been very robust about maintaining a development environment with all the tools and extensions I use. But clearly this is focused on something different or just not getting much attention. Maybe it was set up for testing on github and nothing more. I do not have much experience with dev container on github. It would be nice if someone would put some work into getting the dev container to work correctly for a local development environment, but for now I am just going to go with manually setting my development environment. It is not that hard.
If anyone else uses dev container for local development it would be interesting to hear about your experience. Thanks all.
The docker environment is somehow usefull, but like youāve described, i dislike the inconvenience to restart each time from scratch. Iād rather to have a ālivingā Nextcloud, with agendas, groupfolders, files, plenty of users, like in real life.
Installing a fresh Nextcloud on a development server takes about 15 minutes. If you have php-fpm and nvm, you can switch easily from one nextcloud to another. The only inconvenient, is that you need to keep your Nextcloud dev environment with one specific version. The database can only upgrade, never downgrade. So I have one Nextcloud dev environment per major version, and one in āmasterā. The rest is done exclusively with Git. I keep one docker (julius) for very specific usage, but i didnāt used it for a year i guess.
May I ask you, why you need to start from scratch? I installed my Dev NC probably > 1 year ago and reused it since that. Are you talking about docker compose up or actually setting up the instance?
With the docker, when I switch from NC version (wich i do very frequently, as iām working for clients between NC29 and NC34), I need to scratch my Nextcloud db. So instead of loosing my data or having multiple containers, I made the choice to have ārealā Nextcloud. At least, I feel like being more close to the production reality, and understand which architectural components are (or are not) provided by the docker. I lost more time with the docker environment than with my ārealā environments. Iāve tested both, I made my choice. I fully respect and understand devs who use the Julius docker, but John2 was requiring experiences.I just give mine.