first commmit
This commit is contained in:
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
.env
|
||||||
|
*.sql
|
||||||
|
*.xml
|
||||||
|
data/
|
||||||
|
php.confd/
|
||||||
|
sql.confd/
|
||||||
|
update_nextcloud.sh
|
||||||
|
turnserver.conf
|
||||||
|
backup_nc.sh
|
||||||
|
copyPHPconf.sh
|
||||||
|
migrate.sh
|
||||||
|
install.sh
|
||||||
40
README.md
Normal file
40
README.md
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Nextcloud docker-compose recipe
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This repo is intended for anyone who wishes to self host Nextcloud in docker containers and has been developed based on several tutorials I found online.
|
||||||
|
After cloning the repo for the first time, you'll need to run the init.sh script to create the required folders.
|
||||||
|
### folders required
|
||||||
|
|
||||||
|
1. data
|
||||||
|
- app ( folder to store Nextcloud app )
|
||||||
|
- sql ( folder for the mariadb container to store database files )
|
||||||
|
- config ( easy accces to the config.php file for nextcloud )
|
||||||
|
- theme ( theme folder, which I don't use but it's there for anyone who wants to )
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
To use this repo you will need an **Ubunto/Debian** based Linux system with docker and docker-compose pre installed.
|
||||||
|
The scripts and files also assume that the default admin user id is **1000** which is the defualt for Ubunto server.
|
||||||
|
|
||||||
|
sudo apt update && apt upgrade -y
|
||||||
|
sudo apt install docker docker-compose
|
||||||
|
|
||||||
|
Clone this repo to the folder where you'd like to run your Nextcloud instance from.
|
||||||
|
|
||||||
|
git clone https://git.koke.estate/Docker/nextcloud.git
|
||||||
|
|
||||||
|
## Steps to install first instance
|
||||||
|
|
||||||
|
1. Prepare .env file
|
||||||
|
|
||||||
|
cp env .env
|
||||||
|
nano .env
|
||||||
|
|
||||||
|
2. Start docker containers
|
||||||
|
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
./nextcloud up
|
||||||
|
|
||||||
115
docker-compose.yaml
Normal file
115
docker-compose.yaml
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
version: '3.3'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
nextcloud:
|
||||||
|
external: true
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
container_name: ${appname}-db
|
||||||
|
image: mariadb:${mariadb_version}
|
||||||
|
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./data/sql:/var/lib/mysql:rw
|
||||||
|
- ./sql.confd:/etc/mysql/conf.d
|
||||||
|
environment:
|
||||||
|
- MYSQL_ROOT_PASSWORD=${sql_root_pwd}
|
||||||
|
- MYSQL_PASSWORD=${sql_pwd}
|
||||||
|
- MYSQL_DATABASE=${sql_db}
|
||||||
|
- MYSQL_USER=${sql_user}
|
||||||
|
# ports:
|
||||||
|
# - 3308:3306
|
||||||
|
networks:
|
||||||
|
- nextcloud
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
redis:
|
||||||
|
container_name: ${appname}-redis
|
||||||
|
image: redis:buster
|
||||||
|
command: redis-server --requirepass ${redis_host_pass}
|
||||||
|
privileged: true
|
||||||
|
networks:
|
||||||
|
- nextcloud
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
app:
|
||||||
|
container_name: ${appname}
|
||||||
|
image: nextcloud:${nextcloud_tag}
|
||||||
|
# ports:
|
||||||
|
# - 8889:80
|
||||||
|
volumes:
|
||||||
|
- ./data/app:/var/www/html
|
||||||
|
- ./data/config:/var/www/html/config
|
||||||
|
# - ./data/theme:/var/www/html/themes/coke
|
||||||
|
- ${data_dir}:/var/www/html/data
|
||||||
|
- /home/jandieman/test:/mnt/test
|
||||||
|
environment:
|
||||||
|
- MYSQL_HOST=db
|
||||||
|
- NEXTCLOUD_TRUSTED_DOMAINS=${domains}
|
||||||
|
# - APACHE_DISABLE_REWRITE_IP=1
|
||||||
|
- TRUSTED_PROXIES=${proxies}
|
||||||
|
- REDIS_HOST=${appname}-redis
|
||||||
|
- REDIS_HOST_PORT=${redis_host_port}
|
||||||
|
- REDIS_HOST_PASSWORD=24295
|
||||||
|
- PHP_MEMORY_LIMIT=${php_memory_limit}
|
||||||
|
- PHP_UPLOAD_LIMIT=${php_upload_limit}
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- redis
|
||||||
|
networks:
|
||||||
|
- nextcloud
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
cron:
|
||||||
|
container_name: ${appname}-cron
|
||||||
|
image: rcdailey/nextcloud-cronjob
|
||||||
|
restart: always
|
||||||
|
network_mode: none
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
environment:
|
||||||
|
- NEXTCLOUD_CONTAINER_NAME=${appname}
|
||||||
|
# - NEXTCLOUD_PROJECT_NAME=nextcloud
|
||||||
|
#
|
||||||
|
# turn:
|
||||||
|
# container_name: ${appname}-coturn
|
||||||
|
# image: instrumentisto/coturn:4.5
|
||||||
|
# restart: always
|
||||||
|
# networks:
|
||||||
|
# - nextcloud
|
||||||
|
# ports:
|
||||||
|
# - 3478:3478/tcp
|
||||||
|
# - 3478:3478/udp
|
||||||
|
# - 49153-49306:49153-49306/udp
|
||||||
|
# volumes:
|
||||||
|
# - ./turnserver.conf:/etc/coturn/turnserver.conf
|
||||||
|
# depends_on:
|
||||||
|
# - app
|
||||||
|
# command:
|
||||||
|
# - --realm=${domains}
|
||||||
|
|
||||||
|
collabora:
|
||||||
|
image: collabora/code
|
||||||
|
container_name: ${appname}-collabora
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- nextcloud
|
||||||
|
volumes:
|
||||||
|
- ./loolwsd.xml:/etc/loolwsd/loolwsd.xml
|
||||||
|
ports:
|
||||||
|
- 9980:9980
|
||||||
|
extra_hosts:
|
||||||
|
- "${nextcloud_host}:${host_ip}"
|
||||||
|
- "${collabora_host}:${host_ip}"
|
||||||
|
# - "${NEXTCLOUD_FQDN}:${NEXTCLOUD_IPADDRESS}"
|
||||||
|
# - "${COLLABORA_FQDN}:${NEXTCLOUD_IPADDRESS}"
|
||||||
|
environment:
|
||||||
|
- domain=${collabora_host}
|
||||||
|
- dictionaries=en
|
||||||
|
cap_add:
|
||||||
|
- MKNOD
|
||||||
|
tty: true
|
||||||
19
env
Normal file
19
env
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
appname=nextcloud
|
||||||
|
mariadb_version=10.5.8
|
||||||
|
nextcloud_tag=stable-apache
|
||||||
|
domains=cloud.host.com localhost
|
||||||
|
nextcloud_host=cloud.host.com
|
||||||
|
# Enter the allowed servers that can proxy to nextcloud container
|
||||||
|
proxies=192.168.1.101 192.168.1.100
|
||||||
|
host_ip=192.168.1.101
|
||||||
|
# Foleder where data is stored, (Must belong to www-data user and group)
|
||||||
|
data_dir=/mnt/nextcloud_data
|
||||||
|
sql_db=nextcloud
|
||||||
|
sql_pwd=changeme1
|
||||||
|
sql_root_pwd=changeme2
|
||||||
|
sql_user=nextcloud
|
||||||
|
redis_host_port=6379
|
||||||
|
redis_host_pass=24295
|
||||||
|
php_memory_limit=1024M
|
||||||
|
php_upload_limit=20G
|
||||||
|
collabora_host=office.host.com
|
||||||
121
nextcloud
Executable file
121
nextcloud
Executable file
@@ -0,0 +1,121 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
clear
|
||||||
|
nc_path="/var/www/html"
|
||||||
|
#nc_path="/var/www/nextcloud"
|
||||||
|
|
||||||
|
# File owner for Nextcloud data
|
||||||
|
nc_owner="www-data"
|
||||||
|
|
||||||
|
# This script need to know what your nextcloud docker container is called
|
||||||
|
nc_container="nextcloud"
|
||||||
|
|
||||||
|
# Change this if Nextcloud is hosted in a docker container.
|
||||||
|
# All commands need to change for docker containers
|
||||||
|
docker=true
|
||||||
|
|
||||||
|
if [[ $docker = true ]]
|
||||||
|
then
|
||||||
|
command="docker exec --user $nc_owner $nc_container php occ"
|
||||||
|
else
|
||||||
|
command="sudo -u $nc_owner php --define apc.enable_cli=1 $nc_path/occ"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo " This script are to be used as follows..."
|
||||||
|
echo ""
|
||||||
|
echo " ./nextcloud [function] [paramiters]"
|
||||||
|
echo " "
|
||||||
|
echo " Example: ./nextcloud maintenance on"
|
||||||
|
echo " Maintenance mode enabled"
|
||||||
|
echo " "
|
||||||
|
echo " Available functions are listed below"
|
||||||
|
echo " "
|
||||||
|
echo " - maintenance [on/off] "
|
||||||
|
echo " "
|
||||||
|
echo " - occ [followed by any official occ commands]"
|
||||||
|
echo " "
|
||||||
|
echo " - db [export, import]"
|
||||||
|
echo " "
|
||||||
|
echo " - install [smb, zip, nfs, ffmpeg, all "
|
||||||
|
echo " "
|
||||||
|
echo " "
|
||||||
|
echo " "
|
||||||
|
echo " "
|
||||||
|
|
||||||
|
function maintenance () {
|
||||||
|
clear
|
||||||
|
# echo $command
|
||||||
|
case $1 in
|
||||||
|
on)
|
||||||
|
m="on"
|
||||||
|
;;
|
||||||
|
off)
|
||||||
|
m="off"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo ""
|
||||||
|
echo "Please use either 'on' of 'off' when calling the maintenance function"
|
||||||
|
echo ""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
#sudo -u $nc_owner php --define apc.enable_cli=1 $nc_path/occ maintenance:mode --$m
|
||||||
|
}
|
||||||
|
|
||||||
|
function occ () {
|
||||||
|
$command $1 $2 $3
|
||||||
|
#sudo -u $nc_owner php --define apc.enable_cli=1 $nc_path/occ $1 $2 $3
|
||||||
|
}
|
||||||
|
|
||||||
|
function db () {
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
function install () {
|
||||||
|
clear
|
||||||
|
if [ $1 null ]; then
|
||||||
|
# Perform an APT update and upgrade first
|
||||||
|
|
||||||
|
echo " "
|
||||||
|
echo " Options for this function are ..."
|
||||||
|
echo " "
|
||||||
|
echo " smb - install smb tools to allow network shares for the external drives plugin"
|
||||||
|
echo " zip - install 7zip to unzip files in nextcloud"
|
||||||
|
echo " ffmpeg - Install ffmpeg to play video files (this includes SVG support)"
|
||||||
|
echo " nfs - Install nfs tools to mount nfs shares into docker container"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
else
|
||||||
|
case $1 in
|
||||||
|
smb|SMB)
|
||||||
|
docker exec -i $nc_container sh -c 'apt update'
|
||||||
|
docker exec -i $nc_container sh -c 'apt upgrade -y'
|
||||||
|
docker exec -i $nc_container sh -c 'apt install smbclient -y && apt install libsmbclient-dev -y'
|
||||||
|
docker exec -i $nc_container sh -c 'pecl install smbclient'
|
||||||
|
docker exec -i $nc_container sh -c 'docker-php-ext-enable smbclient'
|
||||||
|
;;
|
||||||
|
zip|ZIP)
|
||||||
|
docker exec -i $nc_container sh -c 'apt update'
|
||||||
|
docker exec -i $nc_container sh -c 'apt upgrade -y'
|
||||||
|
docker exec -i $nc_container sh -c 'pecl -v install rar'
|
||||||
|
docker exec -i $nc_container sh -c 'apt install p7zip p7zip-full'
|
||||||
|
;;
|
||||||
|
ffmpg|FFMPEG)
|
||||||
|
docker exec -i $nc_container sh -c 'apt update'
|
||||||
|
docker exec -i $nc_container sh -c 'apt upgrade -y'
|
||||||
|
docker exec -i $nc_container sh -c 'apt install ffmpeg imagemagick ghostscript -y'
|
||||||
|
docker exec -i $nc_container sh -c 'apt install libmagickcore-6.q16-6-extra -y' #svg support
|
||||||
|
;;
|
||||||
|
nfs|NFS)
|
||||||
|
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo " You didn't choose anything to install"
|
||||||
|
echo " options are ... [smb, zip, ffmpeg, nfs]"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
"$@"
|
||||||
Reference in New Issue
Block a user