This guide will help you deploy your mockup generator API to various cloud platforms and servers. This is an API-only server that receives requests from other applications - no frontend required.
Before deploying, ensure you have:
- A working mockup generator API (this repository)
- Basic knowledge of Linux commands
- A cloud provider account (for cloud deployments)
- Server IP address (domain name optional)
- CPU: 1 vCPU (2+ recommended)
- RAM: 1GB (2GB+ recommended)
- Storage: 10GB SSD
- OS: Ubuntu 20.04+ or CentOS 8+
- Network: Public IP with port 5002 open
- Node.js 18+
- ImageMagick 7+
- PM2 (for process management)
- ✅ No Frontend Required - Just pure API endpoints
- ✅ Simpler Setup - No Nginx or SSL configuration needed
- ✅ Faster Deployment - 10 minutes vs 30+ minutes
- ✅ Lower Resource Usage - No web server overhead
- ✅ Direct Communication - Server-to-server requests work perfectly
- ✅ Easy Scaling - PM2 handles multiple instances automatically
http://your-server-ip:5002/api/mockup/generate/tshirt
http://your-server-ip:5002/api/mockup/generate/mobile_cover
http://your-server-ip:5002/api/mockup/generate
http://your-server-ip:5002/health
- DigitalOcean: $5/month droplet
- Linode: $5/month nanode
- Vultr: $2.50/month instance
- AWS EC2: t3.micro (free tier eligible)
- Google Cloud: e2-micro (free tier eligible)
ssh root@your-server-ip
apt update && apt upgrade -y
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
apt-get install -y nodejs
apt install imagemagick -y
npm install -g pm2git clone https://github.com/yourusername/mockup-generator.git
cd mockup-generator
npm install
./create_maps.sh
npm startcat > ecosystem.config.js << EOF
module.exports = {
apps: [{
name: 'mockup-api',
script: 'server.js',
instances: 'max',
exec_mode: 'cluster',
env: {
NODE_ENV: 'production',
PORT: 5002
},
error_file: './logs/err.log',
out_file: './logs/out.log',
log_file: './logs/combined.log',
time: true
}]
}
EOFmkdir logs
pm2 start ecosystem.config.js
pm2 save
pm2 startupufw allow 5002
ufw enablecurl http://your-server-ip:5002/health
curl http://your-server-ip:5002/api/mockup/productsAWS offers the best free tier for API-only servers:
- EC2 t2.micro: 750 hours/month for 12 months
- 1GB RAM, 1 vCPU
- 30GB storage
- Ubuntu 20.04/22.04
- Perfect for your mockup API
- Create AWS Account at aws.amazon.com
- Launch EC2 Instance:
- Choose Ubuntu 22.04 LTS
- Select t2.micro (Free tier eligible)
- Create/Select Key Pair
- Configure Security Group (SSH, HTTP, Custom TCP 5002)
- Connect to Server:
ssh -i your-key.pem ubuntu@your-server-ip
- Setup Environment:
sudo apt update && sudo apt upgrade -y curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs sudo apt install imagemagick -y sudo npm install -g pm2
- Deploy Application:
git clone https://github.com/yourusername/mockup-generator.git cd mockup-generator npm install ./create_maps.sh pm2 start server.js pm2 save pm2 startup
- ✅ 12 months completely free
- ✅ Full Linux control
- ✅ ImageMagick works perfectly
- ✅ Production ready
- ✅ Easy setup
- ❌ Requires credit card (won't charge for free tier)
- ❌ 12-month limit
- e2-micro: 720 hours/month
- 1GB RAM, 1 vCPU
- 30GB storage
- Ubuntu 20.04/22.04
- $300 credit for 90 days
- Create GCP Account at cloud.google.com
- Create VM Instance:
- Choose e2-micro (Free tier)
- Select Ubuntu 22.04
- Allow HTTP traffic
- Connect and Setup (same as AWS)
- ✅ Always free tier available
- ✅ $300 credit for 90 days
- ✅ Full Linux control
- ✅ ImageMagick works perfectly
- ❌ Requires credit card
- ❌ More complex than AWS
- Basic Droplet: $5/month
- 1GB RAM, 1 vCPU
- 25GB storage
- Ubuntu 20.04/22.04
- Create DigitalOcean Account
- Create Droplet:
- Choose Ubuntu 22.04
- Select Basic $5/month plan
- Add SSH key
- Connect and Setup (same as AWS)
- ✅ Very reliable
- ✅ Simple pricing
- ✅ Good documentation
- ✅ Easy setup
- ❌ No free tier
- ❌ $5/month cost
FROM node:18-alpine
RUN apk add --no-cache imagemagick
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN ./create_maps.sh
EXPOSE 5002
CMD ["npm", "start"]version: '3.8'
services:
mockup-api:
build: .
ports:
- "5002:5002"
environment:
- NODE_ENV=production
- PORT=5002
restart: unless-stopped
volumes:
- ./logs:/app/logs# Build image
docker build -t mockup-api .
# Run container
docker run -d -p 5002:5002 --name mockup-api mockup-api
# Or with docker-compose
docker-compose up -d- Install Vercel CLI:
npm i -g vercel
- Deploy:
vercel
- Configure vercel.json:
{ "version": 2, "builds": [ { "src": "server.js", "use": "@vercel/node" } ], "routes": [ { "src": "/(.*)", "dest": "server.js" } ] }
- ✅ Free tier available
- ✅ Automatic deployments
- ✅ Global CDN
- ❌ ImageMagick not supported
- ❌ Function timeout limits
- Connect GitHub to Netlify
- Configure netlify.toml:
[build] command = "npm install" functions = "netlify/functions" [[redirects]] from = "/api/*" to = "/.netlify/functions/:splat" status = 200
- ✅ Free tier available
- ✅ Easy GitHub integration
- ❌ ImageMagick not supported
- ❌ Function limitations
NODE_ENV=production
PORT=5002
CORS_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
RATE_LIMIT_WINDOW=900000
RATE_LIMIT_MAX=100pm2 install pm2-logrotate
pm2 install pm2-server-monit
pm2 monit// Add to server.js for basic API key authentication
app.use('/api', (req, res, next) => {
const apiKey = req.headers['x-api-key'];
if (apiKey !== process.env.API_KEY) {
return res.status(401).json({ error: 'Unauthorized' });
}
next();
});curl http://your-domain.com/health
curl http://your-domain.com/api/mockup/healthpm2 logs mockup-api
tail -f /var/log/nginx/access.log
tail -f /var/log/nginx/error.lognpm install -g clinic
clinic doctor -- node server.js| Service | Free Tier | Paid Plans | ImageMagick | API-Only Ready |
|---|---|---|---|---|
| AWS EC2 | 750 hours/month | $5+/month | ✅ Native | ⭐⭐⭐⭐⭐ |
| Google Cloud | 720 hours/month | $5+/month | ✅ Native | ⭐⭐⭐⭐⭐ |
| DigitalOcean | None | $5+/month | ✅ Native | ⭐⭐⭐⭐⭐ |
| Linode | None | $5+/month | ✅ Native | ⭐⭐⭐⭐⭐ |
| Vultr | None | $2.50+/month | ✅ Native | ⭐⭐⭐⭐⭐ |
- AWS EC2 - 12 months completely free
- Google Cloud - Always free tier available
- AWS EC2 - Best free tier, full control
- Google Cloud - Good alternative with credits
- DigitalOcean - Simple and reliable
- AWS EC2 with Load Balancer
- Google Cloud with multiple instances
- VPS with PM2 clustering - Multiple Node.js instances
# 1. Create EC2 instance (via AWS Console)
# 2. Connect to server
ssh -i your-key.pem ubuntu@your-server-ip
# 3. Setup environment
sudo apt update && sudo apt upgrade -y
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt install imagemagick -y
sudo npm install -g pm2
# 4. Deploy application
git clone https://github.com/yourusername/mockup-generator.git
cd mockup-generator
npm install
./create_maps.sh
pm2 start server.js
pm2 save
pm2 startup# 1. Create VM instance (via GCP Console)
# 2. Connect to server (same as AWS)
# 3. Run same setup commands as AWS-
ImageMagick not found:
sudo apt install imagemagick -y sudo yum install ImageMagick -y
-
Port already in use:
sudo lsof -ti:5002 | xargs kill -9
-
Permission denied:
chmod +x create_maps.sh chmod +x *.sh -
Memory issues:
export NODE_OPTIONS="--max-old-space-size=2048"
- GitHub Issues: Create an issue
- Documentation: Check the main README.md
- API Docs: Visit
/api/mockup/docswhen deployed
Happy Deploying! 🚀 Your mockup generator API is ready to scale and serve users worldwide!