From 4ae6775ecd3e172a0fa4407dedd76b5bae33d1fb Mon Sep 17 00:00:00 2001 From: xis Date: Sun, 22 Oct 2023 13:42:35 +0200 Subject: [PATCH] Running with docker examples --- README.md | 51 +++++++------ examples/docker-compose/docker-compose.yaml | 84 +++++++++++++++++++++ examples/docker-compose/readme.md | 13 ++++ examples/docker-compose/run.sh | 3 + examples/docker-standalone/readme.md | 2 + examples/docker-standalone/run.sh | 14 ++++ 6 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 examples/docker-compose/docker-compose.yaml create mode 100644 examples/docker-compose/readme.md create mode 100644 examples/docker-compose/run.sh create mode 100644 examples/docker-standalone/readme.md create mode 100644 examples/docker-standalone/run.sh diff --git a/README.md b/README.md index eb55bfe..e6a4ca6 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,33 @@ DLNA addon for your self-hosted Nextcloud app instance that allows you to stream devices in your network. It supports the group folders as well. -Just edit the `application.yml` and rebuild the project with: +## Running in Docker +You can use the docker image with nextcloud-dlna e.g.: + +```bash +docker run -d \ +--name="nextcloud-dlna" \ +--net=host \ +-v /path/to/nextcloud/app/ending/with/data:/nextcloud \ +-e NEXTCLOUD_DATA_DIR=/nextcloud \ +-e NEXTCLOUD_DB_HOST='' \ +-e NEXTCLOUD_DB_PASS='' \ +nextcloud-dlna +``` + +or, if used together with the official Nextcloud docker image using the docker-composer. See the [examples](./examples) +directory. for more details about running nextcloud-dlna server in the docker container. + +You can pass to the container other env variables that are listed below. + +Note that it would not work on Mac OS since docker is a Linux container and the `host` networking mode doesn't actually +share the host's network interfaces. + +See https://hub.docker.com/r/thanek/nextcloud-dlna for more docker image details. + +## Building the project + +Build the project with: `./gradlew clean bootRun` @@ -16,6 +42,8 @@ or, if you've already built the project and created the jar file: `NEXTCLOUD_DLNA_SERVER_PORT=9999 java -jar nextcloud-dlna-X.Y.Z.jar` +## ENV variables + Available env variables with their default values that you can overwrite: | env variable | default value | description | @@ -32,27 +60,6 @@ Available env variables with their default values that you can overwrite: | NEXTCLOUD_DB_PASS | nextcloud | nextcloud database password | -## Running in Docker -You can use the docker image with nextcloud-dlna e.g.: - -``` -docker run -d \ ---name="nextcloud-dlna" \ ---net=host \ --v /path/to/nextcloud/app/ending/with/data:/nextcloud \ --e NEXTCLOUD_DATA_DIR=/nextcloud \ --e NEXTCLOUD_DB_HOST='' \ --e NEXTCLOUD_DB_PASS='' \ -nextcloud-dlna -``` - -You can pass to the container other env variables that are listed above. - -Note that it would not work on Mac OS since docker is a Linux container and the `host` networking mode doesn't actually -share the host's network interfaces. - -See https://hub.docker.com/r/thanek/nextcloud-dlna for more docker image details. - ### Code used Some java code was taken from https://github.com/haku/dlnatoad diff --git a/examples/docker-compose/docker-compose.yaml b/examples/docker-compose/docker-compose.yaml new file mode 100644 index 0000000..206f621 --- /dev/null +++ b/examples/docker-compose/docker-compose.yaml @@ -0,0 +1,84 @@ +version: '2' + +volumes: + app: + driver: local + driver_opts: + type: none + o: bind + device: ${PWD}/app + app_etc: + driver: local + driver_opts: + type: none + o: bind + device: ${PWD}/etc/apache2 + db_data: + driver: local + driver_opts: + type: none + o: bind + device: ${PWD}/db + db_etc: + driver: local + driver_opts: + type: none + o: bind + device: ${PWD}/etc/mysql + +services: + db: + image: mariadb:10.5 + restart: always + command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW + volumes: + - db_data:/var/lib/mysql + - db_etc:/etc/mysql + ports: + - "3306:3306" + environment: + - MYSQL_ROOT_PASSWORD=sql + - MYSQL_PASSWORD=secret + - MYSQL_DATABASE=nextcloud + - MYSQL_USER=nextcloud + + redis: + image: redis + restart: always + + app: + image: nextcloud + restart: always + ports: + - "80:80" + - "443:443" + links: + - db + - redis + volumes: + - app:/var/www/html + - app_etc:/etc/apache2 + environment: + - PHP_MEMORY_LIMIT=1G + - PHP_UPLOAD_LIMIT=4G + - MYSQL_PASSWORD=secret + - MYSQL_DATABASE=nextcloud + - MYSQL_USER=nextcloud + - MYSQL_HOST=db + + dlna: + image: thanek/nextcloud-dlna + restart: always + volumes: + - app:/nextcloud + network_mode: "host" + ports: + - "9999:9999" + environment: + - NEXTCLOUD_DLNA_SERVER_PORT=9999 + - NEXTCLOUD_DLNA_FRIENDLY_NAME=Nextcloud + - NEXTCLOUD_DATA_DIR=/nextcloud/data + - NEXTCLOUD_DB_TYPE=mariadb + - NEXTCLOUD_DB_HOST=localhost + - NEXTCLOUD_DB_PASS=secret + diff --git a/examples/docker-compose/readme.md b/examples/docker-compose/readme.md new file mode 100644 index 0000000..af49033 --- /dev/null +++ b/examples/docker-compose/readme.md @@ -0,0 +1,13 @@ +This will run the nextcloud-dlna in docker together with the full Nextcloud installation (containing the app, database +and redis) located in the `./app` directory. + +Note: in order to enable network access to the MariaDB server, after the first run, you'll need to edit +the `./etc/mariadb.cnf`, section `[client-config]` by adding the line: +``` +port = 3306 +``` +and removing the line: +``` +socket = /var/run/mysqld/mysqld.sock +``` +, then restart the `db` (`nextcloud-db-1`) container. \ No newline at end of file diff --git a/examples/docker-compose/run.sh b/examples/docker-compose/run.sh new file mode 100644 index 0000000..80b5727 --- /dev/null +++ b/examples/docker-compose/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker-compose up -d \ No newline at end of file diff --git a/examples/docker-standalone/readme.md b/examples/docker-standalone/readme.md new file mode 100644 index 0000000..c2c0f79 --- /dev/null +++ b/examples/docker-standalone/readme.md @@ -0,0 +1,2 @@ +This will run the nextcloud-dlna in docker and connect to the Nextcloud installation assuming it is located in the +`/opt/nextcloud` directory. diff --git a/examples/docker-standalone/run.sh b/examples/docker-standalone/run.sh new file mode 100644 index 0000000..7086777 --- /dev/null +++ b/examples/docker-standalone/run.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +docker run -d \ + --name="nextcloud-dlna" \ + --restart=unless-stopped \ + --net=host \ + -p 9999:9999 \ + -e NEXTCLOUD_DLNA_SERVER_PORT=9999 \ + -e NEXTCLOUD_DLNA_FRIENDLY_NAME="Nextcloud" \ + -e NEXTCLOUD_DB_HOST='localhost' \ + -e NEXTCLOUD_DB_PASS='secret' \ + -v '/opt/nextcloud/data:/nextcloud' \ + -e NEXTCLOUD_DATA_DIR=/nextcloud \ +thanek/nextcloud-dlna