DEV Community

Eduardo Lomeli
Eduardo Lomeli

Posted on

Kamal: Speed up the image builds using managed third-party builders and GitHub Actions

In some cases it is more cost-effective to use a managed third-party builder to speed up your image building process in a Kamal deployment. There are new products that offer powerful optimized builders, such as:

If you are interested in setup and tune your own builder, there are great examples in Kamal docs

In this guide, I'm going to cover how to use and configure Docker Build Cloud inside GitHub Actions and deploy the image using Kamal.

Prerequisites

  • Create an account in docker.com
  • Setup Docker Build Cloud in your account

GitHub Action

Note the configuration in docker/setup-buildx-action@v3

name: Workflow - Deployment

on:
  push:
    branches:
      - main

jobs:
  deploy:
    name: kamal deploy
    timeout-minutes: 5
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true

      - uses: webfactory/ssh-agent@v0.9.0
        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

      - name: Log in to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.KAMAL_REGISTRY_USERNAME }}
          password: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
        with:
          version: "lab:latest"
          driver: cloud
          endpoint: "your-org/builder-name"
          install: true

      - run: gem install kamal

      - run: kamal lock release

      - run: kamal deploy
Enter fullscreen mode Exit fullscreen mode

Kamal configuration

You need to configure docker builder driver in order to pickup the docker environment builder defaults.

builder:
  arch: amd64
  driver: docker
Enter fullscreen mode Exit fullscreen mode

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (2)

Collapse
 
pimp_my_ruby profile image
Pimp My Ruby

Hi ! Can you explain why it's faster please ?

Collapse
 
eduardinni profile image
Eduardo Lomeli • Edited

it is basically because Docker Build Cloud has a shared cache and better cpu and ram to run the builds (and I think some other optimizations and some kind of auto-scaling resources)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more