Kitsune Kit ๐ฆ
Kitsune Kit is a Ruby gem that automates the provisioning, configuration, and setup of remote Linux servers (VPS) to host applications deployed with Kamal or Docker Compose. It is designed to work on DigitalOcean infrastructure (for now), featuring reversible commands and a clear workflow.
> ๐ ๏ธ Ideal for Ruby developers who want to launch production without relying on other services.
๐ Main Features
- ๐งช Automatically provisions a Droplet on DigitalOcean
- ๐ค Configures a secure, passwordless
deploy
user - ๐ Applies firewall rules (UFW) for SSH, HTTP, HTTPS
- โป๏ธ Enables automatic security updates (unattended-upgrades)
- ๐ณ Installs and configures Docker Engine and private networking
- ๐ Deploys PostgreSQL via Docker Compose with healthcheck and
.env
- ๐ All steps can be rolled back (
--rollback
) - โก Fast, reproducible and without relying on YAML or complex external tools
๐ฆ Installation
Add this line to your Gemfile
:
gem "kitsune-kit"
Or install it manually:
gem install kitsune-kit
โ๏ธ Prerequisites
Configure a DigitalOcean API token:
export DO_API_TOKEN="your_token"
Have the SSH key ID uploaded to DigitalOcean:
export SSH_KEY_ID="123456"
Have the private key installed on your local machine:
export SSH_KEY_PATH="~/.ssh/id_rsa"
๐ Getting Started
Initialize the Kitsune project structure:
kit init
This will create the .kitsune/
directory, multiple .env
files, and the necessary Docker templates. Run it in your project’s root directory.
๐ง Main Commands
๐งฑ Server Provisioning
kit bootstrap execute
This creates a Droplet and executes:
setup_user create
setup_firewall create
setup_unattended create
๐ณ Full Docker Installation
kit bootstrap_docker execute --server-ip 123.123.123.123
This applies in order:
setup_docker_prereqs create
install_docker_engine create
postinstall_docker create
๐ Install PostgreSQL with Docker Compose
kit setup_postgres_docker create --server-ip 123.123.123.123
It will provide you with a DATABASE_URL
ready for Rails or any other app.
โป๏ธ Rollback for Each Step
Each command accepts the --rollback
flag. For example:
kit bootstrap execute --rollback --keep-server
This:
- Reverts the server configuration (
unattended
,firewall
,user
) - Optionally deletes the Droplet (if you don’t use
--keep-server
)
The same applies to any other subcommand, such as:
kit bootstrap_docker execute --rollback --server-ip ... kit setup_postgres_docker rollback --server-ip ...
๐ Support for Multiple Environments
Use switch_env
to change between environments:
kit switch_env to production
This updates .kitsune/kit.env
and creates (if it doesn’t exist) .kitsune/infra.production.env
.
๐ Integration with Kamal
Once the server is configured:
- Define your
kamal.yml
pointing to the created droplet - Run
kamal setup
to initialize the deployment - Use
kamal deploy
as usual
๐ก Tips
- Use
kit init
in every new project. - Customize
.kitsune/docker/postgres.yml
if you need additional services.
๐ Quick Example
# Initialize project structure kit init # Provision Droplet and configure everything kit bootstrap execute # Install Docker kit bootstrap_docker execute --server-ip 123.123.123.123 # Set up the database kit setup_postgres_docker create --server-ip 123.123.123.123
๐งช In Development
- [ ] Support for other providers (Hetzner)
- [ ] Create databases on another server
๐ Security
Never upload your .env
files to public repositories. Kitsune does not encrypt them: it assumes you control your machine and your repo. Add .kitsune/
to your project’s .gitignore
.
๐ License
MIT License ยฉ [Omar Herrera / OmarHrra]