diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index f38334a8fe7..2974c895e08 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -9,10 +9,19 @@ if [ -d "/app/.cache/prisma-python/binaries" ] && [ ! -d "/tmp/.cache/prisma-pyt echo "Prisma binaries copied successfully" fi -# Set runtime cache locations to /tmp (writable even in read-only root filesystem) -export XDG_CACHE_HOME="${XDG_CACHE_HOME:-/tmp/.cache}" -export NPM_CONFIG_CACHE="${NPM_CONFIG_CACHE:-/tmp/npm-cache}" -export PRISMA_BINARY_CACHE_DIR="${PRISMA_BINARY_CACHE_DIR:-/tmp/.cache/prisma-python/binaries}" +# Override Dockerfile ENV defaults that point to read-only /app/.cache, +# but respect user-provided overrides (e.g. via K8s pod spec, docker-compose). +# The Dockerfile.non_root sets these to /app/.cache/... at build time, but at +# runtime /app is read-only, so we redirect to /tmp which is always writable. +if [ "$XDG_CACHE_HOME" = "/app/.cache" ] || [ -z "$XDG_CACHE_HOME" ]; then + export XDG_CACHE_HOME="/tmp/.cache" +fi +if [ "$NPM_CONFIG_CACHE" = "/app/.cache/npm" ] || [ -z "$NPM_CONFIG_CACHE" ]; then + export NPM_CONFIG_CACHE="/tmp/npm-cache" +fi +if [ "$PRISMA_BINARY_CACHE_DIR" = "/app/.cache/prisma-python/binaries" ] || [ -z "$PRISMA_BINARY_CACHE_DIR" ]; then + export PRISMA_BINARY_CACHE_DIR="/tmp/.cache/prisma-python/binaries" +fi # Run the Python migration script python3 litellm/proxy/prisma_migration.py diff --git a/docker/prod_entrypoint.sh b/docker/prod_entrypoint.sh index 7c6eea6b9fb..18ae4a4bce2 100644 --- a/docker/prod_entrypoint.sh +++ b/docker/prod_entrypoint.sh @@ -8,10 +8,19 @@ if [ -d "/app/.cache/prisma-python/binaries" ] && [ ! -d "/tmp/.cache/prisma-pyt echo "Prisma binaries copied successfully" fi -# Set runtime cache locations to /tmp (writable even in read-only root filesystem) -export XDG_CACHE_HOME="${XDG_CACHE_HOME:-/tmp/.cache}" -export NPM_CONFIG_CACHE="${NPM_CONFIG_CACHE:-/tmp/npm-cache}" -export PRISMA_BINARY_CACHE_DIR="${PRISMA_BINARY_CACHE_DIR:-/tmp/.cache/prisma-python/binaries}" +# Override Dockerfile ENV defaults that point to read-only /app/.cache, +# but respect user-provided overrides (e.g. via K8s pod spec, docker-compose). +# The Dockerfile.non_root sets these to /app/.cache/... at build time, but at +# runtime /app is read-only, so we redirect to /tmp which is always writable. +if [ "$XDG_CACHE_HOME" = "/app/.cache" ] || [ -z "$XDG_CACHE_HOME" ]; then + export XDG_CACHE_HOME="/tmp/.cache" +fi +if [ "$NPM_CONFIG_CACHE" = "/app/.cache/npm" ] || [ -z "$NPM_CONFIG_CACHE" ]; then + export NPM_CONFIG_CACHE="/tmp/npm-cache" +fi +if [ "$PRISMA_BINARY_CACHE_DIR" = "/app/.cache/prisma-python/binaries" ] || [ -z "$PRISMA_BINARY_CACHE_DIR" ]; then + export PRISMA_BINARY_CACHE_DIR="/tmp/.cache/prisma-python/binaries" +fi if [ "$SEPARATE_HEALTH_APP" = "1" ]; then export LITELLM_ARGS="$@"