Compare commits

...

18 Commits

Author SHA1 Message Date
Baptiste Fotia 201da97178 docs(md): Apply the Julius' request change
https://github.com/juliushaertl/nextcloud-docker-dev/pull/87#discussion_r995661925

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-14 15:53:39 +02:00
Baptiste Fotia e3594fe5c4 doc(md):Specify stop containers and run background
I specified how to stop containers (Ctrl+C) and run containers in the
background.

https://github.com/juliushaertl/nextcloud-docker-dev/pull/87#discussion_r995663846

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-14 15:47:23 +02:00
Baptiste Fotia 7442538c2f doc(md): Rewrite the Julius' alert
I rewrite the Julius' alert on the use of the project.

https://github.com/juliushaertl/nextcloud-docker-dev/pull/87#discussion_r995755834

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-14 15:23:11 +02:00
Baptiste Fotia 6625132927 doc(md): Change the doc to use the mysql prompt
We can use the "docker compose exec" command to be in the mysql prompt.

https://github.com/juliushaertl/nextcloud-docker-dev/pull/87#discussion_r995657456

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-14 15:18:10 +02:00
Baptiste Fotia 9b3ed6ee3c docs(md): Move configure-vars-env to manual-setup
I move the content of the configure-vars-env.md file to the
manual-setup.md file.

https://github.com/juliushaertl/nextcloud-docker-dev/pull/87#discussion_r995655130

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-14 14:59:31 +02:00
Baptiste Fotia 61db98eeee doc(md):Remove any ambigouity about Daphne README
I specify to read the README.md from tutorial by Daphne.

Read the Julius' comment : https://github.com/juliushaertl/nextcloud-docker-dev/pull/87#discussion_r995653977

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-14 14:17:42 +02:00
Baptiste Fotia 2b73c61480 Update README.md
I accepted this change

Co-authored-by: Julius Härtl <jus@bitgrid.net>
2022-10-14 14:11:02 +02:00
Baptiste Fotia a34c73df3b docs(md): Add the Daphne's Tutorial
Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-14 11:51:03 +02:00
Baptiste Fotia 1422c78fe8 Merge branch 'doc/improve-getting-started' of https://github.com/arawa/nextcloud-docker-dev into doc/improve-getting-started 2022-10-13 14:30:13 +02:00
Baptiste Fotia a32dec1516 docs(md): Add the bash type for markdown
Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-13 14:28:28 +02:00
Baptiste Fotia 998b7a06ed docs(md): Move the Useful commands section
I moved the Useful command section to a new file 'docs/useful-commands.md' where we can list all tips for using the container commands or how to use the docker command line.

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-13 14:24:17 +02:00
Baptiste Fotia 8f0ba7b3cb docs(md,env):REPO_PATH_SERVER is generic
The instructions on the REPO_PATH_SERVER env var are generic now.

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-13 14:09:53 +02:00
Baptiste Fotia f5ec329fd9 docs(md): Add a link to ssl.md
I forgot to add a link to ssl.md

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-13 12:05:46 +02:00
Baptiste Fotia b501b22a3b doc(md): Fix the default PHP release
Following the comment by @come-nc :
https://github.com/juliushaertl/nextcloud-docker-dev/pull/87#discussion_r994408112.

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-13 11:55:19 +02:00
Baptiste Fotia 13a001965c Update README.md
I approve the change by @come-nc

Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
2022-10-13 11:52:23 +02:00
Baptiste Fotia a0b2c1f45e docs(README): Fix markdown and add users test
I fixed of Markdown and I added others users test in the list.

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-13 10:32:13 +02:00
Baptiste Fotia 23f3cc9404 feature(bash): Use docker compose
Now, we can use docker compose and not docker-compose from docker 2.x.

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-12 16:46:24 +02:00
Baptiste Fotia dfe75ad54d docs(README):Rewrite README and reorganize the doc
I rewrite the README.md for readability and to attract the beginner
devs.

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
2022-10-12 16:06:49 +02:00
22 changed files with 518 additions and 309 deletions
+135 -302
View File
@@ -1,339 +1,172 @@
# nextcloud-dev-docker-compose
Nextcloud development environment using docker-compose
Hi beginner developer ! 👋
**DO NOT USE THIS IN PRODUCTION** Various settings in this setup are considered insecure and default passwords and secrets are used all over the place
This project allows you to start developing a Nextcloud app or contribute to Nextcloud server.
Features
This project is very **modular** where you can add [features](#different-feature-you-can-use).
So, you can use this project for your development environment only.
- ☁ Nextcloud
- 🔒 Nginx proxy with SSL termination
- 💾 MySQL
- 💡 Redis
- 👥 LDAP with example user data
- ✉ Mailhog
- 🚀 Blackfire
- 📄 Collabora
**DO NOT USE THIS IN PRODUCTION** Various settings in this setup are considered insecure and default passwords and secrets are used all over the place.
## Getting started
If you don't know how to install Docker, please, read this tutorial by Daphne Muller: https://cloud.nextcloud.com/s/iyNGp8ryWxc7Efa
Be careful : Read the "README.md" of the tutorial written by Daphne Muller first.
To get the setup running:
## Getting started 🎮
```
First, get the setup running:
```bash
git clone https://github.com/juliushaertl/nextcloud-docker-dev
cd nextcloud-docker-dev
./bootstrap.sh
sudo sh -c "echo '127.0.0.1 nextcloud.local' >> /etc/hosts"
docker-compose up nextcloud proxy
docker compose up nextcloud proxy
```
## Manual setup
Ok, let's go to understand these commands line !
### Nextcloud Code
First, you download the project with the git command, then you move to the `nextcloud-docker-dev` folder.
The Nextcloud code base needs to be available including the `3rdparty` submodule. To clone it from github run:
The `bootstrap.sh` script check if all requirements are present and prepares your workspace.
You have the `./workspace` folder where there is the `server` folder, the Nextcloud's core and [other Nextcloud versions](docs/running-stable-versions.md) if you want (the stable21, stable22, stable23, and so on).
```
git clone https://github.com/nextcloud/server.git
cd server
git submodule update --init
pwd
```
The last command prints the path to the Nextcloud server directory.
Use it for setting the `REPO_PATH_SERVER` in the next step.
So, you if you want to contribute to the Nextcloud's core, you can work in this folder directly !
### Environment variables
Then, you add `nextcloud.local` to your hosts file.
A `.env` file should be created in the repository root, to keep configuration default on the dev setup:
Finally, the `docker compose up nextcloud proxy` command line. This command line runs the nextcloud, proxy, redis and mailhog containers.
```
cp example.env .env
```
Replace `REPO_PATH_SERVER` with the path from above.
### Setting the PHP version to be used
The Nextcloud instance is setup to run with PHP 7.2 by default.
If you wish to use a different version of PHP, set the `PHP_VERSION` `.env` variable.
The variable supports the following values:
1. PHP 7.1: `71`
1. PHP 7.2: `72`
1. PHP 7.3: `73`
1. PHP 7.4: `74`
1. PHP 8.0: `80`
### Starting the containers
- Start full setup: `docker-compose up`
- Minimum: `docker-compose up proxy nextcloud` (nextcloud mysql redis mailhog)
### Running stable versions
The docker-compose file provides individual containers for stable Nextcloud releases. In order to run those you will need a checkout of the stable version server branch to your workspace directory. Using [git worktree](https://blog.juliushaertl.de/index.php/2018/01/24/how-to-checkout-multiple-git-branches-at-the-same-time/) makes it easy to have different branches checked out in parallel in separate directories.
Note that for performance reasons the server repository might have been cloned with --depth=1 by default. To get the full history it is highly recommended to run:
cd workspace/server
git fetch --unshallow
This may take some time depending on your internet connection speed.
```
cd workspace/server
git worktree add ../stable23 stable23
cd ../stable23
git submodule update --init
```
After adding the worktree you can start the stable container using `docker-compose up -d stable23`. You can then add stable23.local to your `/etc/hosts` file to access it.
Git worktrees can also be used to have a checkout of an apps stable brach within the server stable directory.
```
cd workspace/server/apps-extra/text
git worktree add ../../../stable23/apps-extra/text stable23
```
### Running into errors
If your setup isn't working and you can not figure out the reason why, running
`docker-compose down -v` will remove the relevant containers and volumes,
allowing you to run `docker-compose up` again from a clean slate.
## 🔒 Reverse Proxy
Used for SSL termination. To setup SSL support provide a proper DOMAIN_SUFFIX environment variable and put the certificates to ./data/ssl/ named by the domain name.
You might need to add the domains to your `/etc/hosts` file:
```
127.0.0.1 nextcloud.local
127.0.0.1 collabora.local
```
This is assuming you have set `DOMAIN_SUFFIX=.local`
You can generate it through:
```
awk -v D=.local '/- [A-z0-9]+\${DOMAIN_SUFFIX}/ {sub("\\$\{DOMAIN_SUFFIX\}", D " 127.0.0.1", $2); print $2}' docker-compose.yml
```
You can generate selfsigned certificates using:
```
cd data/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout nextcloud.local.key -out nextcloud.local.crt
```
### dnsmasq to resolve wildcard domains
Instead of adding the individual container domains to `/etc/hosts` a local dns server like dnsmasq can be used to resolve any domain ending with the configured DOMAIN_SUFFIX in `.env` to localhost.
For dnsmasq adding the following configuration would be sufficient for `DOMAIN_SUFFIX=.local`:
```
address=/.local/127.0.0.1
```
### Use valid certificates trusted by your system
* Install mkcert https://github.com/FiloSottile/mkcert
* Go to `data/ssl`
* `mkcert nextcloud.local`
* `mv nextcloud.local-key.pem nextcloud.local.key`
* `mv nextcloud.local.pem nextcloud.local.crt`
* `docker-compose restart proxy`
## ✉ Mail
Sending/receiving mails can be tested with [mailhog](https://github.com/mailhog/MailHog) which is available on ports 1025 (SMTP).
To use the webui, add `127.0.0.1 mail.local` to your `/etc/hosts` and open [mail.local](http://mail.local).
## 🚀 Blackfire
Blackfire needs to use a hostname/ip that is resolvable from within the blackfire container. Their free version is [limited to local profiling](https://support.blackfire.io/troubleshooting/hack-edition-users-cannot-profile-non-local-http-applications) so we need to browse Nextcloud though its local docker IP or add the hostname to `/etc/hosts`.
### Using with curl
```
alias blackfire='docker-compose exec -e BLACKFIRE_CLIENT_ID=$BLACKFIRE_CLIENT_ID -e BLACKFIRE_CLIENT_TOKEN=$BLACKFIRE_CLIENT_TOKEN blackfire blackfire'
blackfire curl http://192.168.21.8/
```
## 👥 LDAP
The LDAP sample data is based on https://github.com/rroemhild/docker-test-openldap and extended with randomly generated users/groups. For details see [data/ldap-generator/](https://github.com/juliushaertl/nextcloud-docker-dev/tree/master/data/ldap-generator). LDAP will be configured automatically if the ldap container is available during installation.
Example users are: `leela fry bender zoidberg hermes professor`. The password is the same as the uid.
Useful commands:
```
docker-compose exec ldap ldapsearch -H 'ldap://localhost' -D "cn=admin,dc=planetexpress,dc=com" -w admin -b "dc=planetexpress,dc=com" "(&(objectclass=inetOrgPerson)(description=*use*))"
```
## Collabora
- Make sure to have the collabora hostname setup in your /etc/hosts file: `127.0.0.1 collabora.local`
- Automatically enable for one of your containers (e.g. the main nextcloud one):
- Run `./scripts/enable-collabora nextcloud`
- Manual setup
- Start the Collabora Online server in addition to your other containers `docker-compose up -d collabora`
- Make sure you have the richdocuments app cloned to your apps-extra directory and built the frontend code of the app with `npm ci && npm run build`
- Enable the app and configure `collabora.local` in the Collabora settings inside of Nextcloud
## ONLYOFFICE
- Make sure to have the collabora hostname setup in your /etc/hosts file: `127.0.0.1 onlyoffice.local`
- Automatically enable for one of your containers (e.g. the main nextcloud one):
- Run `./scripts/enable-onlyoffice nextcloud`
- Manual setup
- Start the ONLYOFFICE server in addition to your other containers `docker-compose up -d onlyoffice`
- Clone https://github.com/ONLYOFFICE/onlyoffice-nextcloud into your apps directory
- Enable the app and configure `onlyoffice.local` in the ONLYOFFICE settings inside of Nextcloud
## Antivirus
Once here, you can read the [First connection](#first-connection) section after seeing this result in your terminal :
```bash
docker-compose up -d proxy nextcloud av
nextcloud-nextcloud-1 | The user "alice" was created successfully
nextcloud-nextcloud-1 | The user "user6" was created successfully
nextcloud-nextcloud-1 | The user "user1" was created successfully
nextcloud-nextcloud-1 | The user "nextcloud" was created successfully
nextcloud-nextcloud-1 | The user "user3" was created successfully
nextcloud-nextcloud-1 | The user "user5" was created successfully
nextcloud-nextcloud-1 | The user "jane" was created successfully
nextcloud-nextcloud-1 | The user "john" was created successfully
nextcloud-nextcloud-1 | The user "bob" was created successfully
nextcloud-nextcloud-1 | The user "user4" was created successfully
nextcloud-nextcloud-1 | The user "user2" was created successfully
```
The clanav antivirus will then be exposed as a deamon with host `clam` and
port 3310.
This result means that all users are created and you can try to log in with the admin account or [other users](#which-user-accounts-can-i-use).
## SAML
If you want to stop the services, you should use `Ctrl+C`. But, the containers are always running or presents.
```
docker-compose up -d proxy nextcloud saml
Look at the status of your containers with `docker compose ps` :
```bahs
$ docker compose ps
NAME COMMAND SERVICE STATUS PORTS
nextcloud-database-mysql-1 "docker-entrypoint.s…" database-mysql running 0.0.0.0:8212->3306/tcp, :::8212->3306/tcp
nextcloud-mail-1 "MailHog" mail running 1025/tcp, 8025/tcp
nextcloud-nextcloud-1 "/usr/local/bin/boot…" nextcloud exited (0)
nextcloud-proxy-1 "/app/docker-entrypo…" proxy exited (2)
nextcloud-redis-1 "docker-entrypoint.s…" redis running 6379/tcp
```
- uid mapping: `urn:oid:0.9.2342.19200300.100.1.1`
- idp entity id: `https://sso.local.dev.bitgrid.net/simplesaml/saml2/idp/metadata.php`
- single sign on service url: `https://sso.local.dev.bitgrid.net/simplesaml/saml2/idp/SSOService.php`
- single log out service url: `https://sso.local.dev.bitgrid.net/simplesaml/saml2/idp/SingleLogoutService.php`
- use certificate from docker/configs/var-simplesamlphp/cert/example.org.crt
```
-----BEGIN CERTIFICATE-----
MIICrDCCAhWgAwIBAgIUNtfnC2jE/rLdxHCs2th3WaYLryAwDQYJKoZIhvcNAQEL
BQAwaDELMAkGA1UEBhMCREUxCzAJBgNVBAgMAkJZMRIwEAYDVQQHDAlXdWVyemJ1
cmcxFDASBgNVBAoMC0V4YW1wbGUgb3JnMSIwIAYDVQQDDBlzc28ubG9jYWwuZGV2
LmJpdGdyaWQubmV0MB4XDTE5MDcwMzE0MjkzOFoXDTI5MDcwMjE0MjkzOFowaDEL
MAkGA1UEBhMCREUxCzAJBgNVBAgMAkJZMRIwEAYDVQQHDAlXdWVyemJ1cmcxFDAS
BgNVBAoMC0V4YW1wbGUgb3JnMSIwIAYDVQQDDBlzc28ubG9jYWwuZGV2LmJpdGdy
aWQubmV0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHPZwU+dAc76yB6bOq
0AkP1y9g7aAi1vRtJ9GD4AEAsA3zjW1P60BYs92mvZwNWK6NxlJYw51xPak9QMk5
qRHaTdBkmq0a2mWYqh1AZNNgCII6/VnLcbEIgyoXB0CCfY+2vaavAmFsRwOMdeR9
HmtQQPlbTA4m5Y8jWGVs1qPtDQIDAQABo1MwUTAdBgNVHQ4EFgQUeZSoGKeN5uu5
K+n98o3wcitFYJ0wHwYDVR0jBBgwFoAUeZSoGKeN5uu5K+n98o3wcitFYJ0wDwYD
VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOBgQA25X/Ke+5dw7up8gcF2BNQ
ggBcJs+SVKBmPwRcPQ8plgX4D/K8JJNT13HNlxTGDmb9elXEkzSjdJ+6Oa8n3IMe
vUUejXDXUBvlmmm+ImJVwwCn27cSfIYb/RoZPeKtned4SCzpbEO9H/75z3XSqAZS
Z1tiHzYOVtEs4UNGOtz1Jg==
-----END CERTIFICATE-----
```
- cn `urn:oid:2.5.4.3`
- email `urn:oid:0.9.2342.19200300.100.1.3`
### Environment based SSO
A simple approach to test environment based SSO with the user_saml app is to use apache basic auth with the following configuration:
```
<Location /login>
AuthType Basic
AuthName "SAML"
AuthUserFile /var/www/html/.htpasswd
Require valid-user
</Location>
<Location /index.php/login>
AuthType Basic
AuthName "SAML"
AuthUserFile /var/www/html/.htpasswd
Require valid-user
</Location>
<Location /index.php/apps/user_saml/saml/login>
AuthType Basic
AuthName "SAML"
AuthUserFile /var/www/html/.htpasswd
Require valid-user
</Location>
<Location /apps/user_saml/saml/login>
AuthType Basic
AuthName "SAML"
AuthUserFile /var/www/html/.htpasswd
Require valid-user
</Location>
```
## Fulltextsearch
```
docker-compose up -d elasticsearch elasticsearch-ui
```
- Address for configuring in Nextcloud: `http://elastic:elastic@elasticsearch:9200`
- Adress to access elastic search from outside: `http://elastic:elastic@elasticsearch.local`
- Address for accessing the ui: http://elasticsearch-ui.local/
`sudo sysctl -w vm.max_map_count=262144`
## Object storage
Primary object storage can be enabled by setting the `PRIMARY=minio` environment variable either in your .env file or in docker-compose.yml for individual containers.
To down your containers, use the `docker compose down -v` command :
```bash
docker-composer up proxy nextcloud minio
```
foo@bar:~/Documents/codes/nextcloud-docker-dev$ docker compose down -v
[+] Running 16/5
⠿ Container nextcloud-nextcloud-1 Removed 0.0s
⠿ Container nextcloud-proxy-1 Removed 0.0s
⠿ Container nextcloud-mail-1 Removed 0.6s
#...
foo@bar:~/Documents/codes/nextcloud-docker-dev$
```
## Development
### OCC
Run inside of the Nextcloud container:
```
set XDEBUG_CONFIG=idekey=PHPSTORM
sudo -E -u www-data php -dxdebug.remote_host=192.168.21.1 occ
```
### Useful commands
- Restart apache to reload php configuration without a full container restart: `docker-compose kill -s USR1 nextcloud`
- Access to mysql console: `mysql -h $(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nextcloud_database-mysql_1) -P 3306 -u nextcloud -pnextcloud`
- Run an LDAP search: `ldapsearch -x -H ldap://$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nextcloud_ldap_1) -D "cn=admin,dc=planetexpress,dc=com" -w admin -b "dc=planetexpress,dc=com" -s subtree <filter> <attrs>`
## Keycloak
- Keycloak is using ldap as a user backend (make sure the ldap container is also running)
- `occ user_oidc:provider Keycloak -c nextcloud -s 09e3c268-d8bc-42f1-b7c6-74d307ef5fde -d https://keycloak.local.dev.bitgrid.net/auth/realms/Example/.well-known/openid-configuration`
- https://keycloak.local.dev.bitgrid.net/auth/realms/Example/.well-known/openid-configuration
- nextcloud
- 09e3c268-d8bc-42f1-b7c6-74d307ef5fde
## Global scale
```
docker-compose up -d proxy portal gs1 gs2 lookup database-mysql
```
Users are named the same as the instance name, e.g. gs1, gs2
## Imaginary
Enable the imaginary server for generating previews
Once you understand the mechanisms, you could run your containers in the background with the `-d` flag.
```bash
docker-composer up proxy nextcloud previews_hpb
./scripts/enable-preview-imaginary.sh
foo@bar:~/Documents/codes/nextcloud-docker-dev$ docker compose up -d proxy nextcloud
[+] Running 12/1
⠿ Network nextcloud_default Created 0.2s
⠿ Volume "nextcloud_postgres" Created 0.0s
⠿ Volume "nextcloud_mysql" Created 0.0s
⠿ Volume "nextcloud_smb" Created 0.0s
⠿ Volume "nextcloud_clam" Created 0.0s
⠿ Volume "nextcloud_document_data" Created 0.0s
#...
foo@bar:~/Documents/codes/nextcloud-docker-dev$
```
The difference with the `-d` flag is you can use your currently prompt after run the `docker compose` command.
## First connection
After running the `docker compose up nextcloud proxy` command, you have to wait a few minutes before trying to connect to your development instance.
In fact, you will see that the `nextcloud` and `proxy` containers initialize your Nextcloud, create user accounts, and so on. Step by step.
Then, once these steps are completed, you can connect to your development instance. You must enter `http://nextcloud.local` in your address bar!
In fact, with the `proxy` container you don't need to specify the port number and you can't use `http://localhost` or `http://127.0.0.1`. Just, you have to use this address : `http://nextcloud.local`.
### Which user accounts can I use ?
Here is a list of user accounts you can use :
| uid | password |
|:---:|:---:|
| admin | admin |
| user1 | user1 |
| user2 | user2 |
| user3 | user3 |
| user4 | user4 |
| user5 | user5 |
| user6 | user6 |
| nextcloud | nextcloud |
| alice | alice |
| bob | bob |
| jane | jane |
| john | john |
## Where can I add my app for development ?
Once you have ran the Nextcloud's server with `docker compose`. You can clone your app in this folder : `./workspace/server/apps-extra/`.
Of course, you should adapt to the nextcloud release you are using (server, stable23, stable24, and so on.).
If you have not yet generated an app, you can do so from this web page : [https://apps.nextcloud.com/developer/apps/generate](https://apps.nextcloud.com/developer/apps/generate).
## Going further
If you want to go further, you can add new features or customize your development environment by following this documentation : [Configure my environment](docs/manual-setup.md#copy-environment-variables).
If you use **XDEBUG** to debug your PHP code. Please, read the [Set Up Xdebug](docs/setup-xdebug.md) documentation.
If you want to set up the Nextcloud's core, please, read the [Manual setup](docs/manual-setup.md) documentation.
If you aren't comfortable with Docker or other tools from the various containers (ldap, mysql, and so on.). You can read the [Useful commands](docs/useful-commands.md) file with some tips.
If you encounter any problems, please, look at this documentation : [Troubleshooting](docs/troubleshooting.md).
### Different feature you can use
These are features where you can use :
- ☁ Nextcloud
- 🔒 [Nginx proxy with SSL termination](docs/containers/ssl.md)
- 💾 [MySQL](docs/containers/mysql.md)
- 💡 Redis
- 👥 [LDAP with example user data](docs/containers/ldap.md)
- ✉ [Mailhog](docs/containers/mail.md)
- 🚀 [Blackfire](docs/containers/blackfire.md)
- 📄 [Collabora](docs/containers/collabora.md)
- 📄 [Only Office](docs/containers/onlyoffice.md)
- 👥 [SAML](docs/containers/saml.md)
- 🔍 [Full Text Search](docs/containers/fulltextsearch.md)
- 🪣 [Object Storage](docs/containers/objectstorage.md)
- 💉 [Antivirus](docs/containers/antivirus.md)
- 🔑 [Keycloak](docs/containers/keycloak.md)
- [Global Scale](docs/containers/globalscale.md)
- [Imaginary](docs/containers/imaginary.md)
+3 -4
View File
@@ -40,7 +40,6 @@ echo
echo "⏩ Performing system checks"
is_installed docker
is_installed docker-compose
is_installed git
(
@@ -105,17 +104,17 @@ cat <<EOF
🚀 Start the Nextcloud server by running
$ docker-compose up -d nextcloud
$ docker compose up -d nextcloud
💤 Stop it with
$ docker-compose stop nextcloud
$ docker compose stop nextcloud
🗑 Fresh install and wipe all data
$ docker-compose down -v
$ docker compose down -v
Note that for performance reasons the server repository has been cloned with
+8
View File
@@ -0,0 +1,8 @@
# Antivirus
```bash
docker compose up -d proxy nextcloud av
```
The clanav antivirus will then be exposed as a deamon with host `clam` and
port 3310.
+10
View File
@@ -0,0 +1,10 @@
# 🚀 Blackfire
Blackfire needs to use a hostname/ip that is resolvable from within the blackfire container. Their free version is [limited to local profiling](https://support.blackfire.io/troubleshooting/hack-edition-users-cannot-profile-non-local-http-applications) so we need to browse Nextcloud though its local docker IP or add the hostname to `/etc/hosts`.
## Using with curl
```
alias blackfire='docker compose exec -e BLACKFIRE_CLIENT_ID=$BLACKFIRE_CLIENT_ID -e BLACKFIRE_CLIENT_TOKEN=$BLACKFIRE_CLIENT_TOKEN blackfire blackfire'
blackfire curl http://192.168.21.8/
```
+9
View File
@@ -0,0 +1,9 @@
# Collabora
- Make sure to have the collabora hostname setup in your /etc/hosts file: `127.0.0.1 collabora.local`
- Automatically enable for one of your containers (e.g. the main nextcloud one):
- Run `./scripts/enable-collabora nextcloud`
- Manual setup
- Start the Collabora Online server in addition to your other containers `docker compose up -d collabora`
- Make sure you have the richdocuments app cloned to your apps-extra directory and built the frontend code of the app with `npm ci && npm run build`
- Enable the app and configure `collabora.local` in the Collabora settings inside of Nextcloud
+19
View File
@@ -0,0 +1,19 @@
# Full Text Search
To use Full Text Search, follow these commands :
```bash
docker compose down -v
docker compose up nextcloud proxy elasticsearch elasticsearch-ui
```
You can add another services from `docker-compose.yaml` if you want.
- Address for configuring in Nextcloud: `http://elastic:elastic@elasticsearch:9200`
- Adress to access elastic search from outside: `http://elastic:elastic@elasticsearch.local`
- Address for accessing the ui: http://elasticsearch-ui.local/
```bash
sudo sysctl -w vm.max_map_count=262144
```
+7
View File
@@ -0,0 +1,7 @@
## Global scale
```bash
docker compose up -d proxy portal gs1 gs2 lookup database-mysql
```
Users are named the same as the instance name, e.g. gs1, gs2
+8
View File
@@ -0,0 +1,8 @@
# Imaginary
Enable the imaginary server for generating previews
```bash
docker composer up proxy nextcloud previews_hpb
./scripts/enable-preview-imaginary.sh
```
+7
View File
@@ -0,0 +1,7 @@
# Keycloak
- Keycloak is using ldap as a user backend (make sure the ldap container is also running)
- `occ user_oidc:provider Keycloak -c nextcloud -s 09e3c268-d8bc-42f1-b7c6-74d307ef5fde -d https://keycloak.local.dev.bitgrid.net/auth/realms/Example/.well-known/openid-configuration`
- https://keycloak.local.dev.bitgrid.net/auth/realms/Example/.well-known/openid-configuration
- nextcloud
- 09e3c268-d8bc-42f1-b7c6-74d307ef5fde
+29
View File
@@ -0,0 +1,29 @@
# 👥 LDAP
The LDAP sample data is based on https://github.com/rroemhild/docker-test-openldap and extended with randomly generated users/groups. For details see [data/ldap-generator/](https://github.com/juliushaertl/nextcloud-docker-dev/tree/master/data/ldap-generator). LDAP will be configured automatically if the ldap container is available during installation.
|uid (login) | password |
|---|---|
| leela | leela |
| fry | fry |
| zoidberg | zoidberg |
| hermes | hermes |
| professor | professor |
| ... | ... |
To add LDAP in your dev environment use these commands :
```bash
docker compose down -v
docker compose up nextcloud proxy ldap
```
You can add another services from `docker-compose.yaml` if you want.
Useful commands to know all LDAP's objects :
```
docker compose exec ldap ldapsearch -H 'ldap://localhost' -D "cn=admin,dc=planetexpress,dc=com" -w admin -b "dc=planetexpress,dc=com" "(&(objectclass=inetOrgPerson)(description=*use*))"
```
+5
View File
@@ -0,0 +1,5 @@
# ✉ Mail
Sending/receiving mails can be tested with [mailhog](https://github.com/mailhog/MailHog) which is available on ports 1025 (SMTP).
To use the webui, add `127.0.0.1 mail.local` to your `/etc/hosts` and open [mail.local](http://mail.local).
+25
View File
@@ -0,0 +1,25 @@
# Mysql
This is information about the mysql service :
- user root : `root`
- password root : `nextcloud`
- user : `nextcloud`
- password : `nextcloud`
- database name : `nextcloud`
## How to connect on the mysql service ?
You can run this command to be in the mysql prompt as no root :
```bash
docker compose exec database-mysql mysql -unextcloud -pnextcloud
```
If you want to be as root, use this command :
```bash
docker compose exec database-mysql mysql -uroot -pnextcloud
```
+7
View File
@@ -0,0 +1,7 @@
# Object storage
Primary object storage can be enabled by setting the `PRIMARY=minio` environment variable either in your .env file or in docker-compose.yml for individual containers.
```bash
docker composer up proxy nextcloud minio
```
+9
View File
@@ -0,0 +1,9 @@
# ONLYOFFICE
- Make sure to have the collabora hostname setup in your /etc/hosts file: `127.0.0.1 onlyoffice.local`
- Automatically enable for one of your containers (e.g. the main nextcloud one):
- Run `./scripts/enable-onlyoffice nextcloud`
- Manual setup
- Start the ONLYOFFICE server in addition to your other containers `docker compose up -d onlyoffice`
- Clone https://github.com/ONLYOFFICE/onlyoffice-nextcloud into your apps directory
- Enable the app and configure `onlyoffice.local` in the ONLYOFFICE settings inside of Nextcloud
+65
View File
@@ -0,0 +1,65 @@
# SAML
```bash
docker compose up -d proxy nextcloud saml
```
- uid mapping: `urn:oid:0.9.2342.19200300.100.1.1`
- idp entity id: `https://sso.local.dev.bitgrid.net/simplesaml/saml2/idp/metadata.php`
- single sign on service url: `https://sso.local.dev.bitgrid.net/simplesaml/saml2/idp/SSOService.php`
- single log out service url: `https://sso.local.dev.bitgrid.net/simplesaml/saml2/idp/SingleLogoutService.php`
- use certificate from docker/configs/var-simplesamlphp/cert/example.org.crt
```
-----BEGIN CERTIFICATE-----
MIICrDCCAhWgAwIBAgIUNtfnC2jE/rLdxHCs2th3WaYLryAwDQYJKoZIhvcNAQEL
BQAwaDELMAkGA1UEBhMCREUxCzAJBgNVBAgMAkJZMRIwEAYDVQQHDAlXdWVyemJ1
cmcxFDASBgNVBAoMC0V4YW1wbGUgb3JnMSIwIAYDVQQDDBlzc28ubG9jYWwuZGV2
LmJpdGdyaWQubmV0MB4XDTE5MDcwMzE0MjkzOFoXDTI5MDcwMjE0MjkzOFowaDEL
MAkGA1UEBhMCREUxCzAJBgNVBAgMAkJZMRIwEAYDVQQHDAlXdWVyemJ1cmcxFDAS
BgNVBAoMC0V4YW1wbGUgb3JnMSIwIAYDVQQDDBlzc28ubG9jYWwuZGV2LmJpdGdy
aWQubmV0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHPZwU+dAc76yB6bOq
0AkP1y9g7aAi1vRtJ9GD4AEAsA3zjW1P60BYs92mvZwNWK6NxlJYw51xPak9QMk5
qRHaTdBkmq0a2mWYqh1AZNNgCII6/VnLcbEIgyoXB0CCfY+2vaavAmFsRwOMdeR9
HmtQQPlbTA4m5Y8jWGVs1qPtDQIDAQABo1MwUTAdBgNVHQ4EFgQUeZSoGKeN5uu5
K+n98o3wcitFYJ0wHwYDVR0jBBgwFoAUeZSoGKeN5uu5K+n98o3wcitFYJ0wDwYD
VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOBgQA25X/Ke+5dw7up8gcF2BNQ
ggBcJs+SVKBmPwRcPQ8plgX4D/K8JJNT13HNlxTGDmb9elXEkzSjdJ+6Oa8n3IMe
vUUejXDXUBvlmmm+ImJVwwCn27cSfIYb/RoZPeKtned4SCzpbEO9H/75z3XSqAZS
Z1tiHzYOVtEs4UNGOtz1Jg==
-----END CERTIFICATE-----
```
- cn `urn:oid:2.5.4.3`
- email `urn:oid:0.9.2342.19200300.100.1.3`
## Environment based SSO
A simple approach to test environment based SSO with the user_saml app is to use apache basic auth with the following configuration:
```xml
<Location /login>
AuthType Basic
AuthName "SAML"
AuthUserFile /var/www/html/.htpasswd
Require valid-user
</Location>
<Location /index.php/login>
AuthType Basic
AuthName "SAML"
AuthUserFile /var/www/html/.htpasswd
Require valid-user
</Location>
<Location /index.php/apps/user_saml/saml/login>
AuthType Basic
AuthName "SAML"
AuthUserFile /var/www/html/.htpasswd
Require valid-user
</Location>
<Location /apps/user_saml/saml/login>
AuthType Basic
AuthName "SAML"
AuthUserFile /var/www/html/.htpasswd
Require valid-user
</Location>
```
+52
View File
@@ -0,0 +1,52 @@
# SSL
## What is SSL ?
<!-- ## How to use this container with others ?-->
<!-- This section describes if there are particularities or others with this container. -->
## 🔒 Reverse Proxy
Used for SSL termination. To setup SSL support provide a proper DOMAIN_SUFFIX environment variable and put the certificates to ./data/ssl/ named by the domain name.
You might need to add the domains to your `/etc/hosts` file:
```
127.0.0.1 nextcloud.local
127.0.0.1 collabora.local
```
This is assuming you have set `DOMAIN_SUFFIX=.local`
You can generate it through:
```bash
awk -v D=.local '/- [A-z0-9]+\${DOMAIN_SUFFIX}/ {sub("\\$\{DOMAIN_SUFFIX\}", D " 127.0.0.1", $2); print $2}' docker-compose.yml
```
You can generate selfsigned certificates using:
```bash
cd data/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout nextcloud.local.key -out nextcloud.local.crt
```
### dnsmasq to resolve wildcard domains
Instead of adding the individual container domains to `/etc/hosts` a local dns server like dnsmasq can be used to resolve any domain ending with the configured DOMAIN_SUFFIX in `.env` to localhost.
For dnsmasq adding the following configuration would be sufficient for `DOMAIN_SUFFIX=.local`:
```
address=/.local/127.0.0.1
```
### Use valid certificates trusted by your system
* Install mkcert https://github.com/FiloSottile/mkcert
* Go to `data/ssl`
* `mkcert nextcloud.local`
* `mv nextcloud.local-key.pem nextcloud.local.key`
* `mv nextcloud.local.pem nextcloud.local.crt`
* `docker compose restart proxy`
+57
View File
@@ -0,0 +1,57 @@
# Manual setup
## Nextcloud Code
The Nextcloud code base needs to be available including the `3rdparty` submodule. To clone it from github run:
```bash
git clone https://github.com/nextcloud/server.git
cd server
git submodule update --init
pwd
```
The last command prints the path to the Nextcloud server directory.
Use it for setting the `REPO_PATH_SERVER` in the next step.
## Configure my environment
### Copy environment variables
For this section you don't need to run the `./bootstrap.sh` script.
Here, we learn how to customise our development environment !
First, a `.env` file should be created in the repository root, to keep configuration default on the dev setup:
```bash
cp example.env .env
```
Replace `REPO_PATH_SERVER` with your path using the `pwd` command from the project.
```bash
foo@bar:~/Documents/codes/nextcloud-docker-dev$ pwd
/home/foo/Documents/codes/nextcloud-docker-dev
```
And the new value is :
```bash
REPO_PATH_SERVER=/home/foo/Documents/codes/nextcloud-docker-dev/workspace/server
```
### Setting the PHP version to be used
The Nextcloud instance is setup to run with PHP 8.1 by default.
But, the program adapts the PHP default release to suit the Nextcloud stable release using. For example, the stable23 use PHP 7.3 and the stable24 use PHP 7.4.
If you wish to use a different version of PHP, set the `PHP_VERSION` `.env` variable.
The variable supports the following values:
1. PHP 7.1: `71`
1. PHP 7.2: `72`
1. PHP 7.3: `73`
1. PHP 7.4: `74`
1. PHP 8.0: `80`
+28
View File
@@ -0,0 +1,28 @@
# Running stable versions
The docker compose file provides individual containers for stable Nextcloud releases. In order to run those you will need a checkout of the stable version server branch to your workspace directory. Using [git worktree](https://blog.juliushaertl.de/index.php/2018/01/24/how-to-checkout-multiple-git-branches-at-the-same-time/) makes it easy to have different branches checked out in parallel in separate directories.
Note that for performance reasons the server repository might have been cloned with --depth=1 by default. To get the full history it is highly recommended to run:
```bash
cd workspace/server
git fetch --unshallow
```
This may take some time depending on your internet connection speed.
```bash
cd workspace/server
git worktree add ../stable23 stable23
cd ../stable23
git submodule update --init
```
After adding the worktree you can start the stable container using `docker compose up -d stable23`. You can then add stable23.local to your `/etc/hosts` file to access it.
Git worktrees can also be used to have a checkout of an apps stable brach within the server stable directory.
```bash
cd workspace/server/apps-extra/text
git worktree add ../../../stable23/apps-extra/text stable23
```
+8
View File
@@ -0,0 +1,8 @@
## Set up XDebug
Run inside of the Nextcloud container:
```bash
set XDEBUG_CONFIG=idekey=PHPSTORM
sudo -E -u www-data php -dxdebug.remote_host=192.168.21.1 occ
```
+8
View File
@@ -0,0 +1,8 @@
# Troubleshooting
## Running into errors
If your setup isn't working and you can not figure out the reason why, running
`docker compose down -v` will remove the relevant containers and volumes,
allowing you to run `docker compose up` again from a clean slate.
+16
View File
@@ -0,0 +1,16 @@
# Useful commands
## Related to Apache
- Restart apache to reload php configuration without a full container restart: `docker compose kill -s USR1 nextcloud`
## Related to MySql
- Access to mysql console: `mysql -h $(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nextcloud_database-mysql_1) -P 3306 -u nextcloud -pnextcloud`
## Related to LDAP
- Run an LDAP search: `ldapsearch -x -H ldap://$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nextcloud_ldap_1) -D "cn=admin,dc=planetexpress,dc=com" -w admin -b "dc=planetexpress,dc=com" -s subtree <filter> <attrs>`
+3 -3
View File
@@ -1,11 +1,11 @@
COMPOSE_PROJECT_NAME=master
# Paths
REPO_PATH_SERVER=/home/jus/repos/nextcloud/server
ADDITIONAL_APPS_PATH=/home/jus/repos/nextcloud/server/apps-extra
REPO_PATH_SERVER=/home/foobar/repos/nextcloud-docker-dev/workspace/server
ADDITIONAL_APPS_PATH=/home/foobar/repos/nextcloud-docker-dev/workspace/server/apps-extra
# Stable releases root directory
STABLE_ROOT_PATH=/home/jus/repos/nextcloud/
STABLE_ROOT_PATH=/home/foobar/repos/nextcloud-docker-dev/workspace
# Install Nextcloud apps per default
# NEXTCLOUD_AUTOINSTALL_APPS="viewer activity"