Entrypoint: Disable chown with PHOTOPRISM_DISABLE_CHOWN #1000

This commit is contained in:
Michael Mayer 2021-02-05 17:39:48 +01:00
parent 0ea7222093
commit c51425067c
5 changed files with 48 additions and 7 deletions

View file

@ -1,4 +1,4 @@
FROM photoprism/development:20210117
FROM photoprism/development:20210205
# Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism"

View file

@ -131,7 +131,8 @@ RUN env GO111MODULE=off /usr/local/go/bin/go get -u github.com/psampaz/go-mod-ou
env GO111MODULE=off /usr/local/go/bin/go get -u github.com/tsliwowicz/go-wrk && \
env GO111MODULE=off /usr/local/go/bin/go get -u github.com/kyoh86/richgo && \
env GO111MODULE=off /usr/local/go/bin/go get -u github.com/tianon/gosu && \
echo "alias go=richgo" > /root/.bash_aliases
echo "alias go=richgo" > /root/.bash_aliases && \
cp /go/bin/gosu /bin/gosu
# Create photoprism user and directory for deployment
RUN useradd photoprism -m -d /photoprism && \

View file

@ -1,6 +1,7 @@
#!/usr/bin/env bash
if [[ ${UMASK} ]]; then
echo "entrypoint: umask ${UMASK}"
umask "${UMASK}"
fi
@ -10,13 +11,32 @@ chmod -Rf a+rw /var/lib/photoprism /tmp/photoprism /go
if [[ ${UID} ]] && [[ ${GID} ]] && [[ ${UID} != "0" ]] && [[ $(id -u) = "0" ]]; then
groupadd -f -g "${GID}" "${GID}"
usermod -o -u "${UID}" -g "${GID}" photoprism
chown -Rf photoprism /photoprism /var/lib/photoprism /tmp/photoprism /go
if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]] ; then
echo "entrypoint: updating storage permissions"
chown -Rf photoprism /photoprism /var/lib/photoprism /tmp/photoprism /go
fi
echo "entrypoint: uid ${UID}:${GID}"
echo "entrypoint: starting ${@}"
gosu "${UID}:${GID}" "$@" &
elif [[ ${UID} ]] && [[ ${UID} != "0" ]] && [[ $(id -u) = "0" ]]; then
usermod -o -u "${UID}" photoprism
chown -Rf photoprism /photoprism /var/lib/photoprism /tmp/photoprism /go
if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]] ; then
echo "entrypoint: updating storage permissions"
chown -Rf photoprism /photoprism /var/lib/photoprism /tmp/photoprism /go
fi
echo "entrypoint: uid ${UID}"
echo "entrypoint: starting ${@}"
gosu "${UID}" "$@" &
else
echo "entrypoint: uid $(id -u)"
echo "entrypoint: starting ${@}"
"$@" &
fi

View file

@ -1,19 +1,39 @@
#!/usr/bin/env bash
if [[ ${UMASK} ]]; then
echo "entrypoint: umask ${UMASK}"
umask "${UMASK}"
fi
if [[ ${UID} ]] && [[ ${GID} ]] && [[ ${UID} != "0" ]] && [[ $(id -u) = "0" ]]; then
groupadd -f -g "${GID}" "${GID}"
usermod -o -u "${UID}" -g "${GID}" photoprism
chown -Rf photoprism /photoprism/assets /photoprism/storage /photoprism/import /var/lib/photoprism /tmp/photoprism
if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]] ; then
echo "entrypoint: updating storage permissions"
chown -Rf photoprism /photoprism/storage /photoprism/assets /var/lib/photoprism /tmp/photoprism
fi
echo "entrypoint: uid ${UID}:${GID}"
echo "entrypoint: starting ${@}"
gosu "${UID}:${GID}" "$@" &
elif [[ ${UID} ]] && [[ ${UID} != "0" ]] && [[ $(id -u) = "0" ]]; then
usermod -o -u "${UID}" photoprism
chown -Rf photoprism /photoprism/assets /photoprism/storage /photoprism/import /var/lib/photoprism /tmp/photoprism
if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]] ; then
echo "entrypoint: updating storage permissions"
chown -Rf photoprism /photoprism/storage /photoprism/assets /var/lib/photoprism /tmp/photoprism
fi
echo "entrypoint: uid ${UID}"
echo "entrypoint: starting ${@}"
gosu "${UID}" "$@" &
else
echo "entrypoint: uid $(id -u)"
echo "entrypoint: starting ${@}"
"$@" &
fi

View file

@ -1,4 +1,4 @@
FROM photoprism/development:20210117 as build
FROM photoprism/development:20210205 as build
# Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism"