Skip to content

Add Node.js runtime support #2

@N3xusFour

Description

@N3xusFour

Summary

Add Node.js as a supported runtime alongside Deno and Bun.

Motivation

  • Many npm packages still assume "real Node" and may have quirks with Bun/Deno
  • High compatibility with existing JavaScript/TypeScript ecosystem
  • Low implementation effort since npm dependency flow already exists

Implementation Plan

1. Extend Runtime enum and image selection

  • Add RuntimeNode Runtime = "node" to models/models.go
  • Add RUNTIME_IMAGE_NODE env var support in executor/docker.go

2. Create Node Dockerfile (services/runtime-node/Dockerfile)

FROM node:20-alpine

RUN addgroup -g 1000 nodeuser && \
    adduser -D -u 1000 -G nodeuser nodeuser

USER nodeuser
WORKDIR /workspace

COPY --chown=nodeuser:nodeuser runner.mjs /runtime/runner.mjs

ENTRYPOINT ["node", "/runtime/runner.mjs"]

3. Create Node runner (services/runtime-node/runner.mjs)

  • Read stdin JSON (ExecutionInput)
  • Set process.env from event.env
  • Dynamic import user module from /workspace/${mainModule}
  • Call await module.handler(event, context)
  • Capture console methods for log collection
  • Output ExecutionOutput JSON to stdout

4. Add dependency installation

  • Add installNodeDependencies() function in executor/docker.go
  • Use npm install similar to how Bun uses bun add

Effort Estimate

~0.5-1 day

Acceptance Criteria

  • runtime: "node" accepted in setup request
  • Node.js handler functions execute correctly
  • npm dependencies install and are available at runtime
  • Console logs are captured
  • Works with gVisor sandboxing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions