What you’ll learn
- Fork and configure open-source projects for Upsun deployment
- Adapt application configuration for cloud deployment
- Manage environment variables and service dependencies
- Keep your fork synchronized with upstream changes
- Deploy production-ready open-source applications
Prerequisites
Before starting, ensure you have:- An Upsun account with an active project
- A GitHub account
- Basic familiarity with Git and command line operations
- Upsun CLI installed locally
Forking the target repository
Start by creating your own fork of the open-source project you want to deploy. This gives you full control over the codebase while maintaining the ability to pull updates from the original project. Using Snipe-IT as our example:- Navigate to the Snipe-IT repository on GitHub
- Click the Fork button in the top-right corner
- Choose your GitHub account as the destination
- Wait for GitHub to create your fork
Adding Upsun configuration
Every application needs specific configuration to run on Upsun. We’ll create the necessary configuration files to define our application, services, and deployment process. The configuration approach varies by technology stack, but the core concepts remain the same. Here’s how to configure a Laravel application (Snipe-IT), with notes on adapting for other frameworks.Create the Upsun configuration
Create the.upsun/config.yaml file in your repository root. This example shows a Laravel/PHP configuration, but adapt the runtime, extensions, and build process for your specific technology stack:
- Runtime: Specify your application’s language and version (php:8.2, node:18, python:3.11, etc.)
- Extensions: Add required language extensions for your application
- Services: Define databases, caches, and other dependencies
- Build/Deploy hooks: Commands to build assets and initialize the application
- Mounts: Writable directories for user uploads, logs, and cache files
Create environment configuration
Create a.environment file to map Upsun service variables to your application’s expected format. This example shows Laravel environment mapping:
- Django: Map to
DATABASE_URL,REDIS_URL, etc. - Node.js/Express: Set
DATABASE_URL,REDIS_URL,PORT, etc. - Rails: Configure
DATABASE_URL,REDIS_URL,RAILS_ENV, etc. - WordPress (Bedrock): Map to
DB_HOST,DB_USER,DB_PASSWORD,WP_CACHE_KEY_SALT, etc.
Commit the configuration
Add and commit your new configuration files:main instead of master as the default branch. Adjust accordingly.
Creating your Upsun project
Now create a new Upsun project and connect it to your GitHub repository.Using the Upsun Console
- Log in to the Upsun Console
- Click Create Project
- Choose Import from GitHub
- Select your forked Snipe-IT repository
- Choose your preferred region (select green regions for extra discounts)
- Configure your project settings:
- Project name: Give your project a descriptive name
- Production branch:
masterormain(depending on your repository) - Build and deploy immediately: Check this option
If this is your first time using our GitHub integration, you will redirected to authorize the Upsun GitHub app to access your desired repositories.
Using the CLI (Alternative)
Alternatively, create the project using the Upsun CLI:Please notice with use the
--default-branch=master flag as the Snipe-IT GitHub project still uses master instead of the new default main.Configuring environment variables
Most open-source applications require environment variables for proper operation. The specific variables depend on your application, but common categories include app configuration, database connections, API keys, and feature flags. Here are examples for Snipe-IT (Laravel), with notes on what to adapt for other applications:Generating application secrets
Many applications require unique keys or secrets. For Laravel applications like Snipe-IT, generate the APP_KEY locally:APP_KEY variable (see <ARTISAN-KEY> below).
For other frameworks:
- Django: Generate
SECRET_KEYwithpython -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())" - Node.js: Generate random strings for session secrets using crypto libraries
- Rails: Use
rails secretto generateSECRET_KEY_BASE
Essential variables
Set these variables at the project level:First deployment
If you are using the GitHub integration, Upsun will automatically trigger deployments based on your GitHub repository events. If not, you can start your first deployment:- Via Console: Navigate to your project and click Deploy
- Via Git: Push changes to your master branch
- Via CLI: Use
upsun redeploy
- Build your application with the appropriate package manager
- Compile frontend assets (if configured)
- Run database migrations and initialization scripts
- Configure services (databases, caches, etc.)
- Generate SSL certificates
Accessing your deployment
Once deployed, access your application through the provided URL. Most open-source applications require initial setup: For Snipe-IT:- Create your admin account
- Configure company settings
- Set up asset categories and models
- Configure LDAP (if needed)
- Customize appearance and branding
Adding a custom domain
For production use, add your custom domain:- In the Upsun Console, go to Domains
- Click Add Domain
- Enter your domain name
- Configure DNS with the provided CNAME record
- Wait for SSL certificate provisioning
Keeping your fork updated
Open-source projects receive regular updates for security patches, bug fixes, and new features. Keep your fork synchronized to benefit from these improvements:Setting up upstream remote
Syncing updates
Regularly sync with upstream changes. Thanks to Upsun, you can preview and test these updates to avoid any issue with breaking changes:Handling conflicts
If you’ve customized the application, you may encounter merge conflicts during sync:- Review conflicts: Use
git statusto identify conflicted files - Resolve manually: Edit files to resolve conflicts
- Test changes: Ensure functionality remains intact
- Commit resolution:
git add .andgit commit
Automated sync with GitHub Actions
Consider automating upstream sync with GitHub Actions:Getting help
- Check your project’s official documentation
- Review Upsun documentation for platform-specific issues
- Search the project’s GitHub issues for similar problems
- Join project-specific community forums or the Upsun Discord server
- Check framework-specific resources (Laravel, Django, Rails, etc.)
Conclusion
You now have your open-source application running on Upsun with a robust deployment pipeline. Your setup includes:- Production-ready services (database, cache, etc.)
- SSL certificates and custom domain support
- Automated upstream synchronization strategy
- Scalable infrastructure that grows with your needs