<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>v0.113 on Andrew Beaton</title>
    <link>https://andrewbeaton.net/tags/v0.113/</link>
    <description>Recent content in v0.113 on Andrew Beaton</description>
    <image>
      <title>Andrew Beaton</title>
      <url>https://andrewbeaton.net/me.jpeg</url>
      <link>https://andrewbeaton.net/me.jpeg</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sat, 10 Jun 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://andrewbeaton.net/tags/v0.113/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Using Hugo v0.113.0 and Drone</title>
      <link>https://andrewbeaton.net/posts/2023/06/drone-io-latest-hugo/</link>
      <pubDate>Sat, 10 Jun 2023 00:00:00 +0000</pubDate>
      
      <guid>https://andrewbeaton.net/posts/2023/06/drone-io-latest-hugo/</guid>
      <description>Building a Docker image for Drone to run the latest version of Hugo.</description>
      <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>These days, optimising workflows and automating processes is key to efficient software development and infrastructure management.</p>
<p>In my previous posts I covered how to configure Drone to build Hugo and deploy to various destinations, such as an FTP / Web server or Cloudflare Pages.</p>
<p>As I&rsquo;ve been using and learning more about Hugo, I noticed that the Docker Image I was using to build my Hugo files in Drone was quite out of date and wouldn&rsquo;t let me use some of the latest features available. After a brief search on the web, I couldn&rsquo;t find a more recent version.</p>
<p>So, with a couple of spare hours on a Saturday morning, I did some research and looked in to building my own Docker Image and have it published to GitHub&rsquo;s Container Registry.</p>
<p>And we now have the <a href="https://ghcr.io/andrewbeaton/hugo-drone">andrewbeaton/hugo-drone</a> Docker image.</p>
<h2 id="what-is-it">What is it?</h2>
<p><code>andrewbeaton/hugo-drone</code> is a Docker image specifically designed to facilitate Hugo site builds and deployments.</p>
<p>Built upon the popular Drone CI/CD platform, this image contains a preconfigured environment with Hugo and other necessary dependencies, aiming to streamline the setup process and ensuring consistency across different development environments.</p>
<p>The image is based on <a href="https://rockylinux.org/">RockyLinux</a> and installs the current version of <a href="https://gohugo.io/">Hugo</a>, which is currently <a href="https://github.com/gohugoio/hugo/releases/tag/v0.113.0">v0.113.0</a>.</p>
<p>My aim is to build and release a new versioned image, for each major release that comes along.</p>
<h2 id="step-1-installing-docker">Step 1: Installing Docker</h2>
<p>Before we can use <code>andrewbeaton/hugo-drone</code>, we need to have Docker installed on our system. Docker allows us to run containers, which are lightweight, isolated environments that encapsulate our applications and their dependencies. Follow these instructions to install Docker on your operating system.</p>
<h2 id="step-2-pulling-the-image">Step 2: Pulling the Image</h2>
<p>Once Docker is installed, we can pull the <code>andrewbeaton/hugo-drone</code> image from the <a href="https://github.com/andrewbeaton/hugo-drone/pkgs/container/hugo-drone">GitHub Images Repository</a>.</p>
<p>Open your terminal or command prompt and enter the following command:</p>
<pre tabindex="0"><code>docker pull ghcr.io/andrewbeaton/hugo-drone:latest
</code></pre><p>This command will fetch the latest version of the image and make it available on your system for usage.</p>
<h2 id="step-3-creating-a-hugo-project">Step 3: Creating a Hugo Project</h2>
<p>To work with <code>andrewbeaton/hugo-drone</code>, you need to have an existing Hugo project or create a new one.</p>
<p>If you haven&rsquo;t set up a Hugo project yet, follow these steps:</p>
<ol>
<li>
<p><strong>Install Hugo:</strong><br>
Visit the official Hugo website and download the appropriate binary for your operating system. Follow the installation instructions provided.</p>
</li>
<li>
<p><strong>Create a New Hugo Site:</strong><br>
In your terminal or command prompt, navigate to your desired project directory and run the following command:</p>
<pre tabindex="0"><code>hugo new site my-hugo-site
</code></pre><p>This command will create a new Hugo site with the name &ldquo;my-hugo-site&rdquo; in the current directory.</p>
</li>
<li>
<p><strong>Add a Theme:</strong><br>
Navigate to your Hugo site&rsquo;s directory and add a theme of your choice. You can explore various themes on the Hugo Themes website or use a specific theme by following its documentation.</p>
</li>
</ol>
<h2 id="step-4-setting-up-a-drone-configuration-file">Step 4: Setting Up a Drone Configuration File</h2>
<p>Drone relies on a configuration file named <code>.drone.yml</code> to define the build pipeline.</p>
<p>Create a new file named <code>.drone.yml</code> in the root of your Hugo project and add the following content as a starting point:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">kind</span>: <span style="color:#ae81ff">pipeline</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">type</span>: <span style="color:#ae81ff">docker</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">name</span>: <span style="color:#ae81ff">default</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">steps</span>:
</span></span><span style="display:flex;"><span>  - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Build with Hugo</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">ghcr.io/andrewbeaton/hugo-drone:latest</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">pull</span>: <span style="color:#ae81ff">always</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">commands</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">echo &#34;Checking Hugo version.&#34;</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">hugo version</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">cd /drone/src/hugo/</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">hugo --environment production --verbose --debug </span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">ls -al /drone/src/hugo/public</span>
</span></span></code></pre></div><p>This configuration instructs Drone to use the <code>andrewbeaton/hugo-drone</code> image and execute the <code>hugo</code> command for <code>production</code> to build your Hugo site. I like to enable verbose and debug output to help with problem-solving, and I also output the current version of Hugo with each build.</p>
<h2 id="step-5-building-and-deploying-with-drone">Step 5: Building and Deploying with Drone</h2>
<p>Now that everything is set up, you can build and deploy your Hugo site with Drone.</p>
<p>Commit and push the changes you made to your <code>.drone.yml</code> file. The Drone pipeline will automatically trigger, building your Hugo site.</p>
<p>Take a look at some of my other posts for examples on how to deploy to a web server or Cloudflare Pages.</p>
<h2 id="summary">Summary</h2>
<p>The <code>andrewbeaton/hugo-drone</code> Docker image simplifies the process of building Hugo sites by providing a preconfigured environment. By following the steps outlined in this blog post, you can use this image to automate your Hugo builds, saving time and effort in the development and deployment process.</p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
