Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: chown shenanigans #410

Merged
merged 10 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ LABEL maintainer="hydazz, martabal"
# environment settings
ENV \
IMMICH_BUILD_DATA="/app/immich/server" \
IMMICH_ENV="production" \
IMMICH_MACHINE_LEARNING_URL="http://127.0.0.1:3003" \
IMMICH_MEDIA_LOCATION="/photos" \
IMMICH_PORT="8080" \
MACHINE_LEARNING_CACHE_FOLDER="/config/machine-learning/models" \
SERVER_PORT="8080" \
TRANSFORMERS_CACHE="/config/machine-learning/models"

RUN \
echo "**** install build packages ****" && \
apt-get update && \
apt-get install --no-install-recommends -y \
build-essential \
python3-dev && \
echo "**** install runtime packages ****" && \
apt-get install --no-install-recommends -y \
python3 \
python3-dev \
python3-pip \
python3-venv && \
echo "**** install runtime packages ****" && \
apt-get install --no-install-recommends -y \
python3 && \
echo "**** download immich ****" && \
mkdir -p \
/tmp/immich && \
Expand Down Expand Up @@ -125,7 +126,9 @@ RUN \
done && \
apt-get remove -y --purge \
build-essential \
python3-dev && \
python3-dev \
python3-pip \
python3-venv && \
apt-get autoremove -y --purge && \
apt-get clean && \
rm -rf \
Expand Down
7 changes: 5 additions & 2 deletions root/etc/s6-overlay/s6-rc.d/init-config-immich/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
# make folders
mkdir -p \
/config/machine-learning/models \
"$IMMICH_MEDIA_LOCATION"
"${IMMICH_MEDIA_LOCATION}"

# permissions
find "$IMMICH_MEDIA_LOCATION" -maxdepth 0 \( ! -user abc -o ! -group abc \) -exec lsiown -R abc:abc {} \;
find /app/immich -path "*/node_modules" -prune -o -exec chown abc:abc {} +
lsiown -R abc:abc \
/config
lsiown -R abc:abc \
"${IMMICH_MEDIA_LOCATION}" &

echo "Spawned chown on ${IMMICH_MEDIA_LOCATION} in the background"
6 changes: 3 additions & 3 deletions root/etc/s6-overlay/s6-rc.d/svc-machine-learning/run
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
[[ "${DISABLE_MACHINE_LEARNING}" == "true" || "${IMMICH_MACHINE_LEARNING_URL}" != "http://127.0.0.1:3003" ]] && tail -f /dev/null

lib_path="/usr/lib/$(arch)-linux-gnu/libmimalloc.so.2"
export LD_PRELOAD="$lib_path"
export LD_PRELOAD="${lib_path}"
export MPLCONFIGDIR="/tmp"
export HF_HOME="/tmp"

exec \
cd /app/immich/machine-learning s6-setuidgid abc \
gunicorn app.main:app \
-k uvicorn.workers.UvicornWorker \
-w "${MACHINE_LEARNING_WORKERS:=1}" \
-w "${MACHINE_LEARNING_WORKERS:-1}" \
-b "${MACHINE_LEARNING_HOST:-"0.0.0.0"}":"${MACHINE_LEARNING_PORT:-"3003"}" \
-t "${MACHINE_LEARNING_WORKER_TIMEOUT:=120}" \
-t "${MACHINE_LEARNING_WORKER_TIMEOUT:-120}" \
--log-config-json log_conf.json \
--graceful-timeout 0 || exit
10 changes: 5 additions & 5 deletions root/etc/s6-overlay/s6-rc.d/svc-microservices/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
lib_path="/usr/lib/$(arch)-linux-gnu/libmimalloc.so.2"
export LD_PRELOAD="$lib_path"

export CPU_CORES="${CPU_CORES:=$(/app/immich/server/scripts/get-cpus.sh)}"
echo "Detected CPU Cores: $CPU_CORES"
if [ "$CPU_CORES" -gt 4 ]; then
export UV_THREADPOOL_SIZE=$CPU_CORES
export "${CPU_CORES:="$(/app/immich/server/scripts/get-cpus.sh)"}"
hydazz marked this conversation as resolved.
Show resolved Hide resolved
echo "Detected CPU Cores: ${CPU_CORES}"
if [ "${CPU_CORES}" -gt 4 ]; then
export UV_THREADPOOL_SIZE=${CPU_CORES}
fi

exec \
cd /app/immich/server s6-setuidgid abc \
node dist/main microservices || exit
node dist/main microservices || exit
2 changes: 1 addition & 1 deletion root/etc/s6-overlay/s6-rc.d/svc-server/run
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[[ "${DISABLE_MACHINE_LEARNING}" == "true" ]] && export IMMICH_MACHINE_LEARNING_ENABLED=false

lib_path="/usr/lib/$(arch)-linux-gnu/libmimalloc.so.2"
export LD_PRELOAD="$lib_path"
export LD_PRELOAD="${lib_path}"

exec \
s6-notifyoncheck -d -n 300 -w 5000 -c "nc -z localhost 8080" \
Expand Down