Follow us
Breaking
Web Hosting

Deploying small SaaS projects on self-hosted platforms

Self-hosting small SaaS projects using Dokku requires a minimum of 1 GB RAM to function as a mini-Heroku. This approach offers cost savings over managed PaaS services through a modular plugin architecture and Git-based deployments.

Share

The Dokku Approach

I find the cost of managed PaaS services to be a significant barrier for small SaaS projects. Many founders exhaust free tiers only to face monthly charges that scale with every new container. I prefer the self-hosted approach using Dokku, which brings Heroku-style deployment to any single server running Docker. This tool functions as a "Docker powered mini-Heroku" by using shell scripting and strategic Go extensions. You require a fresh VM with at least 1 GB of memory to run the platform, though 2 GB or more works better for most workloads. The platform supports Ubuntu 22.04/24.04 and Debian 11+ on both amd64 and arm64 architectures. You can get started using the bootstrap.sh script to set up a fresh instance.

The system includes a modular plugin architecture with over 40 core plugins to manage everything from reverse proxy configuration to SSL termination. Because Dokku remains limited to a single machine, you must ensure your applications do not fight too heavily over the system’s CPU and RAM. This single-machine constraint makes scaling across multiple servers an uphill battle for growing projects. When you push code to your server via Git, the deployment follows a strict sequence. The push arrives via SSH, and the Dokku entrypoint detects the command to dispatch it to the correct plugin. The git plugin then extracts your source code and the builder plugin produces a Docker image. Finally, the scheduler plugin starts the containers according to your Procfile or app.json. This entire process relies on the modularity of the core plugins.

Hakopod and Piku Alternatives

Hakopod offers another route for those who want granular control over individual service resources. You describe your application in a deployment file and then choose specific CPU and memory settings. This allows a worker to receive more memory while the main website remains on a smaller allocation. You can pick a template to start or connect your Git repository directly. Hakopod keeps readiness, deployment progress, and logs close to the changes you just made. While the Hakopod Cloud service allows for easy signup, the platform has not yet opened paid checkout for all users.

If you prefer a system that relies on a remote agent, Piku provides a similar Git push experience. Piku installs an agent called piku.py on the remote machine to handle deployments. You control this remote machine from your local machine using a shim named "piku" that runs via SSH. Piku simplifies the process by making the remote machine a Git remote. This removes the need for any commit hooks on your local machine.

Deployment Tool Primary Requirement Key Feature
Dokku 1 GB RAM minimum Plugin-driven architecture
Hakopod Deployment file Granular resource settings
Piku Remote agent (piku.py) Git push via SSH shim

Managing Resources and Troubleshooting

You might wonder if the complexity of managing your own server outweighs the cost savings. Setting up your own infrastructure requires more hands-on work than using a managed provider. I use Dokku to manage my own projects by setting environment variables for secrets through the config:set command. This practice keeps sensitive credentials out of my public code repositories. For databases, I install official plugins to handle specific needs like Redis or MongoDB. When I use the MongoDB plugin, it sets a MONGO_URL environment variable in the app to point to the instance. This makes local testing much easier if you set a similar variable in your local environment.

If you run into issues with Nginx, you can edit the configuration to increase the server_names_hash_bucket_size for longer domain names. If you encounter a Bad Gateway error after a successful deployment, you may need to ensure your application respects the process.env.PORT environment variable instead of using a specified port to allow the container to communicate correctly with the proxy. For apps that fail to build due to slow internet, you can set environment variables to increase the default timeout for curl commands. This allows you to bypass the 3 second default for fetching buildpacks. You can also use the docker-options command to mount persistent storage, such as adding -v /home/breq/cards:/storage to your deployment options.

How much time will you spend fixing buildpack bugs compared to the time saved on monthly hosting fees?

Share

Technewsdaily

Senior tech writer covering AI, gadgets and cybersecurity. Breaking down the news that matters, every day.