This guide helps you deploy LNp2pBot to DigitalOcean's App Platform.
- DigitalOcean Account with App Platform access
- Lightning Node (LND) accessible from the internet
- MongoDB Database (can use DigitalOcean's managed MongoDB)
- Telegram Bot Token from @BotFather
- Telegram Channels for orders and admin notifications
Ensure your repository contains:
.do/app.yaml(App Platform configuration)Dockerfile(container configuration)- All source code committed and pushed to GitHub
- Go to DigitalOcean App Platform
- Click "Create App"
- Choose GitHub as source
- Select your repository and branch (usually
main) - DigitalOcean will automatically detect the
.do/app.yamlconfiguration
You need to set these SECRET environment variables in the App Platform dashboard:
BOT_TOKEN=your_telegram_bot_token_here
LND_CERT_BASE64=your_lnd_tls_cert_base64_encoded
LND_MACAROON_BASE64=your_lnd_admin_macaroon_base64_encoded
MONGO_URI=mongodb://username:password@host:port/database_nameOn your LND node, run:
# Get TLS certificate (base64 encoded)
base64 -w0 ~/.lnd/tls.cert
# Get admin macaroon (base64 encoded)
base64 -w0 ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon- DigitalOcean Managed MongoDB: Recommended for production
- External MongoDB: Atlas, your own server, etc.
- Connection String Format:
mongodb://username:password@host:port/database_name
Important MongoDB Connection Notes:
- If using DigitalOcean Managed MongoDB, use the Private Network connection string
- Ensure your database allows connections from your App Platform instance
- For MongoDB Atlas, add
0.0.0.0/0to IP whitelist (or use VPC peering) - Test connection string format:
mongodb+srv://username:password@cluster.mongodb.net/database_name
In the App Platform dashboard, update these environment variables:
LND_GRPC_HOST: "your-lnd-node-host:10009"
CHANNEL: "@your_orders_channel"
ADMIN_CHANNEL: "@your_admin_channel"
LNURL_PUBLIC_URL: "https://your-app-name.ondigitalocean.app"SOCKS_PROXY_HOST: "your-proxy-host:port"NOSTR_PRIVATE_KEY: "your_nostr_private_key"
NOSTR_RELAYS: "wss://relay1.com,wss://relay2.com"Your LND node must:
- Be accessible from the internet on port 10009 (gRPC)
- Have sufficient channel capacity for hold invoices
- Be properly funded and connected to the Lightning Network
Ensure your LND node allows connections from DigitalOcean:
# Example iptables rule
iptables -A INPUT -p tcp --dport 10009 -j ACCEPT- Create Bot: Message @BotFather, use
/newbot - Create Channels:
- Public channel for order announcements
- Private channel for admin notifications
- Add Bot: Add your bot as admin to both channels
- Get Channel Names: Use format
@channelnameor-100XXXXXXfor private groups
- Create a MongoDB cluster in your DigitalOcean dashboard
- Add your app to the database's trusted sources
- Use the provided connection string
Ensure your MongoDB:
- Accepts connections from DigitalOcean IPs
- Has proper authentication configured
- Uses SSL/TLS for security
- Go to your app in DigitalOcean dashboard
- Click "Runtime Logs" tab
- Monitor for startup messages and errors
The bot includes several health monitoring jobs:
- Node connectivity checks every minute
- Pending payment retries every 5 minutes
- Order cleanup hourly
- Use Secrets: Never put sensitive data in regular environment variables
- TLS Certificates: Keep your LND certificates secure and rotate regularly
- Database Access: Use strong passwords and IP restrictions
- Monitoring: Set up alerts for failed deployments and errors
- Check BOT_TOKEN is valid
- Verify MongoDB connection string
- Ensure LND node is accessible
- Verify LND_GRPC_HOST format (host:port)
- Check base64 encoding of certificates
- Confirm LND node is running and accessible
- Test MongoDB connection string locally first
- Check MongoDB URI format: Ensure it matches your provider's requirements
- Network Access:
- DigitalOcean Managed DB: Use private network connection
- MongoDB Atlas: Add
0.0.0.0/0to IP whitelist or set up VPC peering - Self-hosted: Ensure firewall allows DigitalOcean App Platform IPs
- Verify credentials: Username, password, and database name
- Check database exists: Ensure the database name in the URI exists
- URI encoding: Special characters in passwords must be URL-encoded
View application logs:
# In DigitalOcean dashboard
Apps → Your App → Runtime Logs- Instance Size: Start with
basic-xxs, scale up based on usage - Instance Count: Keep at 1 for most use cases (stateful Lightning operations)
- Monitor connection count and query performance
- Consider indexing for frequently queried fields
- Scale MongoDB cluster as needed
Approximate monthly costs:
- App (basic-xxs): $5/month
- MongoDB (basic-xs): $25/month
- Total: ~$30/month
- Commits to main branch trigger automatic deployments
- Review deployment logs after each update
- Push changes to GitHub
- Go to App Platform dashboard
- Click "Actions" → "Force Rebuild and Deploy"
- LNp2pBot Issues: GitHub Issues
- DigitalOcean Support: Support Portal
- Lightning Network: LND Documentation