MRSK uses the dynamic reverse-proxy Traefik to hold requests, while the new app container is started and the old one is stopped — working seamlessly across multiple hosts, using SSHKit to execute commands. Originally built for Rails apps, MRSK will work with any type of web app that can be containerized with Docker.
Deploy web apps anywhere.
From bare metal to cloud VMs using Docker,
deploy web apps anywhere with zero downtime.
In the past decade+, there’s been an explosion in commercial offerings that make deploying web apps easier. Heroku kicked it off with an incredible offering that stayed ahead of the competition seemingly forever. These days we have excellent alternatives like Fly.io and Render. And hosted Kubernetes is making things easier too on AWS, GCP, Digital Ocean, and elsewhere. But these are all offerings that have you renting computers in the cloud at a premium. If you want to run on your own hardware, or even just have a clear migration path to do so in the future, you need to carefully consider how locked in you get to these commercial platforms. Preferably before the bills swallow your business whole!
MRSK seeks to bring the advance in ergonomics pioneered by these commercial offerings to deploying web apps anywhere. Whether that’s low-cost cloud options without the managed-service markup from the likes of Digital Ocean, Hetzner, OVH, etc, or it’s your own colocated bare metal. To MRSK, it’s all the same. Feed the config file a list of IP addresses with vanilla Ubuntu servers that have seen no prep beyond an added SSH key, and you’ll be running in literally minutes.
This approach gives you enormous portability. You can have your web app deployed on several clouds at ease like this. Or you can buy the baseline with your own hardware, then deploy to a cloud before a big seasonal spike to get more capacity. When you’re not locked into a single provider from a tooling perspective, there are a lot of compelling options available.
Ultimately, MRSK is meant to compress the complexity of going to production using open source tooling that isn’t tied to any commercial offering. Not to zero, mind you. You’re probably still better off with a fully managed service if basic Linux or Docker is still difficult, but as soon as those concepts are familiar, you’ll be ready to go with MRSK.
Why not just run Capistrano, Kubernetes or Docker Swarm?
MRSK basically is Capistrano for Containers, without the need to carefully prepare servers in advance. No need to ensure that the servers have just the right version of Ruby or other dependencies you need. That all lives in the Docker image now. You can boot a brand new Ubuntu (or whatever) server, add it to the list of servers in MRSK, and it’ll be auto-provisioned with Docker, and run right away. Docker’s layer caching also speeds up deployments with less mucking about on the server. And the images built for MRSK can be used for CI or later introspection.
Kubernetes is a beast. Running it yourself on your own hardware is not for the faint of heart. It’s a fine option if you want to run on someone else’s platform, either transparently like Render or explicitly on AWS/GCP, but if you’d like the freedom to move between cloud and your own hardware, or even mix the two, MRSK is much simpler. You can see everything that’s going on, it’s just basic Docker commands being called.
Docker Swarm is much simpler than Kubernetes, but it’s still built on the same declarative model that uses state reconciliation. MRSK is intentionally designed around imperative commands, like Capistrano.
Ultimately, there are a myriad of ways to deploy web apps, but this is the toolkit we’re using at 37signals to bring HEY home from the cloud without losing the advantages of modern containerization tooling.
If you have a Ruby environment available, you can install MRSK globally with:
… otherwise, you can run a dockerized version via an alias (add this to your .bashrc or similar to simplify re-use):
Then, inside your app directory, run
mrsk init (or
mrsk init --bundle within Rails 7+ apps where you want a bin/mrsk binstub). Now edit the new file
config/deploy.yml. It could look as simple as this:
Then edit your
.env file to add your registry password as
MRSK_REGISTRY_PASSWORD (and your
RAILS_MASTER_KEY for production with a Rails app).
Now you’re ready to deploy to the servers:
- Connect to the servers over SSH (using root by default, authenticated by your ssh key)
- Install Docker on any server that might be missing it (using apt-get): root access is needed via ssh for this.
- Log into the registry both locally and remotely
- Build the image using the standard Dockerfile in the root of the application.
- Push the image to the registry.
- Pull the image from the registry onto the servers.
- Ensure Traefik is running and accepting traffic on port 80.
- Ensure your app responds with
- Start a new container with the version of the app that matches the current git version hash.
- Stop the old container running the previous version of the app.
- Prune unused images and stopped containers to ensure servers don’t fill up.
Voila! All the servers are now serving the app on port 80. If you’re just running a single server, you’re ready to go. If you’re running multiple servers, you need to put a load balancer in front of them.