create-strapi-fly
v1.6.0
Published
Interactive CLI tool to create and deploy Strapi instances on Fly.io with Cloudflare R2 storage
Downloads
33
Maintainers
Readme
create-strapi-fly
🚀 Interactive CLI tool to create and deploy Strapi instances on Fly.io with Cloudflare R2 storage
🎯 Features
- ✨ One-command setup - Create a production-ready Strapi instance with a single npx command
- 🔐 Secure by default - Automatically generates all required secrets and tokens
- ☁️ Cloudflare R2 integration - File uploads stored in R2 with CDN support
- 🚀 Fly.io deployment - Containerized deployment with persistent storage
- 📦 Latest Strapi version - Uses Strapi 5 beta with AI features
- 🎨 Interactive CLI - Guided setup with validation and helpful prompts
- 🔄 Complete automation - Handles everything from project creation to deployment
📋 Prerequisites
Before running this tool, ensure you have:
Required Software
- Node.js (v18-22)
- npm or yarn
- Fly CLI (Installation guide)
Accounts & Configuration
- Fly.io account - Sign up at fly.io and run
fly auth login - Cloudflare R2 setup:
- Create an R2 bucket
- Generate R2 API credentials (Access Key ID & Secret)
- Note your R2 endpoint URL
- Configure a custom domain for CDN (optional but recommended)
🚀 Quick Start
Create a New Instance
Run the following command in any directory:
npx create-strapi-flyOr with yarn:
yarn create strapi-flyThe CLI will guide you through the entire setup process!
Uninstall/Cleanup
To remove all Fly.io resources (app, volumes, secrets) for an existing project:
cd your-strapi-project
npx create-strapi-fly uninstallAliases: cleanup, destroy
Warning: This permanently deletes your Fly.io app and all data. Your local files remain unchanged.
Create Tracker (For Orphaned Resources)
If you cancelled the setup early and have orphaned Fly.io resources:
cd your-strapi-project
npx create-strapi-fly create-trackerThis will fetch your Fly.io app info and create the tracker file so you can use the uninstall command.
📖 What It Does
Setup Process
The tool automates these steps:
- Creates a new Strapi application using the latest beta version
- Installs required dependencies including AWS S3 provider for R2
- Generates secure tokens for all authentication and encryption needs
- Configures Cloudflare R2 for file storage with CDN
- Creates Docker configuration for containerized deployment
- Sets up Fly.io resources:
- Creates the application
- Provisions persistent storage volume
- Configures all environment secrets
- Saves resource tracker (
.strapi-fly-resources.json) for easy cleanup - Deploys to production (optional immediate deployment)
Cleanup Process
When you run npx create-strapi-fly uninstall:
- Reads resource tracker (
.strapi-fly-resources.json) - Confirms deletion (requires typing app name)
- Deletes Fly.io volumes (all persistent data)
- Destroys Fly.io app (deployments and secrets)
- Removes tracker file
- Keeps local files (your project remains intact)
💡 Usage Examples
Basic Usage
npx create-strapi-flyFollow the interactive prompts to:
- Name your application
- Choose deployment region
- Enter R2 credentials
- Configure CDN domain
- Deploy immediately or later
What You'll Need
During setup, have ready:
- Fly.io region code (e.g.,
mia,lax,ord,iad) - R2 endpoint URL (e.g.,
https://accountid.r2.cloudflarestorage.com) - R2 bucket name
- R2 Access Key ID
- R2 Secret Access Key
- CDN domain (e.g.,
https://cdn-myapp.mydomain.com)
🏗️ Project Structure
After running the tool, your project will have:
your-app-name/
├── .env # Environment variables (git-ignored)
├── .strapi-fly-resources.json # Resource tracker (git-ignored)
├── Dockerfile # Multi-stage Docker build
├── .dockerignore # Docker build exclusions
├── fly.toml # Fly.io configuration
├── package.json # Dependencies
├── config/
│ ├── plugins.ts # R2/S3 upload configuration
│ ├── middlewares.ts # Security & CSP settings
│ └── env/production/
│ └── database.ts # Production database config
└── src/ # Strapi application code🔧 Configuration
Environment Variables
The tool automatically generates and configures:
APP_KEYS- Application encryption keysADMIN_JWT_SECRET- Admin authenticationJWT_SECRET- API authenticationAPI_TOKEN_SALT- API token generationTRANSFER_TOKEN_SALT- Transfer token generationENCRYPTION_KEY- Database encryptionR2_*- Cloudflare R2 configurationSTRAPI_ADMIN_AI_API_KEY- Optional AI features
Deployment Configuration
- Region: Choose any Fly.io region
- Resources: 1GB RAM, 1 shared CPU (configurable)
- Storage: 2GB persistent volume for SQLite database
- Ports: HTTP (80) and HTTPS (443)
🚢 Deployment
Immediate Deployment
During setup, choose "yes" when prompted to deploy immediately.
Manual Deployment
If you chose to deploy later:
cd your-app-name
fly deploy --strategy immediateAfter Deployment
Your Strapi instance will be available at:
- Application:
https://your-app-name.fly.dev - Admin Panel:
https://your-app-name.fly.dev/admin
📚 Next Steps
After deployment:
- Create admin user - Visit
/adminto set up your first admin account - Configure content types - Use the Content-Type Builder
- Set permissions - Configure API access in Settings > Roles
- Test uploads - Verify R2 integration is working
🔧 CLI Commands
Main Commands
# Create new instance (interactive)
npx create-strapi-fly
# Uninstall Fly.io resources
npx create-strapi-fly uninstall
npx create-strapi-fly cleanup # alias
npx create-strapi-fly destroy # alias
# Create tracker for orphaned resources
npx create-strapi-fly create-tracker
# Show help
npx create-strapi-fly --helpResource Tracker
The tool creates a .strapi-fly-resources.json file that tracks:
- Fly.io app name
- Region
- Volume name
- Creation timestamp
This file is used by the uninstall command to clean up resources. It's automatically added to .gitignore.
Important: Keep this file if you want to use the uninstall command later!
🐛 Troubleshooting
Common Issues
Fly CLI not found
# Install Fly CLI
curl -L https://fly.io/install.sh | shNot authenticated with Fly
fly auth loginR2 connection fails
- Verify your R2 credentials
- Check bucket exists and is accessible
- Ensure CDN domain is configured correctly
Deployment fails
- Check Fly.io dashboard for logs
- Verify all secrets are set correctly
- Ensure sufficient quota in Fly.io account
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Strapi for the amazing headless CMS
- Fly.io for simple application deployment
- Cloudflare R2 for S3-compatible storage
📮 Support
For issues and questions:
- Open an issue on GitHub
- Check existing issues for solutions
- Ensure you have the latest version:
npm update -g create-strapi-fly
Made with ❤️ for the Strapi community
