Skip to content

OmarHrra/kitsune-kit

Repository files navigation

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)
  • 💾 Configures swap space for better performance
  • 📊 Installs DigitalOcean monitoring agent
  • 🌐 Automatically links domains or subdomains (A records) to your server using DigitalOcean DNS
  • 🐳 Installs and configures Docker Engine and private networking
  • 🐘 Deploys PostgreSQL via Docker Compose with healthcheck
  • 🗄️ Deploys Redis via Docker Compose with healthcheck
  • 🔄 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
  4. setup_swap
  5. setup_do_metrics

🐳 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]

About

Provision and bootstrap VPSs (DigitalOcean) with Docker/PostgreSQL, ideal for Kamal deploys

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published