Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions container/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ set -e
# Cap JS heap to prevent OOM
export NODE_OPTIONS="--max-old-space-size=2048"

# Cap Go heap for tsgo (TypeScript native compiler) — Go doesn't auto-detect
# container memory limits, so without this tsgo allocates unbounded memory and hangs.
# Set to 75% of available RAM, leaving headroom for OS + other processes.
# See: https://github.com/microsoft/typescript-go/issues/2125
TOTAL_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}')
export GOMEMLIMIT=$(( TOTAL_KB * 3 / 4 / 1024 ))MiB

# Configure git with GitHub token
if [ -n "$GITHUB_TOKEN" ]; then
gh auth setup-git 2>/dev/null || true
Expand Down
3 changes: 2 additions & 1 deletion src/backends/local-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import path from 'path';
import {
CONTAINER_IMAGE,
CONTAINER_MAX_OUTPUT_SIZE,
CONTAINER_MEMORY,
CONTAINER_STARTUP_TIMEOUT,
CONTAINER_TIMEOUT,
DATA_DIR,
Expand Down Expand Up @@ -231,7 +232,7 @@ function buildVolumeMounts(
}

function buildContainerArgs(mounts: VolumeMount[], containerName: string): string[] {
const args: string[] = ['run', '-i', '--rm', '--name', containerName];
const args: string[] = ['run', '-i', '--rm', '--memory', CONTAINER_MEMORY, '--name', containerName];

for (const mount of mounts) {
if (mount.readonly) {
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const MAIN_GROUP_FOLDER = 'main';

export const CONTAINER_IMAGE =
process.env.CONTAINER_IMAGE || 'nanoclaw-agent:latest';
export const CONTAINER_MEMORY = process.env.CONTAINER_MEMORY || '4G';
export const CONTAINER_TIMEOUT = parseInt(
process.env.CONTAINER_TIMEOUT || '1800000',
10,
Expand Down
Loading