Merge pull request #18 from thanek/dev

This commit is contained in:
xis 2023-10-31 17:49:24 +01:00 committed by GitHub
commit 55079dd954
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 97 additions and 29 deletions

View file

@ -1,7 +0,0 @@
FROM eclipse-temurin:17-jdk
WORKDIR /app
COPY ./build/libs/* ./nextcloud-dlna.jar
EXPOSE 8080
CMD ["java","-jar","nextcloud-dlna.jar"]

View file

@ -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) 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. 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 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. share the host's network interfaces.
@ -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_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_DLNA_FRIENDLY_NAME | Nextcloud-DLNA | friendly name of the DLNA service |
| NEXTCLOUD_DATA_DIR | | nextcloud installation directory (that ends with /data) | | 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_HOST | localhost | nextcloud database host |
| NEXTCLOUD_DB_PORT | 3306 | nextcloud database port | | NEXTCLOUD_DB_PORT | 3306 | nextcloud database port |
| NEXTCLOUD_DB_NAME | nextcloud | nextcloud database name | | NEXTCLOUD_DB_NAME | nextcloud | nextcloud database name |

View file

@ -91,3 +91,8 @@ tasks.register('integrationTest', Test) {
check.dependsOn integrationTest check.dependsOn integrationTest
processResources {
filesMatching('**/application.yml') {
expand(project.properties)
}
}

19
docker/Dockerfile Normal file
View file

@ -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"]

View file

@ -1,6 +1,10 @@
#!/bin/bash #!/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." echo "This will create docker image for version $version."
read -p "Continue [y/n]? " -n 1 -r read -p "Continue [y/n]? " -n 1 -r
@ -21,9 +25,13 @@ docker buildx inspect --bootstrap
docker buildx build \ docker buildx build \
--push \ --push \
--platform=linux/arm/v7,linux/arm64/v8,linux/amd64 \ --platform=linux/arm/v7,linux/arm64/v8,linux/amd64 \
--file=./docker/Dockerfile \
--tag=thanek/nextcloud-dlna:$version . --tag=thanek/nextcloud-dlna:$version .
docker buildx build \ docker buildx build \
--push \ --push \
--platform=linux/arm/v7,linux/arm64/v8,linux/amd64 \ --platform=linux/arm/v7,linux/arm64/v8,linux/amd64 \
--file=./docker/Dockerfile \
--tag=thanek/nextcloud-dlna . --tag=thanek/nextcloud-dlna .
cd - || exit

13
docker/start.sh Normal file
View file

@ -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 "$@"

View file

@ -72,8 +72,6 @@ services:
volumes: volumes:
- app:/nextcloud - app:/nextcloud
network_mode: "host" network_mode: "host"
ports:
- "9999:9999"
environment: environment:
- NEXTCLOUD_DLNA_SERVER_PORT=9999 - NEXTCLOUD_DLNA_SERVER_PORT=9999
- NEXTCLOUD_DLNA_FRIENDLY_NAME=Nextcloud - NEXTCLOUD_DLNA_FRIENDLY_NAME=Nextcloud

View file

@ -4,7 +4,6 @@ docker run -d \
--name="nextcloud-dlna" \ --name="nextcloud-dlna" \
--restart=unless-stopped \ --restart=unless-stopped \
--net=host \ --net=host \
-p 9999:9999 \
-e NEXTCLOUD_DLNA_SERVER_PORT=9999 \ -e NEXTCLOUD_DLNA_SERVER_PORT=9999 \
-e NEXTCLOUD_DLNA_FRIENDLY_NAME="Nextcloud" \ -e NEXTCLOUD_DLNA_FRIENDLY_NAME="Nextcloud" \
-e NEXTCLOUD_DB_HOST='localhost' \ -e NEXTCLOUD_DB_HOST='localhost' \

View file

@ -2,12 +2,12 @@ package support.beans.dlna.upnp
import org.jupnp.DefaultUpnpServiceConfiguration import org.jupnp.DefaultUpnpServiceConfiguration
import org.jupnp.model.message.OutgoingDatagramMessage import org.jupnp.model.message.OutgoingDatagramMessage
import org.jupnp.transport.Router
import org.jupnp.transport.impl.DatagramIOConfigurationImpl import org.jupnp.transport.impl.DatagramIOConfigurationImpl
import org.jupnp.transport.impl.DatagramIOImpl import org.jupnp.transport.impl.DatagramIOImpl
import org.jupnp.transport.spi.DatagramIO import org.jupnp.transport.impl.MulticastReceiverConfigurationImpl
import org.jupnp.transport.spi.NetworkAddressFactory import org.jupnp.transport.impl.MulticastReceiverImpl
import org.jupnp.transport.spi.StreamClient import org.jupnp.transport.spi.*
import org.jupnp.transport.spi.StreamServer
import org.springframework.context.annotation.Profile import org.springframework.context.annotation.Profile
import org.springframework.stereotype.Component import org.springframework.stereotype.Component
@ -31,10 +31,33 @@ class UpnpServiceConfigurationInt extends DefaultUpnpServiceConfiguration {
return new MockDatagramIO(this, new DatagramIOConfigurationImpl()) 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) { private void onOutgoingDatagramMessage(OutgoingDatagramMessage message) {
outgoingDatagramMessages.add(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 { class MockDatagramIO extends DatagramIOImpl {
private final UpnpServiceConfigurationInt upnpServiceConfiguration private final UpnpServiceConfigurationInt upnpServiceConfiguration

View file

@ -23,7 +23,7 @@ INSERT INTO `oc_filecache` VALUES
(584,2,'__groupfolders','29ff0edf73a32cb03e437d88fd049245',3,'__groupfolders',2,1,3012412,1696702221,1696702221,0,0,'',31,''), (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,''), (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,''), '',27,''),
(4,2,'appdata_integration','bed7fa8a60170b5d88c9da5e69eaeb5a',3,'appdata_integration',2,1,10274496,1695737790,1695737790,0,0,'',31,''), (4,2,'appdata_integration','bed7fa8a60170b5d88c9da5e69eaeb5a',3,'appdata_integration',2,1,10274496,1695737790,1695737790,0,0,'',31,''),

View file

@ -1,6 +1,5 @@
package net.schowek.nextclouddlna.util package net.schowek.nextclouddlna.util
import jakarta.annotation.PostConstruct
import mu.KLogging import mu.KLogging
import org.springframework.beans.factory.annotation.Value import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Profile import org.springframework.context.annotation.Profile

View file

@ -1,19 +1,21 @@
server: server:
port: ${NEXTCLOUD_DLNA_SERVER_PORT:8080} port: \${NEXTCLOUD_DLNA_SERVER_PORT:8080}
interface: ${NEXTCLOUD_DLNA_INTERFACE:} interface: \${NEXTCLOUD_DLNA_INTERFACE:}
friendlyName: ${NEXTCLOUD_DLNA_FRIENDLY_NAME:Nextcloud-DLNA} friendlyName: \${NEXTCLOUD_DLNA_FRIENDLY_NAME:Nextcloud-DLNA}
nextcloud: nextcloud:
filesDir: ${NEXTCLOUD_DATA_DIR} filesDir: \${NEXTCLOUD_DATA_DIR}
db: db:
type: ${NEXTCLOUD_DB_TYPE:mariadb} type: \${NEXTCLOUD_DB_TYPE:mariadb}
host: ${NEXTCLOUD_DB_HOST:localhost} host: \${NEXTCLOUD_DB_HOST:localhost}
port: ${NEXTCLOUD_DB_PORT:3306} port: \${NEXTCLOUD_DB_PORT:3306}
name: ${NEXTCLOUD_DB_NAME:nextcloud} name: \${NEXTCLOUD_DB_NAME:nextcloud}
user: ${NEXTCLOUD_DB_USER:nextcloud} user: \${NEXTCLOUD_DB_USER:nextcloud}
pass: ${NEXTCLOUD_DB_PASS:nextcloud} pass: \${NEXTCLOUD_DB_PASS:nextcloud}
spring: spring:
application:
version: ${version}
jpa: jpa:
hibernate: hibernate:
ddl-auto: none ddl-auto: none

View file

@ -0,0 +1,7 @@
_ _ _ _ _
_ __ _____ _| |_ ___| | ___ _ _ __| | __| | |_ __ __ _
| '_ \ / _ \ \/ / __/ __| |/ _ \| | | |/ _` |_____ / _` | | '_ \ / _` |
| | | | __/> <| || (__| | (_) | |_| | (_| |_____| (_| | | | | | (_| |
|_| |_|\___/_/\_\\__\___|_|\___/ \__,_|\__,_| \__,_|_|_| |_|\__,_|
ver: ${spring.application.version} (powered by Spring Boot ${spring-boot.version})