- One install-node.sh <major> replaces install-node{18,20,22}.sh. It fails the
build if NodeSource hands back a version below the newest security release
for the line (22.23.4 / 24.22.1 / 26.12.1: CVE-2026-111497 Brotli OOB write
and 9 others), so a lagging mirror can't ship a vulnerable image silently.
18 and 20 are EOL: they still build, with a warning.
- CI matrix adds 24 and 26; fail-fast off so one line can't cancel the rest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.6 KiB
3.6 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Cloud Node Container (CNOC) is a Docker-based Node.js hosting environment that supports multiple Node.js versions (18, 20, 22, 24, 26) with Nginx reverse proxy, designed for both local development and production deployment.
Common Development Commands
Local Development Setup
# Quick start with automated setup (creates helper scripts and default app)
./local-dev.sh -n local-dev
# With specific Node.js version
./local-dev.sh -n myproject -a 22 # Node.js 22
# Helper scripts created by local-dev.sh:
./instance_start # Start container
./instance_stop # Stop container
./instance_logs # View container logs
./instance_shell # Access container shell
Building and Testing
# Build container locally
docker build -t cnoc:latest .
# Build with specific Node.js version
docker build --build-arg NODEVER=22 -t cnoc:node22 .
# Run container manually
docker run -d -p 80:80 -p 443:443 \
-e NODEVER=20 -e environment=DEV \
-e uid=$(id -u) -e user=$(whoami) -e domain=localhost \
-v"$(pwd)/user":/home/$(whoami) \
--name test-container cnoc:latest
Server Deployment
- Production git directory:
/root/whp - After
git pull, sync web files:rsync -av web-files/ /docker/whp/web/
Architecture and Key Components
Directory Structure
/scripts/- Container setup scripts (entrypoint, Node.js installers, nginx config)/configs/- Nginx, PM2, and default application configurations- User applications go in
/home/$user/app/
Container Behavior
-
Entrypoint Flow (
scripts/entrypoint.sh):- Creates user with specified UID
- Sets up directory structure (/home/$user/app/, logs/)
- Configures Nginx reverse proxy based on environment variables
- In DEV mode: starts Memcached for session storage
- Starts Nginx and PM2-managed Node.js application
-
Environment Modes:
- DEV (
environment=DEV): Local Memcached, automatic backups, verbose logging - PROD (default): Expects external services, optimized for production
- DEV (
-
Node.js Version Management:
- Controlled via
NODEVERenvironment variable (18, 20, 22, 24, 26) - Each version has dedicated install script in
/scripts/ - PM2 ecosystem configuration adapts to user paths
- Controlled via
Key Environment Variables
uid(required): User ID for file permissionsuser(required): Username for container userdomain(required): Primary domain for Nginx configurationserveralias: Additional domains (comma-separated)NODEVER: Node.js version to use (default: 20)environment: DEV or PROD mode
Important Technical Details
- Health Check: Available at
/pingendpoint (Node.js app must implement) - Logs Location:
/home/$user/logs/nginx/and/home/$user/logs/nodejs/ - Application Backups (DEV mode): Every 30 minutes to
/home/$user/_backups/ - Log Rotation: Compress after 3 days, delete after 7 days
- SSL: Self-signed certificate auto-generated, Nginx handles SSL termination
- Static Files: Nginx serves from
/home/$user/app/public/at/static/path - Process Management: PM2 handles Node.js application lifecycle
Application Requirements
User applications in /home/$user/app/ should include:
package.jsonwith dependencies and scripts- Main application file (default:
index.js) - Optional:
ecosystem.config.jsfor PM2 configuration - Optional:
public/directory for static assets
The container provides a default Express.js application with health endpoints and Memcached session support if no user application is found.