<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Email Octopus on Mitja Martini</title><link>https://mitjamartini.com/en/tags/email-octopus/</link><description>Recent content in Email Octopus on Mitja Martini</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2026 Mitja Martini</copyright><lastBuildDate>Thu, 03 Oct 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://mitjamartini.com/en/tags/email-octopus/index.xml" rel="self" type="application/rss+xml"/><item><title>Deploy a Static Site on Dokku</title><link>https://mitjamartini.com/en/posts/deploy-static-site-on-dokku/</link><pubDate>Thu, 03 Oct 2024 00:00:00 +0000</pubDate><guid>https://mitjamartini.com/en/posts/deploy-static-site-on-dokku/</guid><description>&lt;p&gt;This article describes how to deploy a static site on Dokku, including activating Let&amp;rsquo;s encrypt signed certificates for the domain.&lt;/p&gt;
&lt;!-- more --&gt;
&lt;h2 class="relative group"&gt;Configure DNS
&lt;div id="configure-dns" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#configure-dns" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;Register the domain and point it to the Dokku server. I usually set these records in the domain&amp;rsquo;s DNS zone:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;A @ &lt;span class="m"&gt;7200&lt;/span&gt; &lt;span class="nv"&gt;$DOKKU_SERVER_IPv4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;A * &lt;span class="m"&gt;7200&lt;/span&gt; &lt;span class="nv"&gt;$DOKKU_SERVER_IPv4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CNAME www &lt;span class="m"&gt;7200&lt;/span&gt; &lt;span class="nv"&gt;$APP_DOMAIN&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AAAA @ &lt;span class="m"&gt;7200&lt;/span&gt; &lt;span class="nv"&gt;$DOKKU_SERVER_IPv6&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AAAA * &lt;span class="m"&gt;7200&lt;/span&gt; &lt;span class="nv"&gt;$DOKKU_SERVER_IPv6&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 class="relative group"&gt;Create a git repository
&lt;div id="create-a-git-repository" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#create-a-git-repository" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;Create a folder and turn it into a git repository:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mkdir static-dokku
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; static-dokku
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git init .
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add an &lt;code&gt;index.html&lt;/code&gt; file with the desired content:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;hi&amp;#34;&lt;/span&gt; &amp;gt; index.html
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Create an empty &lt;code&gt;.static&lt;/code&gt; file. This tells Dokku that the repository contains a static site. Dokku then uses the Nginx builder to serve it.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;touch .static
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Commit the changes to git:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git add .
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git commit -m &lt;span class="s2"&gt;&amp;#34;initial commit&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 class="relative group"&gt;Create an app on the Dokku host and git push to deploy the app
&lt;div id="create-an-app-on-the-dokku-host-and-git-push-to-deploy-the-app" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#create-an-app-on-the-dokku-host-and-git-push-to-deploy-the-app" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;Use these commands to create, configure, and deploy the site:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;DOKKU_HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;your dokku server&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;APP_DOMAIN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;your app domain&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;APP_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;your app name&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ssh dokku@&lt;span class="nv"&gt;$DOKKU_HOST&lt;/span&gt; apps:create &lt;span class="nv"&gt;$APP_NAME&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git remote add dokku dokku@&lt;span class="nv"&gt;$DOKKU_HOST&lt;/span&gt;:&lt;span class="nv"&gt;$APP_NAME&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git push dokku main
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ssh dokku@&lt;span class="nv"&gt;$DOKKU_HOST&lt;/span&gt; domains:add &lt;span class="nv"&gt;$APP_NAME&lt;/span&gt; &lt;span class="nv"&gt;$APP_DOMAIN&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ssh dokku@&lt;span class="nv"&gt;$DOKKU_HOST&lt;/span&gt; letsencrypt:enable &lt;span class="nv"&gt;$APP_NAME&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s it. The site is now live at &lt;a
href=""&gt;your app domain&lt;/a&gt;.&lt;/p&gt;
&lt;h2 class="relative group"&gt;Deploy updates
&lt;div id="deploy-updates" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#deploy-updates" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;Updates can be deployed by checking them into git and running this command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git push dokku main
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 class="relative group"&gt;Serving from sub directory
&lt;div id="serving-from-sub-directory" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#serving-from-sub-directory" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;Serving files from a subdirectory (eg. &lt;code&gt;public&lt;/code&gt;) is possible by setting the &lt;code&gt;NGINX_ROOT&lt;/code&gt; environment variable of the app on the Dokku host:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ssh dokku@&lt;span class="nv"&gt;$DOKKU_HOST&lt;/span&gt; config:set &lt;span class="nv"&gt;$APP_NAME&lt;/span&gt; &lt;span class="nv"&gt;NGINX_ROOT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/app/www/public
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 class="relative group"&gt;Building the site during deployment
&lt;div id="building-the-site-during-deployment" class="anchor"&gt;&lt;/div&gt;
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100 select-none"&gt;
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#building-the-site-during-deployment" aria-label="Anchor"&gt;#&lt;/a&gt;
&lt;/span&gt;
&lt;/h2&gt;
&lt;p&gt;If you want to build the site during deployment, you can use multiple &lt;a
href="https://dokku.com/docs/deployment/builders/herokuish-buildpacks/"
target="_blank"
&gt;buildpacks&lt;/a&gt;, for example by adding a &lt;code&gt;.buildpacks&lt;/code&gt; file to the root directory of the repository.&lt;/p&gt;
&lt;p&gt;This way, you can use the first buildpack for building and the second fro serving.&lt;/p&gt;
&lt;p&gt;Another, even more flexible option is to use &lt;a
href="https://dokku.com/docs/deployment/builders/dockerfiles/"
target="_blank"
&gt;Dockerfile deployments&lt;/a&gt; with &lt;a
href="https://docs.docker.com/build/building/multi-stage/"
target="_blank"
&gt;multi-stage builds&lt;/a&gt;.&lt;/p&gt;</description></item></channel></rss>