A Developer's Guide to DocPloy: The Self-Hosted Vercel Alternative
If you've read a previous article on a Vercel alternative called Kifi, you'll know that using services like Vercel or Netlify can be problematic. The costs aren't static, and you're always in a guessing game about how much you'll be charged.
The Problem with Platform-as-a-Service (PaaS)
There are numerous horror stories about AWS and Vercel bills on the internet. You think you're saving money, but then suddenly you get a bill that's way higher than you expected. It's not just the cost; it's also the lack of control you have over your own infrastructure.
The Power of Self-Hosting
So, instead of using their serverless architectures, I prefer using my own VPS or self-hosted solutions. That way, I can manage the costs and ensure that everything is under my control, instead of these platforms controlling me. Plus, with self-hosted solutions, you can customize everything to your heart's content, which is really important for developers who want to have full control over their projects.
However, there's always a challenge with this approach: server interactivity. What Vercel provides is the removal of the hassle of setting up your environments, and that's respectable. You can just focus on coding and not worry about the underlying infrastructure. But with self-hosted solutions, you need to take care of all that yourself, which can be time-consuming and frustrating.
With the emergence of open source, you can actually use multiple open-source tools to create your own Vercel-like platform that can be much more highly configured than Vercel itself. You can host whatever you want without the hassle of using the terminal. You get the best of both worlds: the control and customization of self-hosted solutions and the ease of use of Vercel-like platforms.
I had already covered one of these tools in this publication, which was Kifi, but I recently found another one that is also similar but, in my opinion, has a much better UI: DocPloy.
Introducing DocPloy
DocPloy is an open-source alternative to Vercel, Netlify, and Heroku. It is a free, self-hostable Platform-as-a-Service (PaaS) that simplifies the deployment and management of applications and databases using Docker and Traefik.
What is Docker?
If you're not familiar with Docker, here's a quick overview. Docker is a way to package and run applications in a container. A container is like a virtual machine with a stripped-down version of an OS, such as Ubuntu or Debian. It is generally used to ensure that an application runs on every machine without any hassle, getting rid of the age-old saying, "It works on my machine." You can just package your app and its dependencies into a container and then deploy it anywhere without worrying about compatibility issues.
What is Traefik?
The second core component it uses is Traefik. Traefik is like Nginx; it manages your server's interaction with the outside world. It handles your open ports, application domains, load balancing, and more. This is especially handy when you're hosting multiple applications or Docker containers that need to be served on various domains. You can simply configure Traefik to route requests to the correct container, and it will take care of the rest.
Key Features of DocPloy
Now that we've covered the foundation on which this project is built, let's look at the features it provides.
- Docker-Based Deployment: Because it uses Docker, you can deploy any application that can be dockerized. It supports most languages, including Node, PHP, Python, Go, and Ruby.
- Vercel-Like Builds: If you plan to use it like Vercel, that can also be done. It accommodates Nixpacks, which can build and serve your applications just like Vercel.
- Real-time Monitoring: It has real-time monitoring, so you can keep everything in check regarding your server from a single panel.
- Automated Backups: You can configure S3 or any other storage bucket to automate your backups.
- Database Management: You can set up databases, which can significantly reduce your Backend-as-a-Service costs.
- In-Browser File Editing: Files can be changed or edited directly from the interface.
- Team Collaboration: You can create multiple users to share access with your team.
- Terminal Access: It also provides you with terminal access, so you don't need to connect via SSH for any advanced configurations.
Getting Started: Installation and Setup
Now, let's get practical and install it. First, go to the official GitHub page, scroll down, and copy the installation command. Paste it into your terminal and hit enter. The installation process will begin.
wget -qO- https://get.dokploy.com/install.sh | sh
After a few minutes, a link will appear in your terminal. DocPloy is now installed. Open this link in your browser. You'll be asked to register. Once you've registered, you'll see the main dashboard, which looks great and is very similar to Vercel. The UI is certainly an improvement over Kifi.
The dashboard has over four main tabs:
- Projects: Where you manage your applications.
- Monitoring: Here, you'll see your server usage and other details. It's quite impressive.
- Traffic: You can change your Traefik settings from here. You don't need to touch this if you don't know what you're doing, as the application handles all the basic settings for you.
- Docker: Manage your Docker instances here.
- Settings: This is where you can configure your domain.
Domain Setup
To set up your domain, you will need to update the A record in your domain's DNS to point to this server. Then, just enter your domain name in the settings, provide an email so it can send you details about SSL, and in the certificate dropdown, select 'Let's Encrypt.' This will set up your domain with SSL, and it should start working. You can also configure your GitHub account here to deploy your private repositories.
How to Set Up Your First Project
First, click the 'Create Project' button. Enter your project title and description, then click the 'Create' button. Your project has now been created.
After that, you'll be taken to the project page. Under every project, you'll need to create a service, such as a front-end, back-end, database, etc. Let's create a front-end service.
- Click on 'Create Service' and then 'Application.'
- Enter the name of your service and click 'Create.'
Now your service is created, and you'll see it on the screen. Go ahead and click on it.
Here, you'll see multiple options. We'll cover them all, but first, let's get the application deployed. To deploy, you'll need to set up your code provider. You'll see a section with several options:
- GitHub: If you have configured your GitHub API keys, this section will be enabled.
- Docker: If you want to deploy a Dockerfile, you can do it from here.
- Git: This is for public repositories that you may want to deploy.
For this example, we'll use the Git option to deploy a publicly available calculator app repo. Enter the repository URL, specify the branch name you want to deploy, and click 'Save'.
Below this section, you'll see the 'Build Type' option. It has multiple build process options, but since we are deploying a front-end application through Git, we can use Nixpacks, as it will handle everything we need. Now, click the 'Deploy' option at the top. It will take a moment, and you'll see a success message. To check the logs, go to the 'Deployment' tab, where you'll find your deployment.
We still can't access it until we set up a domain or expose a port. To add a domain, go to the 'Domains' tab and add the domain there. Make sure your domain's DNS record is updated to point to this server. For local testing, you can also just expose a port. Once you do that, you'll be able to access the application on your IP or domain. It's now working!
Service Configuration Tabs
Now, let's explore the other tabs available for configuration within a service:
- General: We've already covered this one.
- Environment: You can set up your environment variables here.
- Monitoring: This is different from the main dashboard monitoring; it shows the Docker container's usage and metrics.
- Logs: You can check your application logs here.
- Deployments: View your deployment history here.
- Domains: Add and manage domains here.
- Advanced: This tab has over 6+ options inside it, so let's review them.
Advanced Options
- Run Command: Run commands inside the Docker container.
- Resource Limits: Set limits for your Docker instance, such as memory and CPU.
- Volumes: Set up volumes for persistent data storage.
- Redirects: Configure redirects for your domain.
- Security: Set up a username and password to protect access to your domain.
- Ports: Expose ports for your application.
- Traefik: Change the Traefik configuration to your liking.
Configuring Auto-Deployment
To configure auto-deployment through GitHub, you can go to the main service tab and click the 'Autodeploy' button. Your projects will then be automatically deployed based on GitHub updates.
Setting Up a Database
With your front end done, let's set up a database. Return to the project page and click 'Create New Service,' then select 'Database.' You'll find several options for databases:
- PostgreSQL
- MySQL
- MariaDB
- Redis
Let's choose MySQL. Enter a reference name for the instance, a description, your desired database name, username, password, and a root password. Once done, click 'Create'.
Your database will now be created. Click on the database service, and you'll see its dashboard. It has the same options as the front-end service, but with one new tab: the 'Backup' tab. Here, you can set up automated backups for your database if needed.
To set up backups, you'll first need to configure a storage bucket in your main server settings. To do this, return to the main home screen and click on 'Settings.' You'll see a tab named 'S3 Destinations.' Go there, click 'Add Destination,' and your S3 bucket will be added.
That's it! Now you know how to set up your own Vercel clone and significantly reduce your costs. Not only that, but you can also use this on your local machine to manage your own sites, which is really cool.
Final Thoughts
It's worth mentioning that DocPloy is still a relatively new project and isn't as polished as Vercel or Netlify yet. However, it has a lot of potential, and it's worth keeping an eye on. The community is very active, and they are constantly adding new features and improving existing ones.
Another thing to mention is that DocPloy is not the only open-source alternative to Vercel and Netlify. There are other projects like CapRover and Kifi, which are also self-hosted PaaS solutions. Then there's also Render, another open-source alternative. If you're interested in exploring more options, I definitely recommend checking out these projects as well.
Join the 10xdev Community
Subscribe and get 8+ free PDFs that contain detailed roadmaps with recommended learning periods for each programming language or field, along with links to free resources such as books, YouTube tutorials, and courses with certificates.