<?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>docker on Andrew Beaton</title>
    <link>https://andrewbeaton.net/tags/docker/</link>
    <description>Recent content in docker 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/docker/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>
    
    <item>
      <title>Create and Publish a Docker Image to GitHub&#39;s Container Registry using GitHub Actions.</title>
      <link>https://andrewbeaton.net/posts/2023/06/docker-github-registry-actions/</link>
      <pubDate>Fri, 09 Jun 2023 00:00:00 +0000</pubDate>
      
      <guid>https://andrewbeaton.net/posts/2023/06/docker-github-registry-actions/</guid>
      <description>A guide on how to publish a Docker image to GitHub&amp;#39;s Container Registry using GitHub Actions.</description>
      <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>In this tutorial, I will walk you through the process of publishing a Docker image to GitHub&rsquo;s Container Registry using GitHub Actions. By using GitHub Actions, you can automate the build and publish process, making it easier to distribute your Docker images.</p>
<h2 id="prerequisites">Prerequisites</h2>
<p>Before getting started, make sure you have the following:</p>
<ol>
<li>A GitHub account.</li>
<li>A Dockerfile that describes your application&rsquo;s dependencies and build instructions.</li>
<li>A GitHub repository where you want to publish your Docker image.</li>
</ol>
<h2 id="step-1-set-up-github-actions-workflow">Step 1: Set up GitHub Actions workflow</h2>
<p>GitHub Actions allow you to automate tasks by creating workflows.</p>
<p>To publish a Docker image, we&rsquo;ll create a workflow file named <code>publish.yml</code>.</p>
<p>Create a new directory called <code>.github/workflows</code> in the root of your repository, if it doesn&rsquo;t already exist.</p>
<p>Inside this directory, create a new file named <code>publish.yml</code> and add the following content:</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">name</span>: <span style="color:#ae81ff">Publish Docker Image</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">on</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">push</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">branches</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">main</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">jobs</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">build-and-publish</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">runs-on</span>: <span style="color:#ae81ff">ubuntu-latest</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">Checkout code</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">uses</span>: <span style="color:#ae81ff">actions/checkout@v2</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Login to GitHub Container Registry</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">uses</span>: <span style="color:#ae81ff">docker/login-action@v1</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">with</span>:
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">registry</span>: <span style="color:#ae81ff">ghcr.io</span>
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">username</span>: <span style="color:#ae81ff">${{ github.actor }}</span>
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">password</span>: <span style="color:#ae81ff">${{ secrets.GITHUB_TOKEN }}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Build and push Docker image</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">uses</span>: <span style="color:#ae81ff">docker/build-push-action@v2</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">with</span>:
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">context</span>: <span style="color:#ae81ff">.</span>
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">push</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">tags</span>: <span style="color:#ae81ff">ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ github.sha }}</span>
</span></span></code></pre></div><p>This workflow will trigger whenever you push changes to the <code>main</code> branch. It checks out the code, logs in to GitHub&rsquo;s Container Registry using your GitHub credentials, and builds and pushes the Docker image to the registry.</p>
<h2 id="step-2-configure-the-dockerfile">Step 2: Configure the Dockerfile</h2>
<p>In your repository, create a file named <code>Dockerfile</code> and add the necessary instructions to build your Docker image. Here&rsquo;s an example <code>Dockerfile</code> for a Node.js application:</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-Dockerfile" data-lang="Dockerfile"><span style="display:flex;"><span><span style="color:#66d9ef">FROM</span><span style="color:#e6db74"> node:14</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">WORKDIR</span><span style="color:#e6db74"> /app</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">COPY</span> package.json package-lock.json ./<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">RUN</span> npm ci --only<span style="color:#f92672">=</span>production<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">COPY</span> app.js .<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">CMD</span> [<span style="color:#e6db74">&#34;node&#34;</span>, <span style="color:#e6db74">&#34;app.js&#34;</span>]<span style="color:#960050;background-color:#1e0010">
</span></span></span></code></pre></div><p>Make sure to modify the <code>Dockerfile</code> to suit your application&rsquo;s requirements.</p>
<h2 id="step-3-push-changes-to-your-repository">Step 3: Push changes to your repository</h2>
<p>Commit and push the <code>Dockerfile</code>, <code>publish.yml</code>, and any other files you may have modified to your repository.</p>
<h2 id="step-4-monitor-the-workflow-execution">Step 4: Monitor the workflow execution</h2>
<p>After pushing the changes, navigate to the &ldquo;Actions&rdquo; tab in your GitHub repository. You should see the workflow you created (&ldquo;Publish Docker Image&rdquo;) listed there. Click on it to monitor the execution.</p>
<h2 id="step-5-verify-the-docker-image-in-github-container-registry">Step 5: Verify the Docker image in GitHub Container Registry</h2>
<p>Once the workflow execution is complete, go to the &ldquo;Packages&rdquo; tab in your GitHub repository. You should see your Docker image listed there. Click on it to view the details.</p>
<h2 id="summary">Summary</h2>
<p>You have successfully published a Docker image to GitHub&rsquo;s Container Registry using GitHub Actions. By automating this process, you can easily distribute your Docker images and ensure consistent deployment across different environments. GitHub Actions provides a powerful platform for automating various tasks in your development workflow, saving you time and effort.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Create and Publish a Docker Image to GitHub&#39;s Container Registry</title>
      <link>https://andrewbeaton.net/posts/2023/06/docker-github-container-registry/</link>
      <pubDate>Thu, 08 Jun 2023 00:00:00 +0000</pubDate>
      
      <guid>https://andrewbeaton.net/posts/2023/06/docker-github-container-registry/</guid>
      <description>A guide on how to publish a Docker image to GitHub&amp;#39;s Container Registry using Docker Push.</description>
      <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>Docker has become an essential tool in modern software development, enabling easy and efficient containerisation of applications. GitHub&rsquo;s Container Registry provides a convenient way to store and manage Docker images within the GitHub ecosystem.</p>
<p>In this tutorial, we will walk through the process of creating, editing, and publishing a Docker image to GitHub&rsquo;s Container Registry.</p>
<h2 id="prerequisites">Prerequisites</h2>
<p>Before we begin, ensure that you have the following:</p>
<ol>
<li>A GitHub account</li>
<li>Docker installed on your local machine</li>
<li>Basic familiarity with Docker commands</li>
</ol>
<h2 id="step-1-create-a-dockerfile">Step 1: Create a Dockerfile</h2>
<p>The first step is to create a Dockerfile, which defines the instructions to build your Docker image. Open a text editor and create a new file called <code>Dockerfile</code>. Here&rsquo;s a basic example:</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-Dockerfile" data-lang="Dockerfile"><span style="display:flex;"><span><span style="color:#75715e"># Use a base image</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">FROM</span><span style="color:#e6db74"> ubuntu:latest</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#75715e"># Set the working directory</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">WORKDIR</span><span style="color:#e6db74"> /app</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#75715e"># Copy files to the container</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">COPY</span> . /app<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#75715e"># Install dependencies</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">RUN</span> apt-get update <span style="color:#f92672">&amp;&amp;</span> apt-get install -y &lt;your-package-name&gt;<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#75715e"># Specify the command to run when the container starts</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span><span style="color:#66d9ef">CMD</span> [<span style="color:#e6db74">&#34;&lt;your-command&gt;&#34;</span>]<span style="color:#960050;background-color:#1e0010">
</span></span></span></code></pre></div><p>Customise the <code>FROM</code> line with the base image you want to use and replace <code>&lt;your-package-name&gt;</code> with the required packages for your application. Also, update <code>&lt;your-command&gt;</code> with the command to start your application.</p>
<h2 id="step-2-build-the-docker-image">Step 2: Build the Docker Image</h2>
<p>Once you have the Dockerfile ready, you can build the Docker image.</p>
<p>Open a terminal or command prompt and navigate to the directory containing the Dockerfile.</p>
<p>Run the following command:</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-bash" data-lang="bash"><span style="display:flex;"><span>docker build -t &lt;image-name&gt; .
</span></span></code></pre></div><p>Replace <code>&lt;image-name&gt;</code> with the desired name for your Docker image.</p>
<p>The <code>.</code> at the end specifies the build context, which includes the files needed for building the image.</p>
<p>Wait for the build process to complete.</p>
<p>Docker will execute the instructions in the Dockerfile and generate the image.</p>
<h2 id="step-3-tag-the-docker-image">Step 3: Tag the Docker Image</h2>
<p>To publish the Docker image to GitHub&rsquo;s Container Registry, you need to tag it accordingly.</p>
<p>Run the following command:</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-bash" data-lang="bash"><span style="display:flex;"><span>docker tag &lt;image-name&gt; ghcr.io/&lt;username&gt;/&lt;repository&gt;:&lt;tag&gt;
</span></span></code></pre></div><p>Replace <code>&lt;username&gt;</code> with your GitHub username, <code>&lt;repository&gt;</code> with the name of the repository you want to push the image to, and <code>&lt;tag&gt;</code> with the desired tag (e.g., version number or <code>latest</code>).</p>
<h2 id="step-4-log-in-to-github-container-registry">Step 4: Log in to GitHub Container Registry</h2>
<p>Before you can publish the image, you need to authenticate with GitHub&rsquo;s Container Registry.</p>
<p>Run the following command:</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-bash" data-lang="bash"><span style="display:flex;"><span>docker login ghcr.io -u &lt;username&gt;
</span></span></code></pre></div><p>Replace <code>&lt;username&gt;</code> with your GitHub username. You will be prompted to enter your GitHub password or a personal access token.</p>
<h2 id="step-5-publish-the-docker-image">Step 5: Publish the Docker Image</h2>
<p>Now that you&rsquo;re logged in, you can publish the Docker image to GitHub&rsquo;s Container Registry.</p>
<p>Run the following command:</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-bash" data-lang="bash"><span style="display:flex;"><span>docker push ghcr.io/&lt;username&gt;/&lt;repository&gt;:&lt;tag&gt;
</span></span></code></pre></div><p>Replace <code>&lt;username&gt;</code>, <code>&lt;repository&gt;</code>, and <code>&lt;tag&gt;</code> with the values you used in Step 3.</p>
<p>Wait for the push process to complete. Once finished, your Docker image will be available in GitHub&rsquo;s Container Registry, associated with your specified repository.</p>
<h2 id="step-6-update-and-re-publish">Step 6: Update and Re-Publish</h2>
<p>If you make changes to your Docker image or need to update it with a new version, follow the steps again from Step 2 onwards.</p>
<p>Remember to tag the image with a new version number or an appropriate tag, and push it to GitHub&rsquo;s Container Registry.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Creating an Ackee Container with Docker Compose</title>
      <link>https://andrewbeaton.net/posts/2023/06/docker-compose-ackee/</link>
      <pubDate>Thu, 01 Jun 2023 00:00:00 +0000</pubDate>
      
      <guid>https://andrewbeaton.net/posts/2023/06/docker-compose-ackee/</guid>
      <description>Creating an Ackee Container with Docker Compose</description>
      <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p><a href="https://ackee.electerious.com/">Ackee</a> is a self-hosted, open-source, privacy focused, analytics platform that provides useful insights into your website&rsquo;s traffic.</p>
<p>By running Ackee in a <a href="https://www.docker.com/">Docker</a> container, you can easily deploy and manage it on your own server.</p>
<p>In this guide, I&rsquo;ll talk you through the process of creating an Ackee Docker container and setting it up using <a href="https://docs.docker.com/compose/">Docker Compose</a>.</p>
<h2 id="prerequisites">Prerequisites</h2>
<p>Before you start, ensure you have the following:</p>
<ul>
<li>
<p>Docker installed on your server.</p>
</li>
<li>
<p>Docker Compose installed on your server.</p>
</li>
<li>
<p>Basic knowledge of working with Docker and Docker Compose.</p>
</li>
</ul>
<h2 id="create-a-docker-compose-file">Create a Docker Compose File</h2>
<p>Open your text editor and create a new file named docker-compose.yml.</p>
<p>In this file, we define the configuration for the Ackee Docker container.</p>
<h2 id="define-the-docker-compose-configuration">Define the Docker Compose Configuration</h2>
<p>Copy and paste the following configuration into your docker-compose.yml file:</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">version</span>: <span style="color:#e6db74">&#39;3&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">services</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">ackee</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">electerious/ackee</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">container_name</span>: <span style="color:#ae81ff">ackee</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">restart</span>: <span style="color:#ae81ff">always</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">ports</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#34;3000:3000&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">environment</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">WAIT_HOSTS=mongodb:27017</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DATABASE_URI=mongodb://mongo:27017/ackee</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">depends_on</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">mongo</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">mongo</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">mongo</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">container_name</span>: <span style="color:#ae81ff">mongo</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">restart</span>: <span style="color:#ae81ff">always</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">ports</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#39;27017:27017&#39;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">volumes</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">ackee-mongo:/data/db</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">volumes</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">ackee-mongo</span>:
</span></span></code></pre></div><p>This configuration defines two services: ackee and mongo.</p>
<p>The ackee service uses the electerious/ackee Docker image, exposes port 3000, sets the DATABASE_URI environment variable to connect to the MongoDB instance, and depends on the mongo service.</p>
<p>The mongo service uses the mongo Docker image and mounts a volume to persist MongoDB data.</p>
<h2 id="save-the-docker-compose-file">Save the Docker Compose File</h2>
<p>Save the docker-compose.yml file in your desired directory on your server. Make sure you remember the location as we&rsquo;ll use it in the next step.</p>
<h2 id="start-the-ackee-docker-container">Start the Ackee Docker Container</h2>
<p>Open a terminal or command prompt and navigate to the directory where you saved the docker-compose.yml file.</p>
<p>Run the following command to start the Ackee Docker container:</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-bash" data-lang="bash"><span style="display:flex;"><span>docker-compose up -d
</span></span></code></pre></div><p>Docker Compose will download the necessary Docker images and start the Ackee and MongoDB containers in detached mode.</p>
<h2 id="access-ackee-in-your-web-browser">Access Ackee in your Web Browser</h2>
<p>Open your web browser and enter the following URL:</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-arduino" data-lang="arduino"><span style="display:flex;"><span>http:<span style="color:#75715e">//localhost:3000
</span></span></span></code></pre></div><p>You should now see the Ackee login page.</p>
<p>Create a new user account and log in to the Ackee dashboard.</p>
<p>You have now successfully created an Ackee Docker container and set it up using Docker Compose. You can now start analyzing your website&rsquo;s traffic using Ackee&rsquo;s powerful analytics features.</p>
<h2 id="additional-configuration-options">Additional Configuration Options</h2>
<p>If you want to use a different port for Ackee, you can modify the ports section in the docker-compose.yml file:</p>
<pre tabindex="0"><code>ports:
    - &#34;3000:3000&#34;
</code></pre><p>To allow your domains to connect to Ackee, you can set the ACKEE_ALLOW_ORIGIN environment variable and list your domains:</p>
<pre tabindex="0"><code>ACKEE_ALLOW_ORIGIN=https://domain1.com,https://domain2.com
</code></pre><p>You can specify your username and password in the docker-compose.yml file with the environment variables:</p>
<pre tabindex="0"><code>- ACKEE_USERNAME=username
- ACKEE_PASSWORD=password 
</code></pre><p>Remember to regularly update the docker-compose.yml file to use the latest version of Ackee and MongoDB images to benefit from the latest features and security patches.</p>
<h2 id="summary">Summary</h2>
<p>With Docker Compose, managing your Ackee deployment becomes seamless, allowing you to focus on gaining valuable insights from your website&rsquo;s analytics data.</p>
<p>If you want to look further in to any of the above tools, do take a look at my previous posts and read the official documentation from the following sites:</p>
<p><a href="https://ackee.electerious.com/">Ackee</a><br>
<a href="https://www.docker.com/">Docker</a>
<a href="https://docs.docker.com/compose/">Docker Compose</a></p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Set up Hugo with Drone and Gitea</title>
      <link>https://andrewbeaton.net/posts/2023/05/hugo-drone-io-gitea/</link>
      <pubDate>Sat, 20 May 2023 00:00:00 +0000</pubDate>
      
      <guid>https://andrewbeaton.net/posts/2023/05/hugo-drone-io-gitea/</guid>
      <description>Set up Hugo with Drone and Gitea</description>
      <content:encoded><![CDATA[<p>If you prefer running your own local instances of Drone.io and Gitea using Docker containers, you can still automate your Hugo website deployment seamlessly.</p>
<p>In this guide, I&rsquo;ll walk you through the process of setting up Hugo with a local Drone.io instance and a local Gitea server, allowing you to automate your website deployment workflow in a self-hosted environment.</p>
<p>I used this setup initially, before changing the Drone deployment to upload through FTP to my local staging web server. If you&rsquo;re interested in this setup, you can find the details in the guide <a href="/posts/2023/05/drone-io-ftp-deploy/">Deploy to an FTP server with Drone</a>.</p>
<h2 id="note">Note</h2>
<p>The instructions below cover the setup and running of the Docker instances locally. If you are setting this up in your home lab, then just change the references from local to the details of your servers.</p>
<h2 id="prerequisites">Prerequisites</h2>
<p>Before getting started, make sure you have the following prerequisites in place:</p>
<ul>
<li><strong>Docker installed:</strong>
<ul>
<li>Make sure you have Docker installed on your local machine or remote server.</li>
</ul>
</li>
<li><strong>Basic knowledge of Docker:</strong>
<ul>
<li>Familiarity with Docker and Docker Compose will be helpful.</li>
</ul>
</li>
<li><strong>A working Hugo website:</strong>
<ul>
<li>Set up a Hugo website locally.</li>
</ul>
</li>
</ul>
<h2 id="step-1-set-up-gitea">Step 1: Set up Gitea</h2>
<ol>
<li>Create a new directory on your machine for the Gitea Docker configuration.</li>
<li>Create a <code>docker-compose.yml</code> file within that directory and add the following content:</li>
</ol>
<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">version</span>: <span style="color:#e6db74">&#39;3&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">services</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">gitea</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">gitea/gitea:latest</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">ports</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#34;3000:3000&#34;</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#34;2222:22&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">volumes</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">./gitea-data:/data</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">restart</span>: <span style="color:#ae81ff">always</span>
</span></span></code></pre></div><ol start="3">
<li>Save the file and navigate to the Gitea Docker configuration directory in your terminal.</li>
<li>Run the command <code>docker-compose up -d</code> to start the Gitea container.</li>
</ol>
<p>Gitea should now be accessible at <a href="http://localhost:3000">http://localhost:3000</a>. Follow the on-screen instructions to set up an admin account and create a new repository for your Hugo website.</p>
<h2 id="step-2-set-up-droneio">Step 2: Set up Drone.io</h2>
<ol>
<li>Create a new directory on your machine for the Drone.io Docker configuration.</li>
<li>Create a <code>docker-compose.yml</code> file within that directory and add the following content:</li>
</ol>
<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">version</span>: <span style="color:#e6db74">&#39;3&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">services</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">drone-server</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">drone/drone:latest</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">ports</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#34;8080:80&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">volumes</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">./drone-data:/data</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">restart</span>: <span style="color:#ae81ff">always</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">environment</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DRONE_GITEA_SERVER=http://gitea:3000</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DRONE_GITEA_CLIENT_ID=your-gitea-client-id</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DRONE_GITEA_CLIENT_SECRET=your-gitea-client-secret</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">drone-runner</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">drone/drone-runner-docker:latest</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">volumes</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">/var/run/docker.sock:/var/run/docker.sock</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">restart</span>: <span style="color:#ae81ff">always</span>
</span></span></code></pre></div><ol start="3">
<li>
<p>Save the file and navigate to the Drone.io Docker configuration directory in your terminal.</p>
</li>
<li>
<p>Replace <code>your-gitea-client-id</code> and <code>your-gitea-client-secret</code> with the appropriate values. These can be obtained by registering a new OAuth application within Gitea&rsquo;s settings.</p>
</li>
<li>
<p>Run the command <code>docker-compose up -d</code> to start the Drone.io containers.</p>
</li>
</ol>
<p>Drone.io should now be accessible at <a href="http://localhost:8080">http://localhost:8080</a>. Sign in with your Gitea credentials and authorise Drone.io to access your Gitea repositories.</p>
<h2 id="step-3-configure-the-droneio-pipeline">Step 3: Configure the Drone.io Pipeline</h2>
<ol>
<li>Within your Hugo website&rsquo;s repository, create a <code>.drone.yml</code> file in the root directory.</li>
<li>Add the following code to the <code>.drone.yml</code> file:</li>
</ol>
<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">name</span>: <span style="color:#ae81ff">your-pipeline-name</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">Clone Git Submodules</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">alpine/git</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">git submodule init</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">git submodule update --recursive --remote</span>
</span></span><span style="display:flex;"><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">binaryronin/drone-hugo: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 --verbose </span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">ls -al /drone/src/hugo/public</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Deploy</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">appleboy</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">deploy</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">appleboy/drone-scp</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">settings</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">host</span>: <span style="color:#ae81ff">your-remote-host</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">username</span>: <span style="color:#ae81ff">your-remote-username</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">password</span>: <span style="color:#ae81ff">your-remote-password</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">source</span>:
</span></span><span style="display:flex;"><span>        - <span style="color:#ae81ff">/hugo/public/</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">target</span>: <span style="color:#ae81ff">/path/to/your/remote/directory</span>
</span></span></code></pre></div><p>Replace <code>your-pipeline-name</code> with a suitable name for your pipeline.</p>
<ol start="3">
<li>Adjust the <code>host</code>, <code>username</code>, <code>password</code>, and <code>target</code> fields to match your remote server details and deployment directory.</li>
</ol>
<h2 id="step-4-trigger-the-pipeline">Step 4: Trigger the Pipeline</h2>
<ol>
<li>Push your updated <code>.drone.yml</code> file to your Gitea repository.</li>
<li>This will trigger the Drone.io pipeline to run.</li>
<li>Monitor the build process in the Drone.io interface to ensure everything is working correctly.</li>
<li>Once the pipeline completes successfully, your Hugo website will be deployed to the specified remote server.</li>
</ol>
<p>You have successfully set up Hugo with a local Drone.io instance and a local Gitea server. Now, whenever you push changes to your Gitea repository, Drone.io will automatically build your Hugo website and deploy it to your remote server.</p>
<p>I&rsquo;ll continue documenting my journey with Gitea, Drone and Hugo and share the interesting things I find along the way.</p>
<p>If you want to look further in to any of the above tools, do take a look at my previous posts and read the official documentation from the following sites:</p>
<p><a href="https://gitea.io/en-us/">Gitea</a>
<a href="https://www.drone.io/">Drone</a>
<a href="https://gohugo.io/">Hugo</a></p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Set up Hugo with Drone and GitHub</title>
      <link>https://andrewbeaton.net/posts/2023/05/hugo-drone-io-github/</link>
      <pubDate>Sat, 20 May 2023 00:00:00 +0000</pubDate>
      
      <guid>https://andrewbeaton.net/posts/2023/05/hugo-drone-io-github/</guid>
      <description>Set up Hugo with Drone and GitHub</description>
      <content:encoded><![CDATA[<p>If you&rsquo;re looking for an efficient way to automate your Hugo website deployment, using a Docker Drone.io container as your continuous integration and delivery (CI/CD) platform can be a great choice.</p>
<p>In this guide, I&rsquo;ll walk you through the process of setting up Hugo with a Docker Drone.io container and GitHub, allowing you to streamline your website deployment workflow.</p>
<h2 id="prerequisites">Prerequisites</h2>
<p>Before getting started, make sure you have the following prerequisites in place:</p>
<ul>
<li><em><strong>Docker installed:</strong></em>
<ul>
<li>Ensure you have Docker installed on your local machine.</li>
</ul>
</li>
<li><em><strong>Basic knowledge of Docker:</strong></em>
<ul>
<li>Familiarity with Docker and Docker Compose will be helpful.</li>
</ul>
</li>
<li><em><strong>A working Hugo website:</strong></em>
<ul>
<li>Set up a Hugo website locally.</li>
</ul>
</li>
<li><em><strong>A GitHub repository:</strong></em>
<ul>
<li>Host your Hugo website&rsquo;s code in a GitHub repository.</li>
</ul>
</li>
</ul>
<h2 id="step-1-set-up-a-docker-droneio-container">Step 1: Set Up a Docker Drone.io Container</h2>
<ol>
<li>Create a new directory on your machine for the Docker Drone.io container configuration.</li>
<li>Create a <code>docker-compose.yml</code> file within that directory and add the following content:</li>
</ol>
<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">version</span>: <span style="color:#e6db74">&#39;3&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">services</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">drone-server</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">drone/drone:latest</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">ports</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#34;8080:80&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">volumes</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">./drone-data:/data</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">restart</span>: <span style="color:#ae81ff">always</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">environment</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DRONE_GITHUB_CLIENT_ID=your-github-client-id</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">DRONE_GITHUB_CLIENT_SECRET=your-github-client-secret</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">drone-runner</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">drone/drone-runner-docker:latest</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">volumes</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">/var/run/docker.sock:/var/run/docker.sock</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">restart</span>: <span style="color:#ae81ff">always</span>
</span></span></code></pre></div><ol start="3">
<li>
<p>Save the file and navigate to the Docker Drone.io container configuration directory in your terminal.</p>
</li>
<li>
<p>Replace <code>your-github-client-id</code> and <code>your-github-client-secret</code> with the appropriate values. These can be obtained by registering a new OAuth application within GitHub&rsquo;s settings.</p>
</li>
<li>
<p>Run the command <code>docker-compose up -d</code> to start the Docker Drone.io container.</p>
</li>
</ol>
<p>Drone.io should now be accessible at <a href="http://localhost:8080">http://localhost:8080</a>.</p>
<h2 id="step-2-connect-droneio-to-github">Step 2: Connect Drone.io to GitHub</h2>
<ol>
<li>Open Drone.io in your web browser at <a href="http://localhost:8080">http://localhost:8080</a>.</li>
<li>Sign in with your GitHub credentials.</li>
<li>Authorise Drone.io to access your GitHub repositories.</li>
</ol>
<h2 id="step-3-configure-the-droneio-pipeline">Step 3: Configure the Drone.io Pipeline</h2>
<ol>
<li>Within your Hugo website&rsquo;s GitHub repository, create a <code>.drone.yml</code> file in the root directory.</li>
<li>Add the following code to the <code>.drone.yml</code> file:</li>
</ol>
<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">name</span>: <span style="color:#ae81ff">your-pipeline-name</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">Clone Git Submodules</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">alpine/git</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">git submodule init</span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">git submodule update --recursive --remote</span>
</span></span><span style="display:flex;"><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">binaryronin/drone-hugo: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 --verbose </span>
</span></span><span style="display:flex;"><span>      - <span style="color:#ae81ff">ls -al /drone/src/hugo/public </span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Deploy</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">image</span>: <span style="color:#ae81ff">appleboy/drone-scp</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">settings</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">host</span>: <span style="color:#ae81ff">your-remote-host</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">username</span>: <span style="color:#ae81ff">your-remote-username</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">password</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">from_secret</span>: <span style="color:#ae81ff">your-remote-password-secret</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">source</span>: 
</span></span><span style="display:flex;"><span>        - <span style="color:#ae81ff">/hugo/public/</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">target</span>: <span style="color:#ae81ff">/path/to/your/remote/directory</span>
</span></span></code></pre></div><p>Replace <code>your-pipeline-name</code> with a suitable name for your pipeline.</p>
<ol start="3">
<li>
<p>Adjust the <code>host</code>, <code>username</code>, <code>password</code>, and <code>target</code> fields to match your remote server details and deployment directory.</p>
</li>
<li>
<p>Add a secret for your remote server&rsquo;s password by going to your Drone.io repository settings and adding a secret with the key <code>your-remote-password-secret</code> and the corresponding value.</p>
</li>
</ol>
<h2 id="step-4-trigger-the-pipeline">Step 4: Trigger the Pipeline</h2>
<ol>
<li>Push your updated <code>.drone.yml</code> file to your GitHub repository.</li>
<li>This will trigger the Drone.io pipeline to run.</li>
<li>Monitor the build process in the Drone.io interface to ensure everything is working correctly.</li>
<li>Once the pipeline completes successfully, your Hugo website will be deployed to the specified remote server.</li>
</ol>
<p>You have successfully set up Hugo with a Docker Drone.io container and GitHub. Now, whenever you push changes to your GitHub repository, Drone.io will automatically build your Hugo website and deploy it to your remote server.</p>
<p>I&rsquo;ll continue documenting my journey with Gitea, Drone and Hugo and share the interesting things I find along the way.</p>
<p>If you want to look further in to any of the above tools, do take a look at my previous posts and read the official documentation from the following sites:</p>
<p><a href="https://gitea.io/en-us/">Gitea</a>
<a href="https://www.drone.io/">Drone</a>
<a href="https://gohugo.io/">Hugo</a></p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
