yarlson / ftl

🚀 FTL is a powerful deployment tool that simplifies the process of setting up servers and deploying applications.
MIT License
267 stars 3 forks source link
automation cli deployment devops golang iaac noscale server-management ssh zero-downtime

🚀 FTL

FTL (Faster Than Light) is a powerful deployment tool designed specifically for developers who want to deploy their applications to popular cloud providers like Hetzner, DigitalOcean, Linode, or even Raspberry Pi and other servers but aren't sure where to start. FTL simplifies the process of setting up servers and deploying applications, making deployment easy and reliable, even for those who aren't experts in server management or advanced deployment techniques.

🔑 Key Features

💻 Installation

There are several ways to install FTL:

Option 1: Install via Homebrew (macOS and Linux)

If you're using Homebrew, you can install FTL using the following commands:

brew tap yarlson/ftl
brew install ftl

Option 2: Download Binary from GitHub

You can download the pre-compiled binary for your operating system and architecture from the GitHub Releases page. After downloading, follow these steps:

  1. Extract the downloaded archive.
  2. Make the binary executable.
  3. Move it to a directory in your PATH.

For example, on Linux or macOS:

tar -xzf ftl_*.tar.gz
chmod +x ftl
sudo mv ftl /usr/local/bin/

Option 3: Install from Source

To install FTL from source, you need to have Go installed on your system. Then, you can use the following command:

go install github.com/yarlson/ftl@latest

⚙️ Configuration

Create an ftl.yaml file in your project root. Here's an example:

project:
  name: my-project
  domain: my-project.example.com
  email: my-project@example.com

servers:
  - host: my-project.example.com
    port: 22
    user: my-project
    ssh_key: ~/.ssh/id_rsa

services:
  - name: my-app
    image: my-app:latest
    port: 80
    health_check:
      path: /
      interval: 10s
      timeout: 5s
      retries: 3
    routes:
      - path: /
        strip_prefix: false

storages:
  - name: postgres
    image: postgres:16
      - postgres_data:/var/lib/postgresql/data
    env:
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_DB=${POSTGRES_DB}

volumes:
  - postgres_data

This configuration defines your project, servers, services, and storage requirements.

Usage

FTL provides three main commands: setup, build, and deploy.

Setup

The setup command prepares your servers for deployment:

ftl setup

This command:

  1. Creates a new server on your chosen provider (Hetzner, DigitalOcean, Linode) or prepares your custom server (e.g., Raspberry Pi).
  2. Installs Docker and other necessary software.
  3. Sets up firewall rules to secure your server.
  4. Adds a new user and grants them the necessary permissions.
  5. Configures SSH keys for secure access.

Run this command once for each new server before deploying.

Build

The build command builds Docker images for your services:

ftl build

This command:

  1. Parses your project and service definitions.
  2. Constructs Docker images for each service defined in the configuration.
  3. Uploads the built images to your specified Docker registry.

You can use the --no-push flag to build images without pushing them to the registry:

ftl build --no-push

Deploy

The deploy command is where the magic happens. It deploys your application to all configured servers:

ftl deploy

This command:

  1. Parses the ftl.yaml file to understand your infrastructure.
  2. Establishes secure SSH connections to each server.
  3. Creates dedicated Docker networks for your project.
  4. Ensures the latest Docker images are available on the servers.
  5. Performs Zero-Downtime Deployment:
    • Starts new containers with updated images.
    • Conducts health checks to verify readiness.
    • Switches traffic to the new containers once healthy.
    • Gracefully stops and removes old containers.
  6. Sets up Nginx as a reverse proxy to handle SSL/TLS and route traffic.
  7. Removes any unused resources to maintain server hygiene.

🔄 How FTL Deploys Your Application

FTL uses a sophisticated deployment process to ensure your application is always available, even during updates. Here's what happens when you run ftl deploy:

  1. FTL reads your ftl.yaml file to understand your infrastructure.

  2. It securely connects to each server using SSH.

  3. A dedicated Docker network is created for your project, ensuring proper isolation.

  4. The latest versions of your Docker images are pulled to ensure you're deploying the most recent code.

  5. For each service:

    • A new container is started with the updated image and configuration.
    • Health checks are performed to ensure the new container is ready.
    • Once healthy, traffic is instantly switched to the new container.
    • The old container is gracefully stopped and removed.

    This process ensures that your application remains available throughout the update.

  6. An Nginx proxy is automatically configured to route traffic to your services, handle SSL/TLS, and provide automatic HTTPS.

  7. Any unused resources are cleaned up to keep your server tidy.

The entire process is automatic and requires no manual intervention. You can deploy updates as frequently as needed without worrying about downtime or complex deployment procedures.

🌟 Benefits of FTL's Deployment Process

🛠️ Development

To contribute to FTL, clone the repository and install the dependencies:

git clone https://github.com/yarlson/ftl.git
cd ftl
go mod download

Run the tests:

go test ./...

Contributing

We welcome contributions! Whether it's reporting bugs, suggesting features, or submitting pull requests, your help is invaluable. Please ensure that your code follows the project's coding standards and that all tests pass before submitting.

📄 License

MIT License


Feel free to reach out or open an issue on our GitHub repository if you have any questions or need assistance getting started with FTL!