From fe11b58a8a09fb328891fa41a42120cd4facda85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Sat, 8 Feb 2020 21:30:01 +0900 Subject: [PATCH] Add nextcloud configuration --- etc/nixos/configuration.nix | 1 + .../services/configs/nginx-nextcloud.conf | 18 ++++++ etc/nixos/services/nextcloud.nix | 62 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 etc/nixos/services/configs/nginx-nextcloud.conf create mode 100644 etc/nixos/services/nextcloud.nix diff --git a/etc/nixos/configuration.nix b/etc/nixos/configuration.nix index ca72431..b5db0f7 100644 --- a/etc/nixos/configuration.nix +++ b/etc/nixos/configuration.nix @@ -13,6 +13,7 @@ # docker-containers set here. ./services/nginx.nix ./services/gitlab.nix + ./services/nextcloud.nix ]; networking = { diff --git a/etc/nixos/services/configs/nginx-nextcloud.conf b/etc/nixos/services/configs/nginx-nextcloud.conf new file mode 100644 index 0000000..1d9a7ba --- /dev/null +++ b/etc/nixos/services/configs/nginx-nextcloud.conf @@ -0,0 +1,18 @@ +server { + listen 80; + server_name localhost; + root /var/www/html; + index index.php index.html index.htm; + + client_max_body_size 16G; + location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34]).php(?:$|/) { + fastcgi_split_path_info ^(.+.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_pass nextcloud:9000; + fastcgi_index index.php; + fastcgi_intercept_errors on; + include fastcgi_params; + } +} diff --git a/etc/nixos/services/nextcloud.nix b/etc/nixos/services/nextcloud.nix new file mode 100644 index 0000000..7014621 --- /dev/null +++ b/etc/nixos/services/nextcloud.nix @@ -0,0 +1,62 @@ +{ ... }: + +{ + networked-docker-containers = { + nextcloud = { + image = "nextcloud:fpm-alpine"; + dependsOn = ["docker-nextcloud-postgres.service"]; + volumes = [ + "apps:/var/www/html/custom_apps" + "config:/var/www/html/config" + "data:/var/www/html/data" + ]; + environment = { + POSTGRES_DB = "nextcloud"; + POSTGRES_USER = "nextcloud"; + POSTGRES_HOST = "nextcloud-postgres"; + POSTGRES_PASSWORD = "rI7t7Nek1yGA9ucrRc7Uhy0jcjwPjnXa8me4o8tJON8="; + }; + networks = [ + "nextcloud" + ]; + extraDockerOptions = [ + "--domainname=nextcloud.tlater.net" + ]; + }; + + nextcloud-nginx = { + image = "nginx:alpine"; + dependsOn = ["docker-nextcloud.service"]; + environment = { + LETSENCRYPT_HOST = "nextcloud.tlater.net"; + VIRTUAL_HOST = "nextcloud.tlater.net"; + }; + volumes = [ + "${./configs/nginx-nextcloud.conf}:/etc/nginx/conf.d/default.conf:ro" + ]; + networks = [ + "webproxy" + "nextcloud" + ]; + extraDockerOptions = [ + "--volumes-from" + "nextcloud" + ]; + }; + + nextcloud-postgres = { + image = "postgres:alpine"; + environment = { + POSTGRES_DB = "nextcloud"; + POSTGRES_USER = "nextcloud"; + POSTGRES_PASSWORD = "rI7t7Nek1yGA9ucrRc7Uhy0jcjwPjnXa8me4o8tJON8="; + }; + volumes = [ + "nextcloud-db-data:/var/lib/postgresql/data" + ]; + networks = [ + "nextcloud" + ]; + }; + }; +}