What is Swarmlet?
Swarmlet is a self-hosted, open-source Platform as a Service that runs on any single server.
It's mainly intended for use with multiple servers, a server cluster / swarm.
Heavily inspired by Dokku.
Swarmlet is a thin wrapper around Docker Compose and Docker Swarm mode.
Traefik, Consul, Let's Encrypt, Matamo, Swarmpit and Swarmprom are included by default.
Swarmlet uses these to provide automatic SSL, load balancing, analytics and various metrics dashboards.
This project is aimed at developers that want to experiment with application deployment in a flexible multi-server / high-availability environment. The goal is to be able to set up your own swarm and deploy your app(s) in minutes.
- The project GitHub repository can be found at github.com/swarmlet/swarmlet
- The Swarmlet project boards are located at github.com/orgs/swarmlet/projects
- Join the discussion on Slack using this invite link
Imagine you want to host multiple applications, websites, API services, databases and workers on your VPS (Virtual Private Server). Docker makes it possible to wrap each application in it's own container so it can be deployed anywhere. A tool like Dokku does a very good job at managing and building these containers on a VPS and having multiple web applications running on the same server. Dokku can manage virtual hosts, enable SSL using Let's Encrypt, handle environment variable injection, etc. And most importantly, Dokku makes it possible to deploy apps to your server with a simple
Now there comes a time when we have 25+ applications running on our single host. Disk space starts becoming an issue, anxiety intensifies about the server going down, you wake up in the middle of the night mumbling "Ephemeral Application Container Orchestration and Continuous Delivery on Highly-Available Server Clusters" and the creeping thought of running a personal server cluster seems to be growing stronger by the day.
"But what about resource allocation in a distributed system?"
"And which server is running my application container?"
"What happens when a server running my website container crashes?"
"Where will my SSL certificates be stored in a swarm with 3 nodes?"
Questions, doubt.. We could just ramp up the server resources a.k.a. scaling vertically. Adding more processing power, disk space or increasing memory. (downtime..) - However, the itching thought of running a multi server setup just feels like the right thing to do. Ok, so what are the options? Everyone is talking about Kubernetes, a bit much to start with maybe. The k3s project looks interesting but since it's based on Kubernetes the learning curve is still quite steep.
Since we're using
docker-compose.yml files in our projects already, let's try to stay close to Docker. It would be nice to stay very close to Docker for maximal compatibility. It would also be nice to be able to define our entire application stack, including domains, deployment strategies, networking and persistent storage for our ephemeral / stateless applications in a single file. Also we want to be able to
git push our local project repository to our cluster to deploy and have SSL certificates issued automatically for our web facing services. You're probably using Docker Compose already, so let's combine Git, Docker Swarm mode and Docker Compose to deploy applications to a flexible (cheap) personal server cluster.
- Create a new VPS running Ubuntu 18.04 x64 and log in as root
- Install Swarmlet (optionally with some swap if your server has less than 2gb of memory)
- Edit your SSH config to be able to use
ssh swarminstead of
- Use an existing project, or clone one of the examples
- Add a
docker-compose.ymlfile in the root of your project: example docker-compose.yml
- Add a git remote:
git remote add swarm git@swarm:my-project
(notice the syntax
- Deploy your application stack to the swarm using
git push swarm master
- SSL certificates for web facing services are generated automatically using Let's Encrypt
(assuming you've assigned a domain to your server in your DNS configuration)
Requirements: Bash 4.0 or higher (run
Full installation instructions can be found here
Make sure you have a (sub) domain available which is pointed to your server, this is necessary to access the included dashboards such as Swarmpit or Matomo.
To install the latest version of Swarmlet, log in to your server as root and run:
The installation should take a few minutes to complete.
Swarmlet includes various examples of services that you can deploy to your server cluster with a simple
- swarmlet-website - The swarmlet.dev website
- get-swarmlet - The get.swarmlet.dev install script
- Basic example - Static site
- Basic example - Python web server + Redis
- Moderate example - NGINX + React app + Node.js API
- (FIX) Advanced example - NGINX + React app + Node.js API + CMS + staging/production
- (FIX) GitLab CE (self-hosted)
- (FIX) GitLab Runner (self-hosted)
- (TODO) HAProxy (Replacing Traefik with HAProxy)