mirror of
https://github.com/immich-app/immich.git
synced 2025-12-12 15:50:43 -08:00
feat: relocate scripts, PATH update (#20002)
Relocate scripts, and PATH updates
This commit is contained in:
@@ -12,7 +12,7 @@ ENV PATH="${PATH}:/usr/src/app/bin" \
|
||||
IMMICH_ENV=development \
|
||||
NVIDIA_DRIVER_CAPABILITIES=all \
|
||||
NVIDIA_VISIBLE_DEVICES=all
|
||||
ENTRYPOINT ["tini", "--", "/bin/sh"]
|
||||
ENTRYPOINT ["tini", "--", "/bin/sh", "-c"]
|
||||
|
||||
FROM dev AS dev-container-server
|
||||
|
||||
@@ -110,8 +110,6 @@ COPY --from=prod /usr/src/app/bin ./bin
|
||||
COPY --from=web /usr/src/app/build /build/www
|
||||
COPY server/resources resources
|
||||
COPY server/package.json server/package-lock.json ./
|
||||
COPY server/start*.sh ./
|
||||
COPY "docker/scripts/get-cpus.sh" ./
|
||||
RUN npm install -g @immich/cli && npm cache clean --force
|
||||
COPY LICENSE /licenses/LICENSE.txt
|
||||
COPY LICENSE /LICENSE
|
||||
@@ -134,7 +132,7 @@ ENV IMMICH_SOURCE_URL=https://github.com/immich-app/immich/commit/${BUILD_SOURCE
|
||||
|
||||
VOLUME /usr/src/app/upload
|
||||
EXPOSE 2283
|
||||
ENTRYPOINT ["tini", "--", "/bin/bash"]
|
||||
ENTRYPOINT ["tini", "--", "/bin/bash", "-c"]
|
||||
CMD ["start.sh"]
|
||||
|
||||
HEALTHCHECK CMD immich-healthcheck
|
||||
|
||||
49
server/bin/get-cpus.sh
Executable file
49
server/bin/get-cpus.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
LOG_LEVEL="${IMMICH_LOG_LEVEL:='info'}"
|
||||
|
||||
logDebug() {
|
||||
if [ "$LOG_LEVEL" = "debug" ] || [ "$LOG_LEVEL" = "verbose" ]; then
|
||||
echo "DEBUG: $1" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
|
||||
logDebug "cgroup v2 detected."
|
||||
if [ -f /sys/fs/cgroup/cpu.max ]; then
|
||||
read -r quota period </sys/fs/cgroup/cpu.max
|
||||
if [ "$quota" = "max" ]; then
|
||||
logDebug "No CPU limits set."
|
||||
unset quota period
|
||||
fi
|
||||
else
|
||||
logDebug "/sys/fs/cgroup/cpu.max not found."
|
||||
fi
|
||||
else
|
||||
logDebug "cgroup v1 detected."
|
||||
|
||||
if [ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us ] && [ -f /sys/fs/cgroup/cpu/cpu.cfs_period_us ]; then
|
||||
quota=$(cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us)
|
||||
period=$(cat /sys/fs/cgroup/cpu/cpu.cfs_period_us)
|
||||
|
||||
if [ "$quota" = "-1" ]; then
|
||||
logDebug "No CPU limits set."
|
||||
unset quota period
|
||||
fi
|
||||
else
|
||||
logDebug "/sys/fs/cgroup/cpu/cpu.cfs_quota_us or /sys/fs/cgroup/cpu/cpu.cfs_period_us not found."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${quota:-}" ] && [ -n "${period:-}" ]; then
|
||||
cpus=$((quota / period))
|
||||
if [ "$cpus" -eq 0 ]; then
|
||||
cpus=1
|
||||
fi
|
||||
else
|
||||
cpus=$(grep -c ^processor /proc/cpuinfo)
|
||||
fi
|
||||
|
||||
echo "$cpus"
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
/usr/src/app/start.sh immich-admin "$@"
|
||||
start.sh immich-admin "$@"
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
node /usr/src/app/node_modules/.bin/nest start --debug "0.0.0.0:9230" --watch -- "$@"
|
||||
if [ "$IMMICH_ENV" != "development" ]; then
|
||||
echo "This command can only be run in development environments"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd /usr/src/app || exit 1
|
||||
node ./node_modules/.bin/nest start --debug "0.0.0.0:9230" --watch -- "$@"
|
||||
|
||||
44
server/bin/start.sh
Executable file
44
server/bin/start.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
echo "Initializing Immich $IMMICH_SOURCE_REF"
|
||||
|
||||
lib_path="/usr/lib/$(arch)-linux-gnu/libmimalloc.so.2"
|
||||
if [ -f "$lib_path" ]; then
|
||||
export LD_PRELOAD="$lib_path"
|
||||
else
|
||||
echo "skipping libmimalloc - path not found $lib_path"
|
||||
fi
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/jellyfin-ffmpeg/lib"
|
||||
SERVER_HOME=/usr/src/app
|
||||
|
||||
read_file_and_export() {
|
||||
if [ -n "${!1}" ]; then
|
||||
content="$(cat "${!1}")"
|
||||
export "$2"="${content}"
|
||||
unset "$1"
|
||||
fi
|
||||
}
|
||||
read_file_and_export "DB_URL_FILE" "DB_URL"
|
||||
read_file_and_export "DB_HOSTNAME_FILE" "DB_HOSTNAME"
|
||||
read_file_and_export "DB_DATABASE_NAME_FILE" "DB_DATABASE_NAME"
|
||||
read_file_and_export "DB_USERNAME_FILE" "DB_USERNAME"
|
||||
read_file_and_export "DB_PASSWORD_FILE" "DB_PASSWORD"
|
||||
read_file_and_export "REDIS_PASSWORD_FILE" "REDIS_PASSWORD"
|
||||
|
||||
if CPU_CORES="${CPU_CORES:=$(get-cpus.sh 2>/dev/null)}"; then
|
||||
echo "Detected CPU Cores: $CPU_CORES"
|
||||
if [ "$CPU_CORES" -gt 4 ]; then
|
||||
export UV_THREADPOOL_SIZE=$CPU_CORES
|
||||
fi
|
||||
else
|
||||
echo "skipping get-cpus.sh - not found in PATH or failed: using default UV_THREADPOOL_SIZE"
|
||||
fi
|
||||
|
||||
if [ -f "${SERVER_HOME}/dist/main.js" ]; then
|
||||
exec node "${SERVER_HOME}/dist/main.js" "$@"
|
||||
else
|
||||
echo "Error: ${SERVER_HOME}/dist/main.js not found"
|
||||
if [ "$IMMICH_ENV" = "development" ]; then
|
||||
echo "You may need to build the server first."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "Initializing Immich $IMMICH_SOURCE_REF"
|
||||
|
||||
lib_path="/usr/lib/$(arch)-linux-gnu/libmimalloc.so.2"
|
||||
export LD_PRELOAD="$lib_path"
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/jellyfin-ffmpeg/lib"
|
||||
|
||||
read_file_and_export() {
|
||||
if [ -n "${!1}" ]; then
|
||||
content="$(cat "${!1}")"
|
||||
export "$2"="${content}"
|
||||
unset "$1"
|
||||
fi
|
||||
}
|
||||
read_file_and_export "DB_URL_FILE" "DB_URL"
|
||||
read_file_and_export "DB_HOSTNAME_FILE" "DB_HOSTNAME"
|
||||
read_file_and_export "DB_DATABASE_NAME_FILE" "DB_DATABASE_NAME"
|
||||
read_file_and_export "DB_USERNAME_FILE" "DB_USERNAME"
|
||||
read_file_and_export "DB_PASSWORD_FILE" "DB_PASSWORD"
|
||||
read_file_and_export "REDIS_PASSWORD_FILE" "REDIS_PASSWORD"
|
||||
|
||||
export CPU_CORES="${CPU_CORES:=$(./get-cpus.sh)}"
|
||||
echo "Detected CPU Cores: $CPU_CORES"
|
||||
if [ "$CPU_CORES" -gt 4 ]; then
|
||||
export UV_THREADPOOL_SIZE=$CPU_CORES
|
||||
fi
|
||||
|
||||
exec node /usr/src/app/dist/main "$@"
|
||||
Reference in New Issue
Block a user