Deploy Apps with AWS Lightsail and CapRover
2025-01-20 · 5 min read
Deploy your app for $5–10/month with AWS Lightsail and CapRover. No Kubernetes, no complex setup. This guide walks you through each step with images for each section.
What You'll Need
- An AWS account
- A domain name (e.g.
yourdomain.com) - Your app code in a Git repo or a Dockerfile
Cost: $5–10/month for Lightsail. CapRover is free and open source.
Step 1: Create a Lightsail Instance
Go to AWS Lightsail and create a new instance.
What to choose:
- Region — Pick one close to your users (e.g.
us-east-1). - Platform — Linux/Unix.
- Blueprint — OS Only → Ubuntu 22.04.
- Plan — $5 or $10 for small apps.
- Name — e.g.
caprover-server.
Click Create instance. Wait 1–2 minutes for it to start.
Important: After creation, go to Networking → Create static IP and attach it to your instance. This keeps your IP address fixed when you reboot.
Step 2: Install Docker and CapRover
Click the SSH button on your instance to open a terminal in the browser. Or use your own SSH client.
Run these commands one by one:
# 1. Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
Log out and log back in (or run newgrp docker). Then:
# 2. Install CapRover
npm install -g caprover
caprover setup
During caprover setup you will:
- Enter your root domain (e.g.
captain.yourdomain.com). - Set a password for the CapRover dashboard.
- See instructions to add a DNS A record pointing to your Lightsail static IP.
Do the DNS step now. Add an A record: captain.yourdomain.com → your static IP. Wait a few minutes for DNS to propagate, then continue.
Step 3: Open Ports in Lightsail
CapRover needs ports 80 and 443 for HTTP/HTTPS.
- Go to your instance → Networking tab.
- Click Add rule.
- Add: HTTP (80) and HTTPS (443).
- Save.
Step 4: Deploy Your App
Open https://captain.yourdomain.com in your browser. Log in with the password you set.
To deploy:
- Go to Apps → Create new app (e.g.
myapp). - Set App URL (e.g.
app.yourdomain.com). - Enable HTTPS — CapRover will get a free SSL certificate.
- Add a DNS A record for
app.yourdomain.com→ your static IP. - Connect your GitHub/GitLab repo or upload a Dockerfile.
- Click Deploy.
CapRover will build and run your app. Your app will be live at https://app.yourdomain.com.
Simple Dockerfile for a Node app:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 3000
CMD ["node", "index.js"]
Step 5: HTTP Settings — Domains and Container Port
After creating your app, click on it and go to the HTTP Settings tab. This is where you configure domains, HTTPS, and the port your app listens on.
Key settings:
- Custom domains — Add
app.yourdomain.comandwww.yourdomain.com. Each gets its own SSL. - Enable HTTPS — Click to get a free Let's Encrypt certificate.
- Force HTTPS — Redirect HTTP to HTTPS (recommended).
- Container HTTP Port — Set to the port your app listens on (e.g.
3000for Node/Express). If you get a 502 error, this is usually the fix.
Step 6: App Config — Environment Variables
In your app's CapRover settings, go to App Configs → Environment Variables.
Add variables like:
NODE_ENV=productionDATABASE_URL=your-connection-string- Any API keys your app needs
Click Save and Restart the app. Variables are available as process.env.VAR_NAME in Node.js.
Troubleshooting
| Problem | Fix |
|---|---|
| Dashboard won't load | Check DNS for captain.yourdomain.com points to static IP. Ensure ports 80/443 are open. |
| App build fails | Check build logs in CapRover. Verify Dockerfile path and package.json build script. |
| HTTPS errors | Ensure app domain A record points to static IP. Wait for DNS propagation. |
| App returns 502 | Set Container HTTP Port in HTTP Settings to match your app (e.g. 3000). |
You're done. You now have a simple, cost-effective way to deploy apps. For backend patterns, see Backend Best Practices.