In today's tutorial, we'll deploy a Payload V3 project using Coolify.
What is Coolify?
https://coolify.io
is an open-source project that provides a Vercel-like developer experience on your server. It features:- Project Dashboard: Manage multiple projects on one server.
- Notifications: Receive email or Telegram alerts for deployment failures.
- Web Hooks: Automatically deploy from your GitHub repository.
- Templates: Easily deploy MongoDB, MySQL databases, and more.
- Automatic Preview Domains: Generate automatic preview domains for your projects and environments.
Why Choose Coolify?
Open-Source and Self-Hosted
Coolify is open-source, allowing you to host it on your VPS or server, ensuring you own your data. This is crucial for GDPR compliance, especially in regions like Germany.
Cost-Effective
Hosting on Coolify can be cheaper than using platforms like Vercel or Railway, particularly for higher workloads, as you manage your server resources directly.
Enhanced Role-Based Access Control
Compared to Vercel, Coolify offers role-based access control for normal users, enabling you to specify access permissions per project without needing an enterprise plan.
Deployment Methods
Simple Deployment
This method involves hosting everything on one server, recommended for non-critical projects and smaller side projects.
Advanced Deployment
This method involves setting up a load balancer and multiple servers, enhancing redundancy and ensuring continuous uptime.
Setting Up Your VPS
For this tutorial, we'll use Hetzner, but you can choose any VPS provider such as AWS, Linode, etc. Here's a step-by-step guide:
- Create a New Project:
- Name your project (e.g., All About Payload Coolify).
- Choose a server location (e.g., Nuremberg).
- Select an operating system (e.g., Ubuntu).
- Configure Your Server:
- Opt for a shared virtual CPU, and for higher workloads, choose a more robust plan.
- Skip SSH keys for simplicity but consider setting them up for enhanced security.
- Create and buy the server.
- Install Coolify:
- SSH into your server.
- Change the default password for security.
- Install Coolify by visiting Coolify.io and following the self-hosted installation instructions.
- Access Coolify:
- Once installed, access Coolify via [VPS IP ADDRESS]:8000.
- Create the first user account.
- Unter Settings -> Instance's Domain, set a domain for the coolify server (remember to add DNS entries), click on save and access the Coolify Dashboard from the new domain.
- It should now have SSL enabled. If you're facing an "invalid certificate authority" error, it will go away after waiting for 5-15 minutes.
Configuring DNS and SSL
- DNS Settings:
- Create an A record in your DNS settings pointing to your server IP.
- Create a wildcard A record for your projects.
- Configure Coolify:
- Set the instance domain to your chosen domain (e.g., coolify.allaboutpayload.com).
Deploying Your First Project
- Create a New Project in Coolify:
- Name your project (e.g., My First Blog).
- Choose the production environment.
- Add a new resource from a private GitHub repository.
- Connect to GitHub:
- Install the GitHub app and select your organization.
- Grant access to the repositories you want to deploy.
- Deploy the Project:
- Select the repository and branch.
- Choose the build pack (e.g., Nixpacks) and specify the port (3000 for Payload / NextJS projects).
- Add your environment variables (DATABASE_URI, PAYLOAD_SECRET)
- Deploy the project and check the deployment logs.
- Access Your Project:
- The project should be accessible under the address listed in the "Domains" field in your project resource configurations
Conclusion
Coolify offers a robust, cost-effective, and flexible solution for deploying and managing projects on your server. Its open-source nature ensures data ownership and compliance, while its comprehensive features enhance the developer experience.