🟢
Languages & Build

Node.js

JavaScript runtime for web apps, APIs, and CLI tools

🐧 Linux🍎 Mac🪟 Windows
Reviewed: Tested on: Kubernetes 1.29 · Terraform 1.8 · Ubuntu 22.04

What is this?

Node.js runs JavaScript on the server — the foundation of npm, Express, and most frontend tooling.

📥

Step 01

Install Node.js

(01)Install Node.js

Linux
1curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
2sudo apt-get install -y nodejs
⚙️

Step 02

Configure Node.js

(01)Configure Node.js

Linux
1node --version
2npm init -y
3npm install express

Step 03

Verify

(01)Verify installation

Linux
1node -e "console.log('OK')"
2npm --version

📋Config templates

1 YAML template for Node.js. Copy and deploy after setup.

1 ready-to-copy template. Expand one, copy the YAML, then run the deploy commands.

docker-compose.yml

Node API, Redis cache, MongoDB with named volumes

yaml
1services:
2 api:
3 build: .
4 ports:
5 - "3000:3000"
6 environment:
7 REDIS_URL: redis://redis:6379
8 MONGO_URL: mongodb://mongo:27017/app
9 depends_on:
10 - redis
11 - mongo
12
13 redis:
14 image: redis:7-alpine
15 ports:
16 - "6379:6379"
17 volumes:
18 - redis_data:/data
19
20 mongo:
21 image: mongo:7
22 ports:
23 - "27017:27017"
24 volumes:
25 - mongo_data:/data/db
26
27volumes:
28 redis_data:
29 mongo_data:

Dockerfile

dockerfile
1FROM node:20-alpine
2WORKDIR /app
3COPY package*.json ./
4RUN npm ci --omit=dev
5COPY . .
6EXPOSE 3000
7CMD ["node", "server.js"]
📄

Step 01

Run Node + Redis + Mongo

(01)Start stack

Linux
1docker compose up -d --build
2docker compose ps
3docker compose logs -f

(02)Stop

Linux
1docker compose down