diff --git a/.examples/README.md b/.examples/README.md new file mode 100644 index 0000000..dbcc5b8 --- /dev/null +++ b/.examples/README.md @@ -0,0 +1,63 @@ +# Examples section + +In this subfolders are some examples how to use the docker image. There are two sections: + + * [`dockerfiles`](https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles) + * [`docker-compose`](https://github.com/nextcloud/docker/tree/master/.examples/docker-compose) + +The `dockerfiles` are derived images, that add or alter certain functionalities of the default docker images. In the `docker-compose` subfolder are examples for deployment of the application, including database, redis, collabora and other services. + +## Dockerfiles +The Dockerfiles use the default images as base image and build on top of it. + + +Example | Description +------- | ------- +[cron](https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles/cron) | uses supervisor to run the cron job inside the container (so no extra container is needed). +[imap](https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles/imap) | adds dependencies required to authenticate users via imap +[smb](https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles/smb) | adds dependencies required to use smb shares + + + + + +## docker-compose +In `docker-compose` additional services are bundled to create a complete nextcloud installation. The examples are designed to run out-of-the-box. +Before running the examples you have to modify the `db.env` and `docker-compose.yml` file and fill in your custom information. + +The docker-compose examples make heavily use of dereived Dockerfiles to add configuration files into the containers. This way they should also work on remote docker systems as _Docker for Windows_. When running docker-compose on the same host as the docker daemon, another possibility would be to simply mount the files in the volumes section in the `docker-compose.yml` file. + + +### insecure +This example should only be used for testing on the local network because it uses a unencrypted http connection. +When you want to have your server reachable from the internet adding HTTPS-encryption is mandatory! +For this use one of the [with-nginx-proxy](#with-nginx-proxy) examples. + +To use this example complete the following steps: + +1. if you use mariadb or mysql choose a root password for the database in `docker-compose.yml` behind `MYSQL_ROOT_PASSWORD=` +2. choose a password for the database user nextcloud in `db.env` behind `MYSQL_PASSWORD=` (for mariadb/mysql) or `POSTGRES_PASSWORD=` (for postgres) +3. run `docker-compose build --pull` to pull the most recent base images and build the custom dockerfiles +4. start nextcloud with `docker-compose up -d` + + +If you want to update your installation to a newer version of nextcloud, repeat the steps 3 and 4. + + +### with-nginx-proxy +The nginx proxy adds a proxy layer between nextcloud and the internet. The proxy is designed to serve multiple sites on the same host machine. +The advantage in adding this layer is the ability to add a container for [Let's Encrypt](https://letsencrypt.org/) certificate handling. +This combination of the [jwilder/nginx-proxy](https://github.com/jwilder/nginx-proxy) and [jrcs/docker-letsencrypt-nginx-proxy-companion](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion) containers creates a fully automated https encryption of the nextcloud installation without worrying about certificate generation, validation or renewal. + +To use this example complete the following steps: + +1. open `docker-compose.yml` + 1. insert your nextcloud domain behind `VIRTUAL_HOST=`and `LETSENCRYPT_HOST=` + 2. enter a valid email behind `LETSENCRYPT_EMAIL=` + 3. if you use mariadb or mysql choose a root password for the database behind `MYSQL_ROOT_PASSWORD=` +2. choose a password for the database user nextcloud in `db.env` behind `MYSQL_PASSWORD=` (for mariadb/mysql) or `POSTGRES_PASSWORD=` (for postgres) +3. run `docker-compose build --pull` to pull the most recent base images and build the custom dockerfiles +4. start nextcloud with `docker-compose up -d` + + +If you want to update your installation to a newer version of nextcloud, repeat the steps 3 and 4. diff --git a/.examples/docker-compose.yml b/.examples/docker-compose.yml deleted file mode 100644 index 60167ed..0000000 --- a/.examples/docker-compose.yml +++ /dev/null @@ -1,97 +0,0 @@ -version: '2' -services: - proxy: - image: jwilder/nginx-proxy - container_name: proxy - ports: - - 80:80 - - 443:443 - volumes: - - ./proxy/conf.d:/etc/nginx/conf.d - - ./proxy/vhost.d:/etc/nginx/vhost.d - - ./proxy/html:/usr/share/nginx/html - - ./proxy/certs:/etc/nginx/certs:ro - - /var/run/docker.sock:/tmp/docker.sock:ro - networks: - - proxy-tier - restart: always - - letsencrypt-companion: - image: alastaircoote/docker-letsencrypt-nginx-proxy-companion - container_name: letsencrypt-companion - volumes_from: - - proxy - volumes: - - /var/run/docker.sock:/var/run/docker.sock:ro - - ./proxy/certs:/etc/nginx/certs:rw - restart: always - - web: - image: nginx - container_name: nextcloud_webserver - volumes: - - ./nginx.conf:/etc/nginx/nginx.conf:ro - links: - - app - - collabora - volumes_from: - - app - environment: - - VIRTUAL_HOST=${DOMAIN} - - VIRTUAL_NETWORK=nginx-proxy - - VIRTUAL_PORT=80 - - LETSENCRYPT_HOST=${DOMAIN} - - LETSENCRYPT_EMAIL= - networks: - - proxy-tier - restart: always - - app: - image: nextcloud:fpm - container_name: nextcloud_fpm - links: - - db - volumes: - - ./nextcloud/apps:/var/www/html/apps - - ./nextcloud/config:/var/www/html/config - - ./nextcloud/data:/var/www/html/data - networks: - - proxy-tier - restart: always - - db: - image: mariadb - container_name: db - volumes: - - ./nextcloud/db:/var/lib/mysql - environment: - - MYSQL_ROOT_PASSWORD= - - MYSQL_DATABASE=nextcloud - - MYSQL_USER=nextcloud - - MYSQL_PASSWORD= - networks: - - proxy-tier - restart: always - - redis: - image: redis - container_name: redis - networks: - - proxy-tier - restart: always - - collabora: - image: collabora/code - container_name: collabora - cap_add: - - MKNOD - environment: - - domain=${DOMAIN} - networks: - - proxy-tier - restart: always - -networks: - proxy-tier: - external: - name: nginx-proxy diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile new file mode 100644 index 0000000..b55fb52 --- /dev/null +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile @@ -0,0 +1,3 @@ +FROM nextcloud:apache + +COPY redis.config.php /usr/src/nextcloud/config/redis.config.php diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/redis.config.php b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/redis.config.php new file mode 100644 index 0000000..b0cebe3 --- /dev/null +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/redis.config.php @@ -0,0 +1,8 @@ + '\OC\Memcache\Redis', + 'redis' => array( + 'host' => 'redis', + 'port' => 6379, + ), +); diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/db.env b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/db.env new file mode 100644 index 0000000..a436605 --- /dev/null +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/db.env @@ -0,0 +1,3 @@ +MYSQL_PASSWORD= +MYSQL_DATABASE=nextcloud +MYSQL_USER=nextcloud diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml new file mode 100644 index 0000000..87760d6 --- /dev/null +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml @@ -0,0 +1,59 @@ +version: '3' + +services: + db: + image: mariadb + # image: mysql + restart: always + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD= + env_file: + - db.env + + redis: + image: redis + restart: always + + app: + build: ./app + restart: always + ports: + - 8080:80 + volumes: + - nextcloud:/var/www/html + environment: + - MYSQL_HOST=db + env_file: + - db.env + depends_on: + - db + - redis + + cron: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + user: www-data + entrypoint: | + bash -c 'bash -s < '\OC\Memcache\Redis', + 'redis' => array( + 'host' => 'redis', + 'port' => 6379, + ), +); diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/db.env b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/db.env new file mode 100644 index 0000000..a436605 --- /dev/null +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/db.env @@ -0,0 +1,3 @@ +MYSQL_PASSWORD= +MYSQL_DATABASE=nextcloud +MYSQL_USER=nextcloud diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/docker-compose.yml b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/docker-compose.yml new file mode 100644 index 0000000..f7b2447 --- /dev/null +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/docker-compose.yml @@ -0,0 +1,67 @@ +version: '3' + +services: + db: + image: mariadb + # image: mysql + restart: always + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD= + env_file: + - db.env + + redis: + image: redis + restart: always + + app: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + environment: + - MYSQL_HOST=db + env_file: + - db.env + depends_on: + - db + - redis + + web: + build: ./web + restart: always + ports: + - 8080:80 + volumes: + - nextcloud:/var/www/html:ro + depends_on: + - app + + cron: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + user: www-data + entrypoint: | + bash -c 'bash -s < '\OC\Memcache\Redis', + 'redis' => array( + 'host' => 'redis', + 'port' => 6379, + ), +); diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/db.env b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/db.env new file mode 100644 index 0000000..a436605 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/db.env @@ -0,0 +1,3 @@ +MYSQL_PASSWORD= +MYSQL_DATABASE=nextcloud +MYSQL_USER=nextcloud diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml new file mode 100644 index 0000000..e01be64 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml @@ -0,0 +1,102 @@ +version: '3' + +services: + db: + image: mariadb + # image: mysql + restart: always + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD= + env_file: + - db.env + + redis: + image: redis + restart: always + + app: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + environment: + - VIRTUAL_HOST= + - LETSENCRYPT_HOST= + - LETSENCRYPT_EMAIL= + environment: + - MYSQL_HOST=db + env_file: + - db.env + depends_on: + - db + - redis + networks: + - proxy-tier + - default + + cron: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + user: www-data + entrypoint: | + bash -c 'bash -s < '\OC\Memcache\Redis', + 'redis' => array( + 'host' => 'redis', + 'port' => 6379, + ), +); diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/db.env b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/db.env new file mode 100644 index 0000000..a436605 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/db.env @@ -0,0 +1,3 @@ +MYSQL_PASSWORD= +MYSQL_DATABASE=nextcloud +MYSQL_USER=nextcloud diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml new file mode 100644 index 0000000..8ed230a --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml @@ -0,0 +1,110 @@ +version: '3' + +services: + db: + image: mariadb + # image: mysql + restart: always + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD= + env_file: + - db.env + + redis: + image: redis + restart: always + + app: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + environment: + - MYSQL_HOST=db + env_file: + - db.env + depends_on: + - db + - redis + + web: + build: ./web + restart: always + volumes: + - nextcloud:/var/www/html:ro + environment: + - VIRTUAL_HOST= + - LETSENCRYPT_HOST= + - LETSENCRYPT_EMAIL= + depends_on: + - app + networks: + - proxy-tier + - default + + cron: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + user: www-data + entrypoint: | + bash -c 'bash -s <