feat: Ajout du service Nextcloud

This commit is contained in:
Simon 2020-09-03 11:42:35 +02:00
parent 022ac3a20d
commit 305f739a0e
4 changed files with 184 additions and 0 deletions

25
nextcloud/.env Normal file
View File

@ -0,0 +1,25 @@
## DOCKER
COMPOSE_FILE=./docker-compose.yml
#DOCKER_HOST=
TRAEFIK_NETWORK_NAME=kifeart
## APP
NEXTCLOUD_CONTAINER_NAME=nextcloud
NEXTCLOUD_VOLUME_NAME=nextcloud
NEXTCLOUD_DOMAIN=nextcloud.cool.life
NEXTCLOUD_IMAGE=nextcloud:19.0.2
NEXTCLOUD_ADMIN_USER: user
NEXTCLOUD_ADMIN_PASSWORD: password
# DATABASE
# Voir la description ../postgres/README.md
POSTGRES_IMAGE=postgres:12.2-alpine
POSTGRES_USER=user-example
POSTGRES_PASSWORD=password-example
POSTGRES_DB=postgres-database-name-example
POSTGRES_CONTAINER_NAME=nextcloud-postgres
POSTGRES_VOLUME_NAME=nextcloud-postgres

25
nextcloud/README.md Normal file
View File

@ -0,0 +1,25 @@
# Nextcloud
> Nextcloud server, a safe home for all your data
>
> Nextcloud est un logiciel libre, de site d'hébergement de fichiers, et un fork
> du logiciel ownCloud. À l'origine accessible via WebDAV, n'importe quel
> navigateur web, ou des clients spécialisés, son architecture ouverte a permis
> de voir ses fonctionnalités s'étendre depuis ses origines. Fin 2018, il
> propose de nombreux services.
>
> -- <cite>[Github][github]</cite>
On peut trouver [la documentation ici][documentation].
## TODO
- [x] Mise en place d'une sauvegarde / restauration de sauvegarde
- [x] crontab https://docs.nextcloud.com//server/latest/admin_manual/configuration_server/background_jobs_configuration.html#cron
- [x] Ajouter un redis : https://www.it-connect.fr/nextcloud-activer-et-configurer-le-cache-redis/
- [ ] Ajout des informations SMTP
[github]: https://github.com/nextcloud/server
[documentation]: https://docs.nextcloud.com/server/latest/admin_manual/contents.html
[backup]: https://docs.nextcloud.com/server/latest/admin_manual/maintenance/backup.html
[restore]: https://docs.nextcloud.com/server/latest/admin_manual/maintenance/restore.html

View File

@ -0,0 +1,87 @@
version: "3.8"
networks:
default:
name: ${TRAEFIK_NETWORK_NAME}
volumes:
nextcloud:
name: ${NEXTCLOUD_VOLUME_NAME}
nextcloud-postgres:
name: ${POSTGRES_VOLUME_NAME}
services:
nextcloud:
container_name: ${NEXTCLOUD_CONTAINER_NAME}
image: ${NEXTCLOUD_IMAGE}
restart: always
hostname: ${NEXTCLOUD_DOMAIN}
depends_on:
- nextcloud-postgres
- nextcloud-redis
volumes:
- nextcloud:/var/www/html
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
environment:
NEXTCLOUD_TRUSTED_DOMAINS: ${NEXTCLOUD_DOMAIN}
NEXTCLOUD_ADMIN_USER: ${NEXTCLOUD_ADMIN_USER}
NEXTCLOUD_ADMIN_PASSWORD: ${NEXTCLOUD_ADMIN_PASSWORD}
OVERWRITEPROTOCOL: 'https'
APACHE_DISABLE_REWRITE_IP: '1'
TRUSTED_PROXIES: ${TRAEFIK_NETWORK_NAME}
OVERWRITEPROTOCOL: 'https'
POSTGRES_HOST: ${POSTGRES_CONTAINER_NAME}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
REDIS_HOST: 'nextcloud-redis'
PUID: 1001
PGID: 119
labels:
traefik.enable: 'true'
traefik.docker.network: ${TRAEFIK_NETWORK_NAME}
traefik.http.routers.nextcloud.rule: 'Host(`${NEXTCLOUD_DOMAIN}`)'
traefik.http.routers.nextcloud.entrypoints: 'web'
nextcloud-postgres:
container_name: ${POSTGRES_CONTAINER_NAME}
image: ${POSTGRES_IMAGE}
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
PUID: 1001
PGID: 119
volumes:
- nextcloud-postgres:/var/lib/postgresql/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
nextcloud-redis:
image: redis:6.0.7-alpine
container_name: nextcloud-redis
restart: always
environment:
PUID: 1001
PGID: 119
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
nextcloud-cron:
image: ${NEXTCLOUD_IMAGE}
container_name: nextcloud-cron
restart: always
depends_on:
- nextcloud
entrypoint: /cron.sh
environment:
PUID: 1001
PGID: 119
volumes:
- nextcloud:/var/www/html
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro

47
nextcloud/run Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
set -eu
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/../help.sh
. $DIR/../postgres/run --only-source
nextcloud_help() {
echo "./run backup : Lancement de la sauvegarde de Nextcloud"
echo "./run restore : Restoration de la sauvegarde de Nextcloud"
}
nextcloud_backup() {
script_env
BACKUP_DATE_DEFAULT=`date +%Y%m%d_%H%M%S`
BACKUP_DATE=${BACKUP_DATE:-$BACKUP_DATE_DEFAULT}
backup_folder_create
POSTGRES_BACKUP_FILE=backups/${BACKUP_DATE}_${NEXTCLOUD_DOMAIN}_postgres.sql
postgres_backup
docker run -it --rm -v $HOME/backups/${NEXTCLOUD_DOMAIN}:/backup --volumes-from nextcloud alpine:3.11.6 ash -c "cd /var/www/html && tar cvf /backup/${BACKUP_DATE}_${NEXTCLOUD_DOMAIN}_files.tar ."
}
nextcloud_restore() {
script_env
#postgres_restore
docker run -it --rm -v $HOME/backups/${NEXTCLOUD_DOMAIN}:/backup -v nextcloud:/var/www/html alpine:3.11.6 ash -c "cd /var/www/html && tar xvf /backup/${BACKUP_DATE}_${NEXTCLOUD_DOMAIN}_files.tar --strip 1"
}
if [ $# -ge 1 ]; then
if [ "${1}" == "backup" ]; then
script_start
nextcloud_backup
script_end
elif [ "${1}" == "restore" ]; then
script_start
nextcloud_restore
script_end
elif [ "${1}" != "--only-source" ]; then
nextcloud_help
fi
else
nextcloud_help
fi