13 KiB
CapRover Deployment Guide
This guide walks you through deploying goodpackagerepo on CapRover, a free and open-source PaaS (Platform as a Service).
Table of Contents
- Prerequisites
- Overview
- Deployment Steps
- Configuration
- SSL/HTTPS Setup
- Verification
- Troubleshooting
- Updating Your Deployment
Prerequisites
Before you begin, ensure you have:
-
A CapRover instance running and accessible
- Follow the CapRover installation guide if you haven't set one up
- You can use a DigitalOcean droplet, AWS EC2, or any VPS
-
CapRover CLI installed on your local machine:
npm install -g caprover -
Your CapRover instance configured:
caprover serversetup -
A GitHub repository with the goodpackagerepo code (or clone the original)
-
Basic knowledge of:
- Command line operations
- Environment variables
- DNS configuration (for custom domains)
Overview
goodpackagerepo consists of two main components:
- Backend: Flask-based Python API (Port 5000)
- Frontend: Next.js React application (Port 3000)
You'll deploy these as two separate CapRover apps that communicate with each other.
Deployment Steps
1. Backend Deployment
Create the Backend App
-
Log in to your CapRover dashboard (e.g.,
https://captain.your-domain.com) -
Go to Apps and click "Create New App"
-
Enter the app name:
goodrepo-backend(or your preferred name)- Check "Has Persistent Data" to preserve your package data
- Click "Create New App"
Configure Backend Environment Variables
-
Click on your newly created
goodrepo-backendapp -
Go to the "App Configs" tab
-
Scroll down to "Environmental Variables" and add:
DATA_DIR=/data FLASK_ENV=production -
Click "Add Persistent Directory":
- Path in App:
/data - Label:
backend-data - Click "Save & Update"
- Path in App:
Deploy Backend from GitHub
-
Still in the
goodrepo-backendapp, go to "Deployment" tab -
Select "Method 3: Deploy from Github/Bitbucket/Gitlab"
-
Configure the deployment:
- Repository:
https://github.com/johndoe6345789/goodpackagerepo - Branch:
main(or your preferred branch) - Username: Your GitHub username
- Password/Token: Your GitHub personal access token
- Create one at https://github.com/settings/tokens
- Only needs
reposcope for public repos
- Repository:
-
Captain Definition File Path:
./backend/captain-definition -
Click "Save & Update"
-
The deployment will start automatically. Monitor the logs in the "App Logs" section
Verify Backend Deployment
Once deployment completes:
- Go to "HTTP Settings" tab
- Enable "Websocket Support" (recommended)
- Note your backend URL (e.g.,
https://goodrepo-backend.your-domain.com)
Test the backend:
curl https://goodrepo-backend.your-domain.com/auth/login
You should see a response about missing credentials (this is expected).
2. Frontend Deployment
Create the Frontend App
-
Go to Apps and click "Create New App"
-
Enter the app name:
goodrepo-frontend(or your preferred name)- No persistent data needed for frontend
- Click "Create New App"
Configure Frontend Environment Variables
-
Click on your
goodrepo-frontendapp -
Go to "App Configs" tab
-
Add the following environment variables:
Option 1: Separate Backend Domain (Traditional)
NEXT_PUBLIC_API_URL=https://goodrepo-backend.your-domain.com NODE_ENV=production PORT=3000Important: Replace
goodrepo-backend.your-domain.comwith your actual backend URL from step 1.Option 2: Single Domain with Next.js Proxy (New)
NEXT_PUBLIC_API_URL= BACKEND_URL=http://goodrepo-backend:5000 NODE_ENV=production PORT=3000This option allows the frontend to proxy
/auth/*,/v1/*,/admin/*,/health, and/schemarequests to the backend internally. With this setup, users access everything through the frontend domain (e.g.,https://repo.wardcrew.com/auth/login). Important: Replacegoodrepo-backendwith your actual backend app name in CapRover. -
Click "Save & Update"
Deploy Frontend from GitHub
-
Go to the "Deployment" tab
-
Select "Method 3: Deploy from Github/Bitbucket/Gitlab"
-
Configure the deployment:
- Repository:
https://github.com/johndoe6345789/goodpackagerepo - Branch:
main - Username: Your GitHub username
- Password/Token: Your GitHub personal access token
- Repository:
-
Captain Definition File Path:
./frontend/captain-definition -
Click "Save & Update"
-
Monitor the build in the logs (this may take 5-10 minutes for the first build)
Verify Frontend Deployment
- Once deployed, go to "HTTP Settings" tab
- Note your frontend URL (e.g.,
https://goodrepo-frontend.your-domain.com) - Visit the URL in your browser
You should see the goodpackagerepo interface!
Configuration
Default Credentials
On first deployment, the system uses default credentials:
- Username:
admin - Password:
admin
⚠️ IMPORTANT: Change these immediately after first login!
- Log in with default credentials
- Go to user settings or use the API:
curl -X POST https://goodrepo-backend.your-domain.com/auth/change-password \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"old_password": "admin", "new_password": "your-new-secure-password"}'
Custom Domain (Optional)
To use a custom domain:
- In CapRover, go to your app's "HTTP Settings"
- Click "Connect New Domain"
- Enter your domain (e.g.,
packages.yourdomain.com) - Add the DNS record as shown (usually a CNAME or A record)
- Wait for DNS propagation (can take up to 48 hours, usually much faster)
- Update the frontend's
NEXT_PUBLIC_API_URLif you added a custom domain to backend
SSL/HTTPS Setup
CapRover automatically provides SSL certificates via Let's Encrypt:
- Ensure your domain is pointing to your CapRover instance
- In the app's "HTTP Settings" tab
- Click "Enable HTTPS"
- Click "Force HTTPS" to redirect all HTTP traffic to HTTPS
- CapRover will automatically obtain and renew SSL certificates
Note: SSL setup only works after DNS has propagated and your domain is accessible.
Verification
After deployment, verify everything is working:
1. Test Backend API
If using Option 1 (Separate Backend Domain):
# Health check (if implemented)
curl https://goodrepo-backend.your-domain.com/
# Login endpoint
curl -X POST https://goodrepo-backend.your-domain.com/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "admin"}'
If using Option 2 (Single Domain with Next.js Proxy):
# Login endpoint through frontend proxy
curl -X POST https://goodrepo-frontend.your-domain.com/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "admin"}'
2. Test Frontend
- Open
https://goodrepo-frontend.your-domain.comin your browser - Try logging in with default credentials
- Upload a test package or browse the interface
3. Test Package Upload
If using Option 1 (Separate Backend Domain):
# Login to get token
TOKEN=$(curl -X POST https://goodrepo-backend.your-domain.com/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "admin"}' | jq -r '.token')
# Upload a test package
echo "test content" > test.txt
curl -X PUT "https://goodrepo-backend.your-domain.com/v1/test/package/1.0.0/default/blob" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @test.txt
If using Option 2 (Single Domain with Next.js Proxy):
# Login to get token through frontend proxy
TOKEN=$(curl -X POST https://goodrepo-frontend.your-domain.com/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "admin"}' | jq -r '.token')
# Upload a test package through frontend proxy
echo "test content" > test.txt
curl -X PUT "https://goodrepo-frontend.your-domain.com/v1/test/package/1.0.0/default/blob" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @test.txt
Troubleshooting
Backend Won't Start
Issue: Backend deployment fails or app won't start
Solutions:
- Check the app logs in CapRover dashboard
- Verify all environment variables are set correctly
- Ensure
DATA_DIRis set to/data - Verify persistent directory is mounted at
/data - Check that required environment variables are set
Frontend Can't Connect to Backend
Issue: Frontend loads but API calls fail
Solutions:
- Verify
NEXT_PUBLIC_API_URLpoints to the correct backend URL - Ensure backend URL includes
https://prefix - Check that backend is accessible from the internet
- Verify CORS is properly configured (should work by default)
- Check browser console for specific error messages
Build Failures
Issue: Frontend build fails during deployment
Solutions:
- Check the deployment logs for specific errors
- Verify the
captain-definitionfile path is correct:./frontend/captain-definition - Ensure repository access token has correct permissions
- Try redeploying from the CapRover dashboard
Persistent Data Not Saving
Issue: Data disappears after redeployment
Solutions:
- Verify "Has Persistent Data" was checked when creating the app
- Check that persistent directory is added:
/data - Ensure
DATA_DIR=/dataenvironment variable is set - In App Configs, verify the persistent directory mapping exists
SSL Certificate Errors
Issue: SSL certificate not working or showing warnings
Solutions:
- Verify DNS is properly configured and propagated
- Wait a few minutes for Let's Encrypt to issue certificate
- Check CapRover dashboard for SSL status
- Try disabling and re-enabling HTTPS
- Ensure domain is accessible from internet (not behind firewall)
Performance Issues
Issue: App is slow or unresponsive
Solutions:
- Check server resources (CPU, RAM, Disk)
- Consider upgrading your VPS plan
- Monitor app logs for errors
- Check database/blob storage performance
- Consider adding caching layer if handling high traffic
Can't Login / Authentication Issues
Issue: Unable to login with credentials
Solutions:
- Verify backend is running and accessible
- Check that required environment variables are set
- Try using default credentials:
admin/admin - Check backend logs for authentication errors
- Verify the backend data directory has proper permissions
Updating Your Deployment
Manual Update
To update your deployment with new code:
- Push your changes to your Git repository
- In CapRover dashboard, go to your app's "Deployment" tab
- Click "Force Build" or push a new commit
- Monitor the deployment logs
Automatic Updates
You can set up webhooks for automatic deployment:
- In the "Deployment" tab, find the webhook URL
- Add this as a webhook in your GitHub repository settings
- Set it to trigger on
pushevents to your main branch - Now every push will automatically deploy to CapRover
Rollback
If something goes wrong:
- Go to "Deployment" tab in CapRover
- Find the previous successful version
- Click "Deploy" on that version to rollback
Best Practices
-
Security:
- Change default passwords immediately
- Use strong application secrets (32+ characters)
- Enable HTTPS and force HTTPS redirects
- Regularly update dependencies
-
Backups:
- Regularly backup your
/datadirectory - Export critical package metadata
- Keep configuration documented
- Regularly backup your
-
Monitoring:
- Set up monitoring for your apps
- Check logs regularly
- Monitor disk space usage in persistent directories
-
Performance:
- Use appropriate VPS sizing for your load
- Consider CDN for frequently accessed packages
- Monitor resource usage in CapRover dashboard
-
Updates:
- Test updates in a staging environment first
- Keep CapRover itself updated
- Review changelogs before updating
Additional Resources
Support
If you encounter issues not covered in this guide:
- Check the main README for general information
- Review CapRover logs in the dashboard
- Search existing GitHub issues
- Create a new issue with:
- Detailed description of the problem
- Relevant log excerpts
- Steps to reproduce
- Your environment details (CapRover version, OS, etc.)
Happy deploying! 🚀