It's a simply as possible docker-compose
stack to run a
Nextcloud for development and for
production.
- Requirements
- Run
- Improving Nextcloud Previews
- Full Text Search
- Collabora online
- Talk (STUN / TURN)
- Notify Push
- Reverse proxy
- Backup
- Update / Deploy
- Debug
To run this you just need a docker and docker-compose.
You can install a fresh instance of Nextcloud or restore your already installed cloud from dump/backup.
When you want to run fresh instance of nextcloud:
- Create a .env file (use .env.dist as starter file,
cp .env.dist .env
) and setup values. - Run
docker-compose up [-d]
. - Wait for download and build images.
- Wait for install a fresh Nextcloud instance.
- Goto NEXTCLOUD_HOST:NEXTCLOUD_PORT domain and play with your new cloud.
When you have a dump of your already installed Nextcloud instance:
- Create a .env file (use .env.dist as starter file,
cp .env.dist .env
) and setup required values:MYSQL_DATABASE
(dbname
),MYSQL_PASSWORD
(dbpassword
),MYSQL_USER
(dbuser
),NEXTCLOUD_TRUSTED_DOMAINS
(trusted_domains
),REDIS_HOST_PASSWORD
(redis.password
). They should have the same values as in config/config.php.
- Move your database dump file(s) into initdb.d/ directory.
- Move your config files into config/ directory.
- Move your custom apps into apps/ directory.
- Move your data files into data/ directory.
- Move your nextcloud files into nextcloud/ directory.
- Run
docker-compose up [-d]
. - Wait for download and build images.
- Wait when
db
service will load dump file(s) into the database. Note! When you goto the cloud before database is loaded you will got an error. Please be patient and wait for database. - Goto http://localhost/ domain and play with your new cloud.
If you want to run production environment
- Uncomment line
#COMPOSE_FILE=docker-compose.yml:docker-compose.prod.yml
in .env file. It tells todocker-compose
to use those files instead of default docker-compose.yml and docker-compose.override.yml (they're good for development). - Rebuild images with
docker-compose build [--pull]
. - Run new stack
docker-compose up [-d]
.
NEXTCLOUD_HOST
allow to change a host on which nginx
services is
listening. Default it's 127.0.0.1
so only you can connect from your local
machine to the cloud. Setup 0.0.0.0
to allow others from the same network to
connect to your cloud (for example to test cloud on your mobile).
Other environments are described here.
To "increase" performance you can set log level to error
:
bin/occ log:manage --level=error
According to this article Preview mechanism need some tuning.
Install Nextcloud app and setup recommended configurations:
bin/occ config:app:set previewgenerator squareSizes --value="32 256"
bin/occ config:app:set previewgenerator widthSizes --value="256 384"
bin/occ config:app:set previewgenerator heightSizes --value="256"
bin/occ config:system:set preview_max_x --value 2048
bin/occ config:system:set preview_max_y --value 2048
bin/occ config:system:set jpeg_quality --value 60
bin/occ config:app:set preview jpeg_quality --value="60"
If you want to start from scratch you can delete preview folder:
rm -rf ./data/appdata_*/preview
And regenerate previews first time by:
bin/occ preview:generate-all -vvv
To improve search result we can install:
We have to run elasticsearch
service. Add :docker/elasticsearch/compose.yml
to COMPOSE_FILE
environment.
You can also change/setup other environments in .env file:
###> Elasticsearch ###
ELASTICSEARCH_IMAGE=extalion/nextcloud_elasticsearch
###< Elasticsearch ###
Goto settings, select
Elasticsearch
from select box, as an address type http://elasticsearch:9200
and setup index to nextcloud_index
.
For first index run:
bin/occ fulltextsearch:index
If you want to run collabora online locally and you don't have a reverse proxy,
you have to add nginx
and collabora
to your /etc/hosts:
127.0.0.1 collabora
127.0.0.1 nginx
For nextcloud (docker service) collabora is avaliable under collabora
host and
it has to be the same host for a client (your browser).
For collabora (docker service) nextcloud is avaliable under nginx
host and you
have to access nextcloud instance via http://nginx:$NEXTCLOUD_PORT.
We have to run collabora
service. Add :docker/collabora/compose.yml
to
COMPOSE_FILE
environment.
You can also change/setup other environments in .env file:
###> Collabora ###
COLLABORA_PORT=9980
# Go and read https://www.collaboraoffice.com/code/docker/and
# https://github.com/CollaboraOnline/online/blob/master/docker/from-packages/scripts/start-collabora-online.sh
# to see all env
COLLABORA_DICTIONARIES=en
# Value other then "set" will disable warning/info messages of LOKit
COLLABORA_SAL_LOG=set
# Value other then "set" won't generate ssl cert
COLLABORA_DONT_GEN_SSL_CERT=
COLLABORA_CERT_DOMAIN=collabora
# Collabora domain (without reverse proxy it's docker service)
COLLABORA_SERVER_NAME=collabora:9980
# Nextcloud domain (without reverse proxy it's docker service)
COLLABORA_DOMAIN=nginx
# Extra loolwsd command line parameter. To learn about all possible options,
# refer to the self-documented /etc/loolwsd/loolwsd.xml
# docker-compose exec collabora cat /etc/loolwsd/loolwsd.xml
COLLABORA_EXTRA_PARAMS=--o:admin_console.enable=false --o:ssl.enable=false
# To enable the admin console feature of CODE remove admin_console.enbale option
# $COLLABORA_SERVER_NAME/loleaflet/dist/admin/admin.html
COLLABORA_USERNAME=root
COLLABORA_PASSWORD=CHANGE_ME
###< Collabora ###
Install richdocuments,
goto settings, select
Use your own server
and as an url put http://collabora:9980
.
Done!
If you have install talk app and you want to "increase" performance and have video calls, you have to set up your own STUN/TURN server.
We have to run coturn
service. Add :docker/coturn/compose.yml
to
COMPOSE_FILE
environment.
You can also change/setup other environments in .env file:
###> Coturn ###
COTURN_IMAGE=extalion/nextcloud_coturn
COTURN_PORT=3478
COTURN_SECRET=CHANGE_ME
# Your nextcloud domain
COTURN_REALM=localhost
###< Coturn ###
Goto settings and set:
STUN server
toyour-server-ip:$COTURN_PORT
,TURN server
toyour-server-ip:$COTURN_PORT
,TURN secret
to$COTURN_SECRET
.
To configure notify_push app:
- Install the
notify_push
app from the appstore, - Restart
nextcloud
service (docker-compose restart nextcloud
), - set the url of the push server (
bin/occ notify_push:setup http://domain/push
)
If you got push server is not a trusted proxy then you have to add displayed
proxies in config/config.php to trusted_proxies
.
Basic nginx configuration for reverse proxy is avaliable here.
Update Server > Domain
names and Reverse proxy > proxy_pass
ports (read
ports from your .env file).
Remove include nginxconfig.io/security.conf;
from nextcloud domain conf.
Docker nginx service conf is build base on
Nextcloud example.
In .env file you have to change:
NEXTCLOUD_TRUSTED_DOMAINS=nextcloud.example.com
COLLABORA_CERT_DOMAIN=collabora.example.com
COLLABORA_SERVER_NAME=collabora.example.com
COLLABORA_DOMAIN=nextcloud.example.com
If you have install nextcloud already, in ./config/config.php:
- add
nextcloud.example.pl
totrusted_domains
array, - change
overwrite.cli.url
tonextcloud.example.pl
.
If you have setup collabora online, you have to update
URL (and Port) of Collabora Online-server
to collabora.example.com
.
Reload docker:
docker-compose up [-d]
To make a backup we're using a docker-backup tool which use BorgBackup under hood.
Create a .docker-backup file (use .docker-backup.dist as starter file,
cp .docker-backup.dist .docker-backup
) and setup values. Refer to
documentation.
Setup COMPOSE_FILE
to docker-compose.yml:docker-compose.prod.yml
. Also if
you want to run other services (elasticsearch
, collabora
, coturn
) add their
compose.yml too. See
here.
Update images names (.env *_IMAGE
) which point to your hub.
Run:
docker-compose build --pull
If you didn't build images on the server run:
docker-compose push
On the server run:
docker-compose pull
docker-compose up -d
If you want to debug a cloud with xdebug:
- be sure you're running dev environment (and images),
- add/setup
debug
toXDEBUG_MODE
, - reload docker with
docker-compose up -d
.
Now you're ready to remote debugging.