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
Kamal configuration
You need to configure docker
builder driver in order to pickup the docker environment builder defaults.
builder:
arch: amd64
driver: docker
Top comments (2)
Hi ! Can you explain why it's faster please ?
it is basically because Docker Build Cloud has a shared cache and better cpu and ram to run the builds (and I think some kind of auto-scaling resources)