samien 7 months ago
commit
92f7b46726
4 changed files with 63 additions and 0 deletions
  1. 14 0
      Dockerfile
  2. 28 0
      README.md
  3. 2 0
      build.sh
  4. 19 0
      files/supervisor.sh

+ 14 - 0
Dockerfile

@@ -0,0 +1,14 @@
+FROM alpine:latest
+ADD files/supervisor.sh /supervisor.sh
+ENV USER ""
+ENV PSWD ""
+ENV HOST ""
+ENV PATHNAME ""
+RUN addgroup -g 1000 nextcloud \
+    && adduser -G nextcloud -D -u 1000 nextcloud \
+    && apk update \
+    && apk add nextcloud-client \
+    && chmod +x /supervisor.sh \
+    && mkdir -p /home/nextcloud/data \
+    && chown nextcloud:nextcloud /home/nextcloud/data
+CMD ["/supervisor.sh"]

+ 28 - 0
README.md

@@ -0,0 +1,28 @@
+# Nextcloud client
+This image provides a Nextcloud client to sync a Docker volume to a Nectcloud location.
+
+## Deprecated
+This repo was moved to [GitLab](https://gitlab.com/nilsramsperger/docker-nextcloud-client).
+
+## Usage
+To start the container run `docker run -d --init --name nextcloud-client --restart unless-stopped -v nextcloud-data:/home/nextcloud/data -e USER='myuser' -e PSWD='mypswd' -e HOST='https://myhost' nilsramsperger/nextcloud-client`
+The env parameters `USER`, `PSWD` and `HOST` have to be replaced with username, password and host URL of the NextCloud server.
+
+The files will be synced to the continer's `/home/nextcloud/data` directory.
+If you want to sync a docker volume to a certian location within the synced directory structure, just exchange the `-v` parameter accordingly.
+i.e.: `-v image-files:/home/nextcloud/data/image-files`
+
+Synchronization is performed every 60 seconds.
+
+## FAQ
+### Question
+Existing files on Nextcloud server are not synced to client.
+The docker log tells, that access was denied.
+
+### Answer
+Folders might be created with wrong rights on first sync.
+Tap into the continer by `docker exec -it nextloud ash`.
+Then switch to the Nextcloud folder by `cs /home/nextcloud/data`.
+`ls -Al` should show folders owned by `root:root`.
+Issue a `chown -R nextcloud:nextcloud *` to fix it.
+Then `exit` the container.

+ 2 - 0
build.sh

@@ -0,0 +1,2 @@
+#!/bin/sh
+docker build --no-cache -t nilsramsperger/nextcloud-client .

+ 19 - 0
files/supervisor.sh

@@ -0,0 +1,19 @@
+#!/bin/ash
+
+term_handler() {
+    echo "SIGTERM received"
+    exit 143;
+}
+
+echo "Starting Nextcloud client"
+
+trap term_handler SIGTERM
+
+while true
+do
+    echo "Start sync"
+    chown -R nextcloud:nextcloud /home/nextcloud/data
+    /bin/su -s /bin/ash nextcloud -c "nextcloudcmd --non-interactive --unsyncedfolders '/home/nextcloud/exclude/exclude/unsync' --path '$PATHNAME'  -u '$USER' -p '$PSWD' /home/nextcloud/data '$HOST'"
+    echo "Sync done"
+    sleep 60
+done

粤ICP备19079148号