Docker: Fix entrypoint-init.sh script for non-root users #1337 #2076

This commit is contained in:
Michael Mayer 2022-03-02 10:30:07 +01:00
parent 4fc900b39a
commit d78cc31f72
10 changed files with 20 additions and 19 deletions

View file

@ -110,7 +110,7 @@ RUN /usr/local/go/bin/go install github.com/tianon/gosu@latest; \
cp /go/bin/gosu /bin/gosu && \ cp /go/bin/gosu /bin/gosu && \
echo "alias ll='ls -alh'" > /photoprism/.bash_aliases && \ echo "alias ll='ls -alh'" > /photoprism/.bash_aliases && \
echo "alias ll='ls -alh'" > /root/.bash_aliases && \ echo "alias ll='ls -alh'" > /root/.bash_aliases && \
echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/all && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \
cp /root/.local/bin/heif-convert.sh /usr/local/bin/heif-convert && \ cp /root/.local/bin/heif-convert.sh /usr/local/bin/heif-convert && \
cp /root/.local/bin/entrypoint.sh /entrypoint.sh && \ cp /root/.local/bin/entrypoint.sh /entrypoint.sh && \
chmod -R a+rwX /go chmod -R a+rwX /go

View file

@ -64,7 +64,7 @@ RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \
/photoprism/storage/config \ /photoprism/storage/config \
/photoprism/storage/cache \ /photoprism/storage/cache \
&& \ && \
echo "ALL ALL=(ALL) NOPASSWD: /opt/photoprism/scripts/entrypoint-init.sh" >> /etc/sudoers.d/init && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: /opt/photoprism/scripts/entrypoint-init.sh" >> /etc/sudoers.d/init && \
cleanup.sh cleanup.sh
# define default directory and user # define default directory and user

View file

@ -121,7 +121,7 @@ RUN /usr/local/go/bin/go install github.com/tianon/gosu@latest && \
cp /go/bin/gosu /bin/gosu && \ cp /go/bin/gosu /bin/gosu && \
echo "alias go=richgo ll='ls -alh'" > /photoprism/.bash_aliases && \ echo "alias go=richgo ll='ls -alh'" > /photoprism/.bash_aliases && \
echo "alias go=richgo ll='ls -alh'" > /root/.bash_aliases && \ echo "alias go=richgo ll='ls -alh'" > /root/.bash_aliases && \
echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/all && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \
cp /root/.local/bin/heif-convert.sh /usr/local/bin/heif-convert && \ cp /root/.local/bin/heif-convert.sh /usr/local/bin/heif-convert && \
cp /root/.local/bin/entrypoint.sh /entrypoint.sh && \ cp /root/.local/bin/entrypoint.sh /entrypoint.sh && \
chmod -R a+rwX /go chmod -R a+rwX /go

View file

@ -120,7 +120,7 @@ RUN /usr/local/go/bin/go install github.com/tianon/gosu@latest && \
cp /go/bin/gosu /bin/gosu && \ cp /go/bin/gosu /bin/gosu && \
echo "alias go=richgo ll='ls -alh'" > /photoprism/.bash_aliases && \ echo "alias go=richgo ll='ls -alh'" > /photoprism/.bash_aliases && \
echo "alias go=richgo ll='ls -alh'" > /root/.bash_aliases && \ echo "alias go=richgo ll='ls -alh'" > /root/.bash_aliases && \
echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/all && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \
cp /root/.local/bin/heif-convert.sh /usr/local/bin/heif-convert && \ cp /root/.local/bin/heif-convert.sh /usr/local/bin/heif-convert && \
cp /root/.local/bin/entrypoint.sh /entrypoint.sh && \ cp /root/.local/bin/entrypoint.sh /entrypoint.sh && \
chmod -R a+rwX /go chmod -R a+rwX /go

View file

@ -121,7 +121,7 @@ RUN /usr/local/go/bin/go install github.com/tianon/gosu@latest && \
cp /go/bin/gosu /bin/gosu && \ cp /go/bin/gosu /bin/gosu && \
echo "alias go=richgo ll='ls -alh'" > /photoprism/.bash_aliases && \ echo "alias go=richgo ll='ls -alh'" > /photoprism/.bash_aliases && \
echo "alias go=richgo ll='ls -alh'" > /root/.bash_aliases && \ echo "alias go=richgo ll='ls -alh'" > /root/.bash_aliases && \
echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/all && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \
cp /root/.local/bin/heif-convert.sh /usr/local/bin/heif-convert && \ cp /root/.local/bin/heif-convert.sh /usr/local/bin/heif-convert && \
cp /root/.local/bin/entrypoint.sh /entrypoint.sh && \ cp /root/.local/bin/entrypoint.sh /entrypoint.sh && \
chmod -R a+rwX /go chmod -R a+rwX /go

View file

@ -123,7 +123,7 @@ RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \
/photoprism/storage/config \ /photoprism/storage/config \
/photoprism/storage/cache \ /photoprism/storage/cache \
&& \ && \
echo "ALL ALL=(ALL) NOPASSWD: /opt/photoprism/scripts/entrypoint-init.sh" >> /etc/sudoers.d/init && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: /opt/photoprism/scripts/entrypoint-init.sh" >> /etc/sudoers.d/init && \
cp /opt/photoprism/scripts/entrypoint.sh /entrypoint.sh && \ cp /opt/photoprism/scripts/entrypoint.sh /entrypoint.sh && \
cleanup.sh cleanup.sh

View file

@ -124,7 +124,7 @@ RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \
/photoprism/storage/config \ /photoprism/storage/config \
/photoprism/storage/cache \ /photoprism/storage/cache \
&& \ && \
echo "ALL ALL=(ALL) NOPASSWD: /opt/photoprism/scripts/entrypoint-init.sh" >> /etc/sudoers.d/init && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: /opt/photoprism/scripts/entrypoint-init.sh" >> /etc/sudoers.d/init && \
cp /opt/photoprism/scripts/entrypoint.sh /entrypoint.sh && \ cp /opt/photoprism/scripts/entrypoint.sh /entrypoint.sh && \
cleanup.sh cleanup.sh

View file

@ -123,7 +123,7 @@ RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \
/photoprism/storage/config \ /photoprism/storage/config \
/photoprism/storage/cache \ /photoprism/storage/cache \
&& \ && \
echo "ALL ALL=(ALL) NOPASSWD: /opt/photoprism/scripts/entrypoint-init.sh" >> /etc/sudoers.d/init && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: /opt/photoprism/scripts/entrypoint-init.sh" >> /etc/sudoers.d/init && \
cp /opt/photoprism/scripts/entrypoint.sh /entrypoint.sh && \ cp /opt/photoprism/scripts/entrypoint.sh /entrypoint.sh && \
cleanup.sh cleanup.sh

15
scripts/dist/Makefile vendored
View file

@ -16,13 +16,16 @@ clean:
apt-get -y autoremove apt-get -y autoremove
apt-get -y autoclean apt-get -y autoclean
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
nano:
apt-get update
apt-get -qq install nano
gpu: gpu:
install-gpu.sh ./install-gpu.sh
tensorflow: tensorflow:
install-tensorflow.sh auto ./install-tensorflow.sh auto
davfs: davfs:
install-davfs.sh ./install-davfs.sh
.PHONY: update apt-upgrade clean apt-cleanup gpu tensorflow davfs install-davfs \ .PHONY: update apt-upgrade clean apt-cleanup nano gpu tensorflow davfs \
tensorflow-amd64-cpu tensorflow-amd64-avx tensorflow-amd64-avx2 install-davfs \ tensorflow-amd64-cpu tensorflow-amd64-avx tensorflow-amd64-avx2 \
intel-graphics install-intel-graphics; intel-graphics install-intel-graphics install-davfs;

View file

@ -14,13 +14,13 @@ re='^[0-9]+$'
# detect environment # detect environment
case $DOCKER_ENV in case $DOCKER_ENV in
prod) prod)
INIT_MAKEFILE="/opt/photoprism/scripts/Makefile" INIT_SCRIPTS="/opt/photoprism/scripts"
CHOWN_DIRS=("${PHOTOPRISM_HOME}" "${PHOTOPRISM_DIST}") CHOWN_DIRS=("${PHOTOPRISM_HOME}" "${PHOTOPRISM_DIST}")
CHMOD_DIRS=("${PHOTOPRISM_DIST}") CHMOD_DIRS=("${PHOTOPRISM_DIST}")
;; ;;
develop) develop)
INIT_MAKEFILE="/go/src/github.com/photoprism/photoprism/scripts/dist/Makefile" INIT_SCRIPTS="/go/src/github.com/photoprism/photoprism/scripts/dist"
CHOWN_DIRS=("/go /photoprism" "/opt/photoprism" "/tmp/photoprism") CHOWN_DIRS=("/go /photoprism" "/opt/photoprism" "/tmp/photoprism")
CHMOD_DIRS=("/photoprism" "/opt/photoprism" "/tmp/photoprism") CHMOD_DIRS=("/photoprism" "/opt/photoprism" "/tmp/photoprism")
;; ;;
@ -65,11 +65,9 @@ INIT_LOCK="/root/.init-lock"
# execute targets via make # execute targets via make
if [[ ! -e ${INIT_LOCK} ]]; then if [[ ! -e ${INIT_LOCK} ]]; then
for INIT_TARGET in $PHOTOPRISM_INIT; do for INIT_TARGET in $PHOTOPRISM_INIT; do
echo "init $INIT_TARGET..." echo "init $INIT_TARGET..."
make -f "$INIT_MAKEFILE" "$INIT_TARGET}" make -C "$INIT_SCRIPTS" "$INIT_TARGET"
done done
echo 1 >${INIT_LOCK} echo 1 >${INIT_LOCK}