How to Deploy NestJS with Docker for Free
Deploy a NestJS backend to Oracle Cloud free tier with Docker. $0/month. 4 ARM cores, 24GB RAM, 200GB storage. Step-by-step from a developer running 4 production apps on it.
Deploy a NestJS backend to Oracle Cloud free tier with Docker. $0/month. 4 ARM cores, 24GB RAM, 200GB storage. Step-by-step from a developer running 4 production apps on it.
NestJS on Oracle Cloud free tier. $0/month. 4 cores, 24GB RAM. Production-ready.
Prerequisites
I run 4 production NestJS backends on Oracle Cloud's free tier. Zero dollars per month. 24GB of RAM total. It handles thousands of daily active users without issues.
This isn't a trial. It's their Always Free tier — no expiration.
For comparison, equivalent specs on AWS EC2 cost ~$108/month.
Oracle Cloud Console → Compute → Create Instance:
OCI Console → Networking → Security Lists → Add ingress rules:
Also open ports in Ubuntu's firewall:
ssh ubuntu@YOUR_IP
sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 443 -j ACCEPT
sudo netfilter-persistent save
sudo apt update && sudo apt install -y docker.io docker-compose
sudo usermod -aG docker ubuntu
# Log out and back in
FROM node:20-slim AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-slim
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
EXPOSE 3000
CMD ["node", "dist/main.js"]
services:
api:
build: .
ports:
- "3000:3000"
env_file:
- .env
restart: always
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
# On the server
git clone your-repo
cd your-repo
cp .env.example .env # Edit with production values
docker-compose up -d --build
Use Caddy as a reverse proxy — it handles SSL automatically:
sudo apt install -y caddy
Edit /etc/caddy/Caddyfile:
yourdomain.com {
reverse_proxy localhost:3000
}
sudo systemctl restart caddy
Done. HTTPS is automatic.
Oracle's "Out of capacity" error. ARM instances are popular. If creation fails, try a different availability domain or try again later.
Don't forget OCI security lists. Ubuntu firewall AND OCI security lists both need the ports open. Missing either one blocks traffic.
ARM architecture. Some npm packages with native binaries need ARM builds. Most popular packages support it. Check before deploying.
Everything in this guide is already pre-configured in AI App Factory. 11 AI agents automate the rest.