Kitsune Kit ๐ŸฆŠ

Kitsune Logo

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

  1. Configure a DigitalOcean API token:

    export DO_API_TOKEN="your_token"
    
  2. Have the SSH key ID uploaded to DigitalOcean:

    export SSH_KEY_ID="123456"
    
  3. 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:

  1. setup_user create
  2. setup_firewall create
  3. setup_unattended create

๐Ÿณ Full Docker Installation

kit bootstrap_docker execute --server-ip 123.123.123.123

This applies in order:

  1. setup_docker_prereqs create
  2. install_docker_engine create
  3. 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:

  1. Define your kamal.yml pointing to the created droplet
  2. Run kamal setup to initialize the deployment
  3. 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]