From 01547dae1caa6d3ddd38431b8a4fb9ac0ad85ae2 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Mon, 1 Apr 2019 23:41:46 +0200
Subject: [PATCH] Add option to change permissions on upload dir

Since some people serve their static data by uploads directory, unhandy
to set the permissions of the upload directory to 0700 by default.

In order to allow everyone to set the permissions themselves, an option
`UPLOADS_MODE` is introduced that will allow to define the default mode
set to the directory.

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
---
 alpine/Dockerfile              | 1 +
 debian/Dockerfile              | 1 +
 resources/docker-entrypoint.sh | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/alpine/Dockerfile b/alpine/Dockerfile
index 2cd0b6d..76fb88e 100644
--- a/alpine/Dockerfile
+++ b/alpine/Dockerfile
@@ -27,6 +27,7 @@ RUN yarn install --production=true --pure-lockfile
 FROM base
 ARG UID=10000
 ENV NODE_ENV=production
+ENV UPLOADS_MODE=0700
 
 COPY --chown=$UID --from=builder /hedgedoc /hedgedoc
 
diff --git a/debian/Dockerfile b/debian/Dockerfile
index 7d6f5eb..caf5b28 100644
--- a/debian/Dockerfile
+++ b/debian/Dockerfile
@@ -27,6 +27,7 @@ RUN yarn install --production=true --pure-lockfile
 FROM base
 ARG UID=10000
 ENV NODE_ENV=production
+ENV UPLOADS_MODE=0700
 
 RUN apt-get update && \
     apt-get install --no-install-recommends -y gosu && \
diff --git a/resources/docker-entrypoint.sh b/resources/docker-entrypoint.sh
index 4e9aef8..73a0ff6 100755
--- a/resources/docker-entrypoint.sh
+++ b/resources/docker-entrypoint.sh
@@ -30,7 +30,7 @@ fi
 if [ "$UID" -eq 0 ] && [ "$CMD_IMAGE_UPLOAD_TYPE" = "filesystem" ]; then
     if [ "$UID" -eq 0 ]; then
         chown -R hedgedoc ./public/uploads
-        chmod 700 ./public/uploads
+        chmod -R $UPLOADS_MODE ./public/uploads
     else
         echo "
             #################################################################
-- 
2.21.0