Skip to content

Conversation

kshivang
Copy link

Problem

Currently, the edge-runtime has a hardcoded path for function compilation at /var/tmp/sb-compile-<executable-name>. This creates compatibility issues with deployment scenarios that require custom paths, particularly:

  1. Kubernetes deployments using community Helm charts that mount functions at different paths (e.g., /home/deno/functions)
  2. Restricted environments where /var/tmp may not be writable or available
  3. Custom Docker deployments that prefer different directory structures

Solution

This PR adds a configurable SUPABASE_FUNCTIONS_PATH environment variable that allows users to override the default function compilation path while maintaining full backward compatibility.

Changes Made:

  1. Modified standalone.rs: Added environment variable check for SUPABASE_FUNCTIONS_PATH with fallback to existing behavior
  2. Updated README.md: Added documentation for the new environment variable
  3. Maintained backward compatibility: Existing deployments continue to work unchanged

Code Changes:

let root_path = match std::env::var("SUPABASE_FUNCTIONS_PATH") {
  Ok(custom_path) => PathBuf::from(custom_path),
  Err(_) => {
    // Default behavior: use platform-specific temp directory
    if cfg!(target_family = "unix") {
      PathBuf::from("/var/tmp")
    } else {
      std::env::temp_dir()
    }
    .join(format!("sb-compile-{}", current_exe_name))
  }
};

Usage

Default behavior (unchanged):

  • Unix/Linux: /var/tmp/sb-compile-edge-runtime
  • Windows: %TEMP%\sb-compile-edge-runtime

Custom path:

export SUPABASE_FUNCTIONS_PATH=/home/deno/functions
./edge-runtime start --main-service /path/to/function

Kubernetes example:

env:
  - name: SUPABASE_FUNCTIONS_PATH
    value: "/home/deno/functions"

Testing

  • ✅ Maintains backward compatibility (no environment variable set)
  • ✅ Respects custom path when SUPABASE_FUNCTIONS_PATH is set
  • ✅ Documentation updated

Benefits

  1. Kubernetes compatibility: Enables edge functions to work with community Helm charts
  2. Deployment flexibility: Allows custom paths for different deployment scenarios
  3. Zero breaking changes: Existing deployments continue working without modification
  4. Security: Enables deployment in environments with restricted /var/tmp access

Related Issues


Reported-by: kshivang
Tested with: edge-runtime v1.69.6+

…ironment variable

- Make function compilation path configurable instead of hardcoded /var/tmp/sb-compile-*
- Maintains backward compatibility with existing deployments
- Enables flexibility for different deployment scenarios (Kubernetes, Docker, etc.)
- Add documentation for the new SUPABASE_FUNCTIONS_PATH environment variable

Fixes edge functions compatibility with community Kubernetes Helm charts
where custom mount paths are required.

Reported-by: kshivang
Comment on lines 34 to 35
risashivang/edge-runtime:configurable-path
risashivang/edge-runtime:latest
Copy link
Contributor

@kallebysantos kallebysantos Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need to update this to not directly reference risashivang user.

@kallebysantos
Copy link
Contributor

Hi @kshivang 💚
Is install_onnx.sh related with the main thread of this PR? or you just took the opportunity to refactor it as well?
May you please add a note of this change on your PR description? - for documenting

@kshivang
Copy link
Author

sure I will

@kshivang kshivang force-pushed the feature/configurable-functions-path branch from bb13d73 to 14c3e81 Compare September 13, 2025 19:45
@kshivang
Copy link
Author

Hey @kallebysantos I removed other commit from this PR, keeping just first commit that is relevant for this fix. For onnx I will create separate PR, as it is not relevant for this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants