<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://kamal.wiki/feed.xml" rel="self" type="application/atom+xml" /><link href="https://kamal.wiki/" rel="alternate" type="text/html" /><updated>2026-08-03T15:51:05+05:30</updated><id>https://kamal.wiki/feed.xml</id><title type="html">Kamal Wiki</title><subtitle>Unofficial wiki for Kamal: No-nonsense tips and solutions for kamal. Short, clear, and straight to the point.</subtitle><author><name>Deepak Mahakale</name></author><entry><title type="html">Deploying Rails application with Kamal and SQLite</title><link href="https://kamal.wiki/deploying-rails-application-with-kamal-and-sqlite/" rel="alternate" type="text/html" title="Deploying Rails application with Kamal and SQLite" /><published>2026-01-01T00:00:00+05:30</published><updated>2026-01-01T00:00:00+05:30</updated><id>https://kamal.wiki/deploying-rails-application-with-kamal-and-sqlite</id><content type="html" xml:base="https://kamal.wiki/deploying-rails-application-with-kamal-and-sqlite/"><![CDATA[<p>For complete config visit <a href="https://dailydevtools.com/kamal_config">Kamal Config Generator</a></p>

<p class="notice--info"><strong>Note:</strong> This post will guide you through deploying a Rails application with <strong>SQLite</strong> using Kamal. If you’re looking to deploy a Rails application with <strong>PostgreSQL</strong> or <strong>MySQL</strong>, check out our guide on <a href="/accessory/deploying-rails-application-with-kamal-and-postgres/">Deploying Rails application with Kamal and Postgres</a> and <a href="/accessory/deploying-rails-application-with-kamal-and-mysql/">Deploying Rails application with Kamal and MySQL</a>.</p>

<h3 id="pro-tip">Pro Tip:</h3>

<p>Run the following command to switch the database from <code class="language-plaintext highlighter-rouge">sqlite</code> to <code class="language-plaintext highlighter-rouge">mysql2</code>:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>rails db:system:change <span class="nt">--to</span><span class="o">=</span>mysql
</code></pre></div></div>

<p>Verify the changes and then you can jump to step 4.</p>

<h3 id="1-gemfile">1. <code class="language-plaintext highlighter-rouge">Gemfile</code></h3>

<p>First, update the <code class="language-plaintext highlighter-rouge">Gemfile</code> to use <code class="language-plaintext highlighter-rouge">mysql2</code> as the database for Active Record.</p>

<div class="language-diff highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gd">-# Use sqlite3 as the database for Active Record
-gem "sqlite3", "&gt;= 2.1"
</span><span class="gi">+# Use mysql2 as the database for Active Record
+gem "mysql2", "~&gt; 0.5"
</span></code></pre></div></div>

<h2 id="2-dockerfile">2. <code class="language-plaintext highlighter-rouge">Dockerfile</code></h2>

<p>Next, update the <code class="language-plaintext highlighter-rouge">Dockerfile</code> to install the <code class="language-plaintext highlighter-rouge">default-mysql-client</code> and <code class="language-plaintext highlighter-rouge">default-libmysqlclient-dev</code> packages.</p>

<div class="language-diff highlighter-rouge"><div class="highlight"><pre class="highlight"><code> # Install base packages
 RUN apt-get update -qq &amp;&amp; \
<span class="gd">-    apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 &amp;&amp; \
</span><span class="gi">+    apt-get install --no-install-recommends -y curl default-mysql-client libjemalloc2 libvips &amp;&amp; \
</span>     rm -rf /var/lib/apt/lists /var/cache/apt/archives


 # Install packages needed to build gems
 RUN apt-get update -qq &amp;&amp; \
<span class="gd">-    apt-get install --no-install-recommends -y build-essential git pkg-config &amp;&amp; \
</span><span class="gi">+    apt-get install --no-install-recommends -y build-essential default-libmysqlclient-dev git pkg-config &amp;&amp; \
</span>     rm -rf /var/lib/apt/lists /var/cache/apt/archives
</code></pre></div></div>

<h3 id="3-configdatabaseyml">3. <code class="language-plaintext highlighter-rouge">config/database.yml</code></h3>

<p>Update the <code class="language-plaintext highlighter-rouge">config/database.yml</code> to use <code class="language-plaintext highlighter-rouge">mysql2</code> as the adapter.</p>

<p class="notice--info"><strong>Note:</strong> Make sure to replace the <code class="language-plaintext highlighter-rouge">password</code> in production block to <code class="language-plaintext highlighter-rouge">&lt;%= ENV["MYSQL_ROOT_PASSWORD"] %&gt;</code></p>

<div class="language-yml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">default</span><span class="pi">:</span> <span class="nl">&amp;default</span>
  <span class="na">adapter</span><span class="pi">:</span> <span class="s">mysql2</span>
  <span class="na">encoding</span><span class="pi">:</span> <span class="s">utf8mb4</span>
  <span class="na">pool</span><span class="pi">:</span> <span class="s">&lt;%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %&gt;</span>
  <span class="na">username</span><span class="pi">:</span> <span class="s">root</span>
  <span class="na">password</span><span class="pi">:</span>
  <span class="na">host</span><span class="pi">:</span> <span class="s">&lt;%= ENV.fetch("DB_HOST") { "127.0.0.1" } %&gt;</span>

<span class="na">development</span><span class="pi">:</span>
  <span class="na">&lt;&lt;</span><span class="pi">:</span> <span class="nv">*default</span>
  <span class="na">database</span><span class="pi">:</span> <span class="s">kamal_demo_development</span>

<span class="na">test</span><span class="pi">:</span>
  <span class="na">&lt;&lt;</span><span class="pi">:</span> <span class="nv">*default</span>
  <span class="na">database</span><span class="pi">:</span> <span class="s">kamal_demo_test</span>

<span class="na">production</span><span class="pi">:</span>
  <span class="na">primary</span><span class="pi">:</span> <span class="nl">&amp;primary_production</span>
    <span class="na">&lt;&lt;</span><span class="pi">:</span> <span class="nv">*default</span>
    <span class="na">database</span><span class="pi">:</span> <span class="s">kamal_demo_production</span>
    <span class="na">password</span><span class="pi">:</span> <span class="s">&lt;%= ENV["MYSQL_ROOT_PASSWORD"] %&gt;</span>
  <span class="na">cache</span><span class="pi">:</span>
    <span class="na">&lt;&lt;</span><span class="pi">:</span> <span class="nv">*primary_production</span>
    <span class="na">database</span><span class="pi">:</span> <span class="s">kamal_demo_production_cache</span>
    <span class="na">migrations_paths</span><span class="pi">:</span> <span class="s">db/cache_migrate</span>
  <span class="na">queue</span><span class="pi">:</span>
    <span class="na">&lt;&lt;</span><span class="pi">:</span> <span class="nv">*primary_production</span>
    <span class="na">database</span><span class="pi">:</span> <span class="s">kamal_demo_production_queue</span>
    <span class="na">migrations_paths</span><span class="pi">:</span> <span class="s">db/queue_migrate</span>
  <span class="na">cable</span><span class="pi">:</span>
    <span class="na">&lt;&lt;</span><span class="pi">:</span> <span class="nv">*primary_production</span>
    <span class="na">database</span><span class="pi">:</span> <span class="s">kamal_demo_production_cable</span>
    <span class="na">migrations_paths</span><span class="pi">:</span> <span class="s">db/cable_migrate</span>
</code></pre></div></div>

<h3 id="4-configdeployyml">4. <code class="language-plaintext highlighter-rouge">config/deploy.yml</code></h3>

<p>Update the <code class="language-plaintext highlighter-rouge">config/deploy.yml</code> to add environment variables the db accessory.</p>

<div class="language-yml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="s">&lt;% require "dotenv"; Dotenv.load(".env") %&gt;</span>

<span class="na">service</span><span class="pi">:</span> <span class="s">kamal-demo</span>
<span class="na">image</span><span class="pi">:</span> <span class="s">yourregistryusername/kamal-demo</span>
<span class="na">servers</span><span class="pi">:</span>
  <span class="na">web</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="s">12.34.56.78</span>

<span class="na">proxy</span><span class="pi">:</span>
  <span class="na">ssl</span><span class="pi">:</span> <span class="no">true</span>
  <span class="na">host</span><span class="pi">:</span> <span class="s">example.com</span>

<span class="na">registry</span><span class="pi">:</span>
  <span class="na">username</span><span class="pi">:</span> <span class="s">yourregistryusername</span>
  <span class="na">password</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="s">KAMAL_REGISTRY_PASSWORD</span>

<span class="na">env</span><span class="pi">:</span>
  <span class="na">secret</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="s">RAILS_MASTER_KEY</span>
    <span class="pi">-</span> <span class="s">MYSQL_ROOT_PASSWORD</span>
  <span class="na">clear</span><span class="pi">:</span>
    <span class="na">DB_HOST</span><span class="pi">:</span> <span class="s">kamal-demo-db</span>
    <span class="na">SOLID_QUEUE_IN_PUMA</span><span class="pi">:</span> <span class="no">true</span>

<span class="na">volumes</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="s1">'</span><span class="s">kamal_demo_storage:/rails/storage'</span>

<span class="na">asset_path</span><span class="pi">:</span> <span class="s">/rails/public/assets</span>

<span class="na">builder</span><span class="pi">:</span>
  <span class="na">arch</span><span class="pi">:</span> <span class="s">amd64</span>

<span class="na">accessories</span><span class="pi">:</span>
  <span class="na">db</span><span class="pi">:</span>
    <span class="na">image</span><span class="pi">:</span> <span class="s">mysql:8.0</span>
    <span class="na">host</span><span class="pi">:</span> <span class="s">12.34.56.78</span>
    <span class="na">port</span><span class="pi">:</span> <span class="s2">"</span><span class="s">127.0.0.1:3306:3306"</span>
    <span class="na">env</span><span class="pi">:</span>
      <span class="na">clear</span><span class="pi">:</span>
        <span class="na">MYSQL_ROOT_HOST</span><span class="pi">:</span> <span class="s1">'</span><span class="s">%'</span>
      <span class="na">secret</span><span class="pi">:</span>
        <span class="pi">-</span> <span class="s">MYSQL_ROOT_PASSWORD</span>
    <span class="na">files</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="s">db/production.sql:/docker-entrypoint-initdb.d/setup.sql</span>
    <span class="na">directories</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="s">data:/var/lib/mysql</span>
</code></pre></div></div>

<h3 id="5-env">5. <code class="language-plaintext highlighter-rouge">.env</code></h3>

<p>Add the <code class="language-plaintext highlighter-rouge">MYSQL_ROOT_PASSWORD</code> to the <code class="language-plaintext highlighter-rouge">.env</code> file.</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">KAMAL_REGISTRY_PASSWORD</span><span class="o">=</span>dckr_pat_<span class="k">*******************</span>o
<span class="nv">MYSQL_ROOT_PASSWORD</span><span class="o">=</span>mysql_<span class="k">*******************</span>_password
</code></pre></div></div>

<h3 id="6-kamalsecrets">6. <code class="language-plaintext highlighter-rouge">.kamal/secrets</code></h3>

<p>Add the <code class="language-plaintext highlighter-rouge">MYSQL_ROOT_PASSWORD</code> to the <code class="language-plaintext highlighter-rouge">.kamal/secrets</code> file.</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">KAMAL_REGISTRY_PASSWORD</span><span class="o">=</span><span class="nv">$KAMAL_REGISTRY_PASSWORD</span>
<span class="nv">MYSQL_ROOT_PASSWORD</span><span class="o">=</span><span class="nv">$MYSQL_ROOT_PASSWORD</span>

<span class="nv">RAILS_MASTER_KEY</span><span class="o">=</span><span class="si">$(</span><span class="nb">cat </span>config/master.key<span class="si">)</span>
</code></pre></div></div>

<h3 id="7-deploy">7. Deploy</h3>

<p>Once done you should be able to deploy your Rails application with Kamal.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kamal deploy
</code></pre></div></div>

<p>If you get an error saying the service <code class="language-plaintext highlighter-rouge">app-name-db</code> already exists you can remove the service using the following command and then re-deploy.:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kamal accessory remove db
kamal deploy
</code></pre></div></div>

<p>We have a separate guide on <a href="/accessory/how-to-remove-an-accessory-in-kamal/">how to remove an accessory in Kamal</a>.</p>]]></content><author><name>Deepak Mahakale</name></author><category term="SQLite" /><summary type="html"><![CDATA[Ready to deploy your Rails app using Kamal and SQLite? This guide covers the steps to deploy your Rails application with SQLite using Kamal. Get your app up and running - read more!]]></summary></entry><entry><title type="html">Kamal Deployment: From Zero to Hero</title><link href="https://kamal.wiki/setup/kamal-deployment-zero-to-hero/" rel="alternate" type="text/html" title="Kamal Deployment: From Zero to Hero" /><published>2026-01-01T00:00:00+05:30</published><updated>2026-01-01T00:00:00+05:30</updated><id>https://kamal.wiki/setup/kamal-deployment-zero-to-hero</id><content type="html" xml:base="https://kamal.wiki/setup/kamal-deployment-zero-to-hero/"><![CDATA[<ul>
  <li>Create a comprehensive guide covering the entire deployment process, including setup, configuration, deployment, and rollback.</li>
  <li>Target keywords like “rails kamal deploy” and “kamal deployment guide.”</li>
  <li>Include practical examples and FAQs.</li>
</ul>]]></content><author><name>Deepak Mahakale</name></author><category term="Setup" /><category term="Deployment" /><summary type="html"><![CDATA[Learn how to deploy your application with Kamal from scratch. This guide covers the basics, configuration, and best practices.]]></summary></entry><entry><title type="html">Managing Secrets with Kamal - A Complete Guide</title><link href="https://kamal.wiki/managing-secrets-with-kamal/" rel="alternate" type="text/html" title="Managing Secrets with Kamal - A Complete Guide" /><published>2026-01-01T00:00:00+05:30</published><updated>2026-01-01T00:00:00+05:30</updated><id>https://kamal.wiki/managing-secrets-with-kamal</id><content type="html" xml:base="https://kamal.wiki/managing-secrets-with-kamal/"><![CDATA[<ul>
  <li>Discuss best practices for handling environment variables, secrets, and configuration files in Kamal.</li>
  <li>Explain commands like kamal env push and how to troubleshoot issues.</li>
  <li>Include examples of secure env var management.</li>
</ul>]]></content><author><name>Deepak Mahakale</name></author><category term="Secrets" /><summary type="html"><![CDATA[Learn how to manage secrets and environment variables with Kamal. This guide covers the basics, configuration, and best practices.]]></summary></entry><entry><title type="html">Understanding Kamal Accessories: A Complete Guide</title><link href="https://kamal.wiki/accessory/what-is-kamal-accessory/" rel="alternate" type="text/html" title="Understanding Kamal Accessories: A Complete Guide" /><published>2026-01-01T00:00:00+05:30</published><updated>2026-01-01T00:00:00+05:30</updated><id>https://kamal.wiki/accessory/what-is-kamal-accessory</id><content type="html" xml:base="https://kamal.wiki/accessory/what-is-kamal-accessory/"><![CDATA[<ul>
  <li>Explain what accessories are in Kamal (e.g., databases, caching, background jobs).</li>
  <li>Provide configuration examples for common use cases.</li>
  <li>Include step-by-step guides and troubleshooting tips.</li>
</ul>]]></content><author><name>Deepak Mahakale</name></author><category term="Accessory" /><category term="Accessory" /><summary type="html"><![CDATA[Learn how to use Kamal accessories to simplify your deployment process. This guide covers the basics, configuration, and best practices.]]></summary></entry><entry><title type="html">How to use local docker registry with kamal?</title><link href="https://kamal.wiki/registry/how-to-use-local-docker-registry-with-kamal/" rel="alternate" type="text/html" title="How to use local docker registry with kamal?" /><published>2025-10-09T00:00:00+05:30</published><updated>2025-10-09T00:00:00+05:30</updated><id>https://kamal.wiki/registry/how-to-use-local-docker-registry-with-kamal</id><content type="html" xml:base="https://kamal.wiki/registry/how-to-use-local-docker-registry-with-kamal/"><![CDATA[<p>This article covers the new local Docker registry feature introduced in Kamal that allows you to deploy applications without setting up a remote Docker registry.</p>

<h3 id="what-is-the-local-docker-registry-feature">What is the Local Docker Registry Feature?</h3>

<p>Kamal now supports using a local Docker registry for pushing and pulling application images. When you configure your registry server to start with <code class="language-plaintext highlighter-rouge">"localhost"</code>, Kamal will:</p>

<ol>
  <li>Start a local Docker registry on the specified port</li>
  <li>Push your app image to this local registry</li>
  <li>Use SSH port forwarding to make the registry accessible from your app servers</li>
</ol>

<p>This can reduce deployment time by 10-15 seconds by eliminating the need to push/pull from remote registries.</p>

<h3 id="configuration">Configuration</h3>

<p>Update your <code class="language-plaintext highlighter-rouge">config/deploy.yml</code> to use a local registry:</p>

<div class="language-yml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="s">&lt;% require "dotenv"; Dotenv.load(".env") %&gt;</span>

<span class="na">service</span><span class="pi">:</span> <span class="s">my-app</span>
<span class="na">image</span><span class="pi">:</span> <span class="s">my-app</span>
<span class="na">servers</span><span class="pi">:</span>
  <span class="na">web</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="s">192.168.1.100</span>

<span class="na">registry</span><span class="pi">:</span>
  <span class="na">server</span><span class="pi">:</span> <span class="s2">"</span><span class="s">localhost:5555"</span>

<span class="na">env</span><span class="pi">:</span>
  <span class="na">secret</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="s">RAILS_MASTER_KEY</span>
</code></pre></div></div>

<p class="notice--info"><strong>Note:</strong> You don’t need to specify username/password when using a local registry.</p>

<h3 id="how-it-works">How It Works</h3>

<p>When Kamal detects a localhost registry configuration:</p>

<ol>
  <li><strong>Local Registry Startup</strong>: Kamal starts a Docker registry container on your deployment machine</li>
  <li><strong>Image Push</strong>: Your application image is pushed to this local registry</li>
  <li><strong>SSH Port Forwarding</strong>: Kamal creates an SSH tunnel from your app servers to the local registry</li>
  <li><strong>Image Pull</strong>: App servers pull the image through the SSH tunnel</li>
</ol>

<h3 id="benefits">Benefits</h3>

<ul>
  <li><strong>Faster Deployments</strong>: Eliminates remote registry push/pull time</li>
  <li><strong>Simplified Setup</strong>: No need to configure Docker Hub, GHCR, or other remote registries</li>
  <li><strong>Development Friendly</strong>: Perfect for staging environments or local development</li>
  <li><strong>Reduced Dependencies</strong>: Less reliance on external services</li>
</ul>

<h3 id="when-to-use-local-registry">When to Use Local Registry</h3>

<p><strong>Good for:</strong></p>
<ul>
  <li>Development and staging environments</li>
  <li>Quick prototyping and testing</li>
  <li>Situations where you want minimal external dependencies</li>
  <li>Teams that prefer to keep images local during development</li>
</ul>

<p><strong>Consider Remote Registry for:</strong></p>
<ul>
  <li>Production deployments</li>
  <li>Multi-developer teams needing shared image access</li>
  <li>CI/CD pipelines</li>
  <li>Long-term image storage and versioning</li>
</ul>

<h3 id="troubleshooting">Troubleshooting</h3>

<p>If you encounter issues:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Check if the local registry is running</span>
docker ps | <span class="nb">grep </span>registry

<span class="c"># Verify SSH port forwarding</span>
kamal app details
</code></pre></div></div>

<p>This feature makes Kamal even more developer-friendly by removing the friction of setting up remote registries for development workflows.</p>

<div style="border: 1px solid #ddd; border-radius: 6px; background: #fdfdfd; padding: 0.75rem 1rem; margin: 1.5rem 0; position: relative;">
  <div style="display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap;">
    <div style="flex: 1; padding-right: 1rem;">
      <strong style="font-size: 1rem;">
        📘 Learn Kamal with a Practical Guide
      </strong>
      <p style="margin: 0.25rem 0 0; font-size: 0.9rem; line-height: 1.4;">
        Check out
        <a href="https://gumroad.com/a/172070675/myyhj" target="_blank" style="font-weight: 600; text-decoration: none;">
          Kamal Handbook
        </a>
        by Josef Strzibny - a concise eBook covering real-world deployment tips.
      </p>
    </div>
    <div style="white-space: nowrap; margin-top: 0.25rem;">
      <a href="https://gumroad.com/a/172070675/myyhj" target="_blank" style="background-color: #2f7d95; color: white; padding: 0.4rem 0.9rem; border-radius: 4px; text-decoration: none; font-size: 0.85rem; font-weight: 600;">
        Get the eBook →
      </a>
    </div>
  </div>
  <p style="margin: 0.5rem 0 0; font-size: 0.75rem; color: #666;">
    <small>
      This is an affiliate link.
      I may earn a small commission if you buy, at no extra cost to you.
    </small>
  </p>
</div>]]></content><author><name>Deepak Mahakale</name></author><category term="Registry" /><category term="Docker" /><category term="Registry" /><summary type="html"><![CDATA[Want to deploy your Rails app without setting up a remote Docker registry? Learn how to use Kamal's new local Docker registry feature to streamline your deployment process. Save 10-15 seconds per deployment and simplify your setup!]]></summary></entry><entry><title type="html">How to rollback a deployment with Kamal?</title><link href="https://kamal.wiki/how-to-rollback-a-deployment-with-kamal/" rel="alternate" type="text/html" title="How to rollback a deployment with Kamal?" /><published>2025-02-17T00:00:00+05:30</published><updated>2025-02-17T00:00:00+05:30</updated><id>https://kamal.wiki/how-to-rollback-a-deployment-with-kamal</id><content type="html" xml:base="https://kamal.wiki/how-to-rollback-a-deployment-with-kamal/"><![CDATA[<p>Kamal provides an easy way to rollback a deployment using the <code class="language-plaintext highlighter-rouge">kamal rollback</code> command.</p>

<h3 id="command">Command:</h3>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kamal rollback <span class="o">[</span>VERSION]
</code></pre></div></div>

<p>To rollback you need to specify the version you want to rollback to.</p>

<p>To find the version you can use the following command to list the available containers.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kamal app containers <span class="nt">-q</span>
</code></pre></div></div>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>App Host: 37.27.188.95
CONTAINER ID   IMAGE                                                            COMMAND                  CREATED          STATUS                        PORTS     NAMES
df826bc62d45   deepakmahakale/meetup:9533761e01c8810dc5a678675c0907a91cf7935d   <span class="s2">"/rails/bin/docker-e…"</span>   26 seconds ago   Up 25 seconds                 80/tcp    meetup-web-9533761e01c8810dc5a678675c0907a91cf7935d
911a7e9baa16   deepakmahakale/meetup:f34e9efe57fb781c89b3ce3f85427bb230b34d9e   <span class="s2">"/rails/bin/docker-e…"</span>   10 days ago      Exited <span class="o">(</span>255<span class="o">)</span> 18 seconds ago             meetup-web-f34e9efe57fb781c89b3ce3f85427bb230b34d9e
</code></pre></div></div>

<p class="notice--info"><strong>Note:</strong><br />
<code class="language-plaintext highlighter-rouge">9533761e01c8810dc5a678675c0907a91cf7935d</code> is the version that we just deployed (bad version)<br />
<code class="language-plaintext highlighter-rouge">f34e9efe57fb781c89b3ce3f85427bb230b34d9e</code> is the previous stable version that we want to rollback to.</p>

<p>Once we have identified the version we want to rollback to we can run the following command:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kamal rollback f34e9efe57fb781c89b3ce3f85427bb230b34d9e
</code></pre></div></div>

<p>This will rollback the deployment to the specified version.</p>]]></content><author><name>Deepak Mahakale</name></author><category term="Rails" /><category term="Rollback" /><summary type="html"><![CDATA[Learn how to rollback a deployment in Kamal using the kamal rollback command. This guide covers finding the right version, executing the rollback, and verifying successful rollback. Ensure your Rails app stays stable - read more!]]></summary></entry><entry><title type="html">How to access Rails app logs on Kamal?</title><link href="https://kamal.wiki/how-to-view-rails-app-logs-on-kamal/" rel="alternate" type="text/html" title="How to access Rails app logs on Kamal?" /><published>2025-02-13T00:00:00+05:30</published><updated>2025-02-13T00:00:00+05:30</updated><id>https://kamal.wiki/how-to-view-rails-app-logs-on-kamal</id><content type="html" xml:base="https://kamal.wiki/how-to-view-rails-app-logs-on-kamal/"><![CDATA[<p>With the introduction of <a href="https://kamal-deploy.org/docs/configuration/aliases/">aliases</a> in Kamal 2.0 it’s easier to check the Rails app logs.</p>

<p>Kamal setup provides a default aliases for <code class="language-plaintext highlighter-rouge">logs</code>. But, if it’s not available, you can add your own <code class="language-plaintext highlighter-rouge">aliases</code> to the <code class="language-plaintext highlighter-rouge">deploy.yml</code> file.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">aliases</span><span class="pi">:</span>
  <span class="na">logs</span><span class="pi">:</span> <span class="s">app logs -f</span>
</code></pre></div></div>

<p>and then run the following command:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>kamal logs

INFO Following logs on 37.xx.xxx.xx.
</code></pre></div></div>

<div style="border: 1px solid #ddd; border-radius: 6px; background: #fdfdfd; padding: 0.75rem 1rem; margin: 1.5rem 0; position: relative;">
  <div style="display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap;">
    <div style="flex: 1; padding-right: 1rem;">
      <strong style="font-size: 1rem;">
        📘 Learn Kamal with a Practical Guide
      </strong>
      <p style="margin: 0.25rem 0 0; font-size: 0.9rem; line-height: 1.4;">
        Check out
        <a href="https://gumroad.com/a/172070675/myyhj" target="_blank" style="font-weight: 600; text-decoration: none;">
          Kamal Handbook
        </a>
        by Josef Strzibny - a concise eBook covering real-world deployment tips.
      </p>
    </div>
    <div style="white-space: nowrap; margin-top: 0.25rem;">
      <a href="https://gumroad.com/a/172070675/myyhj" target="_blank" style="background-color: #2f7d95; color: white; padding: 0.4rem 0.9rem; border-radius: 4px; text-decoration: none; font-size: 0.85rem; font-weight: 600;">
        Get the eBook →
      </a>
    </div>
  </div>
  <p style="margin: 0.5rem 0 0; font-size: 0.75rem; color: #666;">
    <small>
      This is an affiliate link.
      I may earn a small commission if you buy, at no extra cost to you.
    </small>
  </p>
</div>]]></content><author><name>Deepak Mahakale</name></author><category term="Rails" /><category term="Logs" /><summary type="html"><![CDATA[Discover how to access your Rails app logs using Kamal's aliases feature. This post walks you through setting up and using the logs alias for real-time monitoring. Start debugging faster - check it out!]]></summary></entry><entry><title type="html">Simplify Commands: How to add and use alias in Kamal?</title><link href="https://kamal.wiki/how-to-add-alias-with-kamal/" rel="alternate" type="text/html" title="Simplify Commands: How to add and use alias in Kamal?" /><published>2025-02-11T00:00:00+05:30</published><updated>2025-02-11T00:00:00+05:30</updated><id>https://kamal.wiki/how-to-add-alias-with-kamal</id><content type="html" xml:base="https://kamal.wiki/how-to-add-alias-with-kamal/"><![CDATA[<p>With the introduction of
<a href="https://kamal-deploy.org/docs/configuration/aliases/">aliases</a>
in Kamal 2.0 it’s easier to add aliases to the <code class="language-plaintext highlighter-rouge">deploy.yml</code> file and run them using the <code class="language-plaintext highlighter-rouge">kamal</code> command.</p>

<p>Kamal setup provides a few default aliases like <code class="language-plaintext highlighter-rouge">console</code>, <code class="language-plaintext highlighter-rouge">shell</code>, <code class="language-plaintext highlighter-rouge">logs</code>, and <code class="language-plaintext highlighter-rouge">dbc</code>.
You can add your own aliases to the <code class="language-plaintext highlighter-rouge">deploy.yml</code> file.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># config/deploy.yml</span>
<span class="na">aliases</span><span class="pi">:</span>
  <span class="na">console</span><span class="pi">:</span> <span class="s">app exec --interactive --reuse "bin/rails console"</span>
  <span class="na">shell</span><span class="pi">:</span> <span class="s">app exec --interactive --reuse "bash"</span>
  <span class="na">logs</span><span class="pi">:</span> <span class="s">app logs -f</span>
  <span class="na">dbc</span><span class="pi">:</span> <span class="s">app exec --interactive --reuse "bin/rails dbconsole"</span>
</code></pre></div></div>

<p>Now you can run the alias using the <code class="language-plaintext highlighter-rouge">kamal</code> command.</p>

<p><strong>Open rails console</strong></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>kamal console

Loading production environment <span class="o">(</span>Rails 8.0.1<span class="o">)</span>
meetup<span class="o">(</span>prod<span class="o">)&gt;</span> Post.count
<span class="c"># =&gt; 1</span>
</code></pre></div></div>

<p><strong>Open bash</strong></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>kamal shell

rails@37:/rails<span class="nv">$ </span><span class="nb">ls
</span>Gemfile  Gemfile.lock  README.md  Rakefile  app  bin  config  config.ru  db  lib  log  public  script  storage  <span class="nb">test  </span>tmp  vendor
</code></pre></div></div>

<p><strong>See rails app logs</strong></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>kamal logs

INFO Following logs on 37.xx.xxx.xx.
</code></pre></div></div>

<p><strong>Open rails dbconsole (sqlite, psql or whatever database you are using)</strong></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>kamal dbc

SQLite version 3.40.1 2022-12-28 14:03:47
Enter <span class="s2">".help"</span> <span class="k">for </span>usage hints.

sqlite&gt; <span class="k">select </span>count<span class="o">(</span><span class="k">*</span><span class="o">)</span> from posts<span class="p">;</span>
1
</code></pre></div></div>]]></content><author><name>Deepak Mahakale</name></author><category term="Alias" /><summary type="html"><![CDATA[Unlock the magic of aliases in Kamal to streamline your workflow. Learn how to set up custom aliases for tasks like running the Rails console or accessing logs. Boost your productivity - explore the guide!]]></summary></entry><entry><title type="html">How to run a rake task on Kamal?</title><link href="https://kamal.wiki/how-to-run-a-rake-task-on-kamal/" rel="alternate" type="text/html" title="How to run a rake task on Kamal?" /><published>2024-10-30T00:00:00+05:30</published><updated>2024-10-30T00:00:00+05:30</updated><id>https://kamal.wiki/how-to-run-a-rake-task-on-kamal</id><content type="html" xml:base="https://kamal.wiki/how-to-run-a-rake-task-on-kamal/"><![CDATA[<p>To run a rake task on Kamal, you can use the following command:</p>

<p><strong>Syntax:</strong></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kamal app <span class="nb">exec</span> <span class="nt">-i</span> <span class="s1">'bundle exec rake &lt;task_name&gt;'</span>
</code></pre></div></div>

<p><strong>Example:</strong></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kamal app <span class="nb">exec</span> <span class="nt">-i</span> <span class="s1">'bundle exec rake users:import'</span>
</code></pre></div></div>]]></content><author><name>Deepak Mahakale</name></author><category term="Rails" /><category term="Rake Task" /><summary type="html"><![CDATA[Need to execute a Rake task on your Kamal-deployed Rails app? This tutorial provides the exact command and syntax you need. Get your tasks running smoothly - read more!]]></summary></entry><entry><title type="html">Accessing the rails console on Kamal?</title><link href="https://kamal.wiki/how-to-run-rails-console-on-kamal/" rel="alternate" type="text/html" title="Accessing the rails console on Kamal?" /><published>2024-10-28T00:00:00+05:30</published><updated>2025-02-27T16:00:00+05:30</updated><id>https://kamal.wiki/how-to-run-rails-console-on-kamal</id><content type="html" xml:base="https://kamal.wiki/how-to-run-rails-console-on-kamal/"><![CDATA[<p>The Rails console is a powerful tool for debugging, testing, and managing your Rails application. You can use it to interact with your application’s models, run queries, etc.</p>

<p>A common use case would be to check some data related to users, products or specific scenarios like users with specific attributes, etc.</p>

<h3 id="with-kamal-20">With Kamal 2.0</h3>

<p>With the introduction of <a href="https://kamal-deploy.org/docs/configuration/aliases/">aliases</a> in Kamal 2.0 it’s easier to run the Rails console.</p>

<p>You can define <code class="language-plaintext highlighter-rouge">aliases</code> in the <code class="language-plaintext highlighter-rouge">deploy.yml</code> file:</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">aliases</span><span class="pi">:</span>
  <span class="na">console</span><span class="pi">:</span> <span class="s">app exec --reuse -i "bin/rails console"</span>
</code></pre></div></div>

<p>and then run the Rails console using the following command:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kamal console
</code></pre></div></div>

<h3 id="with-kamal-1x">With Kamal 1.x</h3>

<p>With Kamal 1.x, you can run the Rails console using the following command:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kamal app <span class="nb">exec</span> <span class="nt">-i</span> <span class="nt">--reuse</span> <span class="s2">"bin/rails console"</span>
</code></pre></div></div>

<div style="border: 1px solid #ddd; border-radius: 6px; background: #fdfdfd; padding: 0.75rem 1rem; margin: 1.5rem 0; position: relative;">
  <div style="display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap;">
    <div style="flex: 1; padding-right: 1rem;">
      <strong style="font-size: 1rem;">
        📘 Learn Kamal with a Practical Guide
      </strong>
      <p style="margin: 0.25rem 0 0; font-size: 0.9rem; line-height: 1.4;">
        Check out
        <a href="https://gumroad.com/a/172070675/myyhj" target="_blank" style="font-weight: 600; text-decoration: none;">
          Kamal Handbook
        </a>
        by Josef Strzibny - a concise eBook covering real-world deployment tips.
      </p>
    </div>
    <div style="white-space: nowrap; margin-top: 0.25rem;">
      <a href="https://gumroad.com/a/172070675/myyhj" target="_blank" style="background-color: #2f7d95; color: white; padding: 0.4rem 0.9rem; border-radius: 4px; text-decoration: none; font-size: 0.85rem; font-weight: 600;">
        Get the eBook →
      </a>
    </div>
  </div>
  <p style="margin: 0.5rem 0 0; font-size: 0.75rem; color: #666;">
    <small>
      This is an affiliate link.
      I may earn a small commission if you buy, at no extra cost to you.
    </small>
  </p>
</div>]]></content><author><name>Deepak Mahakale</name></author><category term="Rails" /><category term="Console" /><summary type="html"><![CDATA[Learn how to open the Rails console in Kamal for both version 1.x and 2.0. This guide covers commands and aliases to make debugging and management easy. Start exploring your app.]]></summary></entry></feed>