Skip to content

Commit

Permalink
Merge pull request #18 from thanek/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
thanek authored Oct 31, 2023
2 parents 2a33a89 + 5eccb5b commit 55079dd
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 29 deletions.
7 changes: 0 additions & 7 deletions Dockerfile

This file was deleted.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ thanek/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.
While using docker, you can pass to the container the `NC_DOMAIN` and `NC_PORT` environment variables and force the container
to check and wait for the nextcloud HTTP server to appear on the specified domain and port address.
You can also 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.
Expand Down Expand Up @@ -55,7 +57,7 @@ Available env variables with their default values that you can overwrite:
| NEXTCLOUD_DLNA_INTERFACE | | (optional) interface the server will be listening on<br/>if not given, the default local address will be used |
| NEXTCLOUD_DLNA_FRIENDLY_NAME | Nextcloud-DLNA | friendly name of the DLNA service |
| NEXTCLOUD_DATA_DIR | | nextcloud installation directory (that ends with /data) |
| NEXTCLOUD_DB_TYPE | mariadb | nextcloud database type (mysql, mariadb, postgresql) |
| NEXTCLOUD_DB_TYPE | mariadb | nextcloud database type (mysql, mariadb, postgres) |
| NEXTCLOUD_DB_HOST | localhost | nextcloud database host |
| NEXTCLOUD_DB_PORT | 3306 | nextcloud database port |
| NEXTCLOUD_DB_NAME | nextcloud | nextcloud database name |
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ tasks.register('integrationTest', Test) {

check.dependsOn integrationTest

processResources {
filesMatching('**/application.yml') {
expand(project.properties)
}
}
19 changes: 19 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM eclipse-temurin:17-jdk
WORKDIR /app

COPY ./build/libs/* ./nextcloud-dlna.jar

RUN set -ex; \
export DEBIAN_FRONTEND=noninteractive; \
apt-get update; \
apt-get install -y --no-install-recommends \
tzdata \
netcat-openbsd \
; \
rm -rf /var/lib/apt/lists/*;

COPY --chmod=775 ./docker/start.sh /start.sh

EXPOSE 8080
ENTRYPOINT ["/start.sh"]
CMD ["java","-jar","nextcloud-dlna.jar"]
10 changes: 9 additions & 1 deletion docker-build-image.sh → docker/build-image.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash

version=`./gradlew currentVersion | grep "Project version" | awk -F"version: " '{ print $2 }'`
dir=$(realpath "$(dirname "$0")")

cd "$dir/../" || exit

version=$(./gradlew currentVersion | grep "Project version" | awk -F"version: " '{ print $2 }')

echo "This will create docker image for version $version."
read -p "Continue [y/n]? " -n 1 -r
Expand All @@ -21,9 +25,13 @@ docker buildx inspect --bootstrap
docker buildx build \
--push \
--platform=linux/arm/v7,linux/arm64/v8,linux/amd64 \
--file=./docker/Dockerfile \
--tag=thanek/nextcloud-dlna:$version .

docker buildx build \
--push \
--platform=linux/arm/v7,linux/arm64/v8,linux/amd64 \
--file=./docker/Dockerfile \
--tag=thanek/nextcloud-dlna .

cd - || exit
13 changes: 13 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Wait for Nextcloud to come online
if [ -n "$NC_DOMAIN" ] && [ -n "$NC_PORT" ]; then
while ! nc -z "$NC_DOMAIN" "$NC_PORT"; do
echo "Waiting for Nextcloud to start on $NC_DOMAIN:$NC_PORT..."
sleep 5
done
echo "Nextcloud found on $NC_DOMAIN:$NC_PORT!"
fi

# Execute CMD
exec /__cacert_entrypoint.sh "$@"
2 changes: 0 additions & 2 deletions examples/docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ services:
volumes:
- app:/nextcloud
network_mode: "host"
ports:
- "9999:9999"
environment:
- NEXTCLOUD_DLNA_SERVER_PORT=9999
- NEXTCLOUD_DLNA_FRIENDLY_NAME=Nextcloud
Expand Down
1 change: 0 additions & 1 deletion examples/docker-standalone/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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' \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package support.beans.dlna.upnp

import org.jupnp.DefaultUpnpServiceConfiguration
import org.jupnp.model.message.OutgoingDatagramMessage
import org.jupnp.transport.Router
import org.jupnp.transport.impl.DatagramIOConfigurationImpl
import org.jupnp.transport.impl.DatagramIOImpl
import org.jupnp.transport.spi.DatagramIO
import org.jupnp.transport.spi.NetworkAddressFactory
import org.jupnp.transport.spi.StreamClient
import org.jupnp.transport.spi.StreamServer
import org.jupnp.transport.impl.MulticastReceiverConfigurationImpl
import org.jupnp.transport.impl.MulticastReceiverImpl
import org.jupnp.transport.spi.*
import org.springframework.context.annotation.Profile
import org.springframework.stereotype.Component

Expand All @@ -31,10 +31,33 @@ class UpnpServiceConfigurationInt extends DefaultUpnpServiceConfiguration {
return new MockDatagramIO(this, new DatagramIOConfigurationImpl())
}

@Override
public MulticastReceiver createMulticastReceiver(NetworkAddressFactory networkAddressFactory) {
return new MockMulticastReceiver(
new MulticastReceiverConfigurationImpl(
networkAddressFactory.getMulticastGroup(),
networkAddressFactory.getMulticastPort()
)
);
}

private void onOutgoingDatagramMessage(OutgoingDatagramMessage message) {
outgoingDatagramMessages.add(message)
}

class MockMulticastReceiver extends MulticastReceiverImpl {
MockMulticastReceiver(MulticastReceiverConfigurationImpl configuration) {
super(configuration)
}

@Override
void init(NetworkInterface networkInterface, Router router, NetworkAddressFactory networkAddressFactory, DatagramProcessor datagramProcessor) throws InitializationException {
}

@Override
public void run() {}
}

class MockDatagramIO extends DatagramIOImpl {
private final UpnpServiceConfigurationInt upnpServiceConfiguration

Expand Down
2 changes: 1 addition & 1 deletion src/integration/resources/db/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ INSERT INTO `oc_filecache` VALUES

(584,2,'__groupfolders','29ff0edf73a32cb03e437d88fd049245',3,'__groupfolders',2,1,3012412,1696702221,1696702221,0,0,'',31,''),
(586,2,'__groupfolders/1','e46cc72327dfc3ccaf32f0a167e6c6d1',584,'1',2,1,3012412,1696695701,1696695701,0,0,'',31,''),
(587,2,'__groupfolders/Nextcloud community.jpg','b9b3caef83a2a1c20354b98df6bcd9d0',586,'Nextcloud community.jpg',12,10,797325,1695737657,1695737657,0,0,
(587,2,'__groupfolders/1/Nextcloud community.jpg','b9b3caef83a2a1c20354b98df6bcd9d0',586,'Nextcloud community.jpg',12,10,797325,1695737657,1695737657,0,0,
'',27,''),

(4,2,'appdata_integration','bed7fa8a60170b5d88c9da5e69eaeb5a',3,'appdata_integration',2,1,10274496,1695737790,1695737790,0,0,'',31,''),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.schowek.nextclouddlna.util

import jakarta.annotation.PostConstruct
import mu.KLogging
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Profile
Expand Down
22 changes: 12 additions & 10 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
server:
port: ${NEXTCLOUD_DLNA_SERVER_PORT:8080}
interface: ${NEXTCLOUD_DLNA_INTERFACE:}
friendlyName: ${NEXTCLOUD_DLNA_FRIENDLY_NAME:Nextcloud-DLNA}
port: \${NEXTCLOUD_DLNA_SERVER_PORT:8080}
interface: \${NEXTCLOUD_DLNA_INTERFACE:}
friendlyName: \${NEXTCLOUD_DLNA_FRIENDLY_NAME:Nextcloud-DLNA}

nextcloud:
filesDir: ${NEXTCLOUD_DATA_DIR}
filesDir: \${NEXTCLOUD_DATA_DIR}
db:
type: ${NEXTCLOUD_DB_TYPE:mariadb}
host: ${NEXTCLOUD_DB_HOST:localhost}
port: ${NEXTCLOUD_DB_PORT:3306}
name: ${NEXTCLOUD_DB_NAME:nextcloud}
user: ${NEXTCLOUD_DB_USER:nextcloud}
pass: ${NEXTCLOUD_DB_PASS:nextcloud}
type: \${NEXTCLOUD_DB_TYPE:mariadb}
host: \${NEXTCLOUD_DB_HOST:localhost}
port: \${NEXTCLOUD_DB_PORT:3306}
name: \${NEXTCLOUD_DB_NAME:nextcloud}
user: \${NEXTCLOUD_DB_USER:nextcloud}
pass: \${NEXTCLOUD_DB_PASS:nextcloud}

spring:
application:
version: ${version}
jpa:
hibernate:
ddl-auto: none
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_ _ _ _ _
_ __ _____ _| |_ ___| | ___ _ _ __| | __| | |_ __ __ _
| '_ \ / _ \ \/ / __/ __| |/ _ \| | | |/ _` |_____ / _` | | '_ \ / _` |
| | | | __/> <| || (__| | (_) | |_| | (_| |_____| (_| | | | | | (_| |
|_| |_|\___/_/\_\\__\___|_|\___/ \__,_|\__,_| \__,_|_|_| |_|\__,_|

ver: ${spring.application.version} (powered by Spring Boot ${spring-boot.version})

0 comments on commit 55079dd

Please sign in to comment.