diff --git a/Dockerfile b/Dockerfile index 3e3331a5df..135c6abceb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,8 @@ LABEL org.opencontainers.image.title="omniroute" \ ENV NODE_ENV=production ENV PORT=20128 ENV HOSTNAME=0.0.0.0 -ENV NODE_OPTIONS="--max-old-space-size=256" +ENV OMNIROUTE_MEMORY_MB=1024 +ENV NODE_OPTIONS="--max-old-space-size=${OMNIROUTE_MEMORY_MB}" # Data directory inside Docker — must match the volume mount in docker-compose.yml ENV DATA_DIR=/app/data diff --git a/scripts/check-permissions.sh b/scripts/check-permissions.sh index 13eedf45b0..45846806ca 100755 --- a/scripts/check-permissions.sh +++ b/scripts/check-permissions.sh @@ -1,6 +1,13 @@ #!/bin/sh set -e +# ── Memory limit override ────────────────────────────────────────────── +# If OMNIROUTE_MEMORY_MB is set, build NODE_OPTIONS dynamically so the +# user can tune heap size via environment without editing the Dockerfile. +if [ -n "$OMNIROUTE_MEMORY_MB" ]; then + export NODE_OPTIONS="--max-old-space-size=${OMNIROUTE_MEMORY_MB} ${NODE_OPTIONS:-}" +fi + if [ -d "/app/data" ] && [ ! -w "/app/data" ]; then echo "WARNING: /app/data is not writable by the current user (UID $(id -u))." echo "Run this on the Docker host to fix:"