<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cicd on blog.iankulin.com</title><link>https://blog.iankulin.com/tags/cicd/</link><description>Recent content in Cicd on blog.iankulin.com</description><generator>Hugo</generator><language>en-AU</language><lastBuildDate>Mon, 16 Dec 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.iankulin.com/tags/cicd/index.xml" rel="self" type="application/rss+xml"/><item><title>Updating a deployment on fly.io</title><link>https://blog.iankulin.com/updating-a-deployment-on-fly-io/</link><pubDate>Mon, 16 Dec 2024 00:00:00 +0000</pubDate><guid>https://blog.iankulin.com/updating-a-deployment-on-fly-io/</guid><description>&lt;img src="https://blog.iankulin.com/images/flyio_picture.png" width="620" alt=""&gt;
&lt;p&gt;I&amp;rsquo;ve had my external UptimeKuma chugging away on &lt;a href="https://fly.io/"&gt;fly.io&lt;/a&gt;, for free, for months now, and the container image it was based on was a bit out of date, so I wanted to update it. I hadn&amp;rsquo;t looked at fly.io for months, and couldn&amp;rsquo;t really recall what I&amp;rsquo;d done to create it.&lt;/p&gt;
&lt;p&gt;The way this works is that that you create a fly.toml file that sets out the details of your app. From memory I think I used the one from the docs and gave it a unique name, the name of the Docker image, the port, the datacentre location, and the directory for the persisted data. The you run &lt;code&gt;fly deploy&lt;/code&gt; from the directory with the toml file (having already installed the CLI tool and logged in) and you&amp;rsquo;re in business.&lt;/p&gt;
&lt;p&gt;Fly doesn&amp;rsquo;t actually run your container, it deconstructs it and uses the layer information to launch a firecracker instance, but of course, none of this matters to the user - it&amp;rsquo;s just as if your containerised app is magically live on the internet with hardly any effort or money (so far I&amp;rsquo;ve paid $0.00 for eight months of good service).&lt;/p&gt;
&lt;p&gt;I was sort of dreading the upgrade, I guessed I&amp;rsquo;d need to kill the old instance, start the new one and connect it back to my persistent storage, but here&amp;rsquo;s what I actually did.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Went to the folder with my fly.toml file&lt;/li&gt;
&lt;li&gt;Typed &lt;code&gt;fly deploy&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2024-10-28-at-6.22.46-am-1.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2024-10-28-at-6.22.46-am-1.png" width="900" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Fly.io is such a great way to deploy stuff. If I wasn&amp;rsquo;t such a committed self-hoster I would use it a lot more. They used to be hosted on Heroku (which is on AWS) but I understand they have moved to their own worldwide data centers. Their secret sauce is the dev experience. So good.&lt;/p&gt;
&lt;h3 id="edit-update-from-the-future"&gt;Edit: Update from the future&lt;/h3&gt;
&lt;p&gt;So, very day or so since I did that update, which was to version 1.23, I&amp;rsquo;ve been getting these emails from Fly.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;[Fly.io] ikuptime ran out of memory and crashed
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Fly &amp;lt;support@fly.io&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;4:12 AM (16 hours ago)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Hello! Your “ikuptime” application hosted on Fly.io crashed because it ran out of memory. Specifically, the instance 3d8d7de3b20738. Adding more RAM to your application might help!
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Hmm. In theory the free machine I&amp;rsquo;m using on Fly includes 256MB of RAM, and when I look at the average use, it&amp;rsquo;s sitting around 200MB, but it does say out of 223MB, so I guess that&amp;rsquo;s the real limit.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2024-11-06-at-8.37.18-pm.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2024-11-06-at-8.37.18-pm.png" width="900" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Looking at the graph of memory use, it does look like there&amp;rsquo;s something in the container with a memory leak, then it&amp;rsquo;s being restarted once it hits about 205MB for a while.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2024-11-06-at-8.31.28-pm.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2024-11-06-at-8.31.28-pm.png" width="1000" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;An easy fix might be to swap to a lighter weight container. You can see at the end of the graph above I&amp;rsquo;ve dropped it down to about 160MB. That was by using the image tagged with &lt;code&gt;:1-alpine&lt;/code&gt;. I&amp;rsquo;ll keep and eye on it and see what happens.&lt;/p&gt;
&lt;p&gt;I am running the full size container in the home lab inside an LXC, and it doesn&amp;rsquo;t seem to have the leak.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2024-11-06-at-8.40.49-pm.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2024-11-06-at-8.40.49-pm.png" width="1000" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is not quite an apples for apples comparison. Fly.io doesn&amp;rsquo;t actually run the container, it uses the container layers to build the app in a tiny VM called &lt;a href="https://firecracker-microvm.github.io/"&gt;firecracker&lt;/a&gt;. This is the technology used by AWS to run serverless functions.&lt;/p&gt;
&lt;p&gt;I guess I&amp;rsquo;ll be able to see in a day or so if I&amp;rsquo;ve solved the problem.&lt;/p&gt;
&lt;h3 id="edit-update-from-the-distant-future"&gt;Edit: Update from the distant future&lt;/h3&gt;
&lt;p&gt;Perhaps the memory growth is still there (after an update it drops down 12ish MB):&lt;/p&gt;
&lt;img src="https://blog.iankulin.com/images/screenshot-2025-03-17-at-12.56.40.png" width="900" alt=""&gt;
&lt;p&gt;but in any case, running the Alpine base image has kept the memory use well under the limits for my free instance.&lt;/p&gt;
&lt;p&gt;In other news, I was on a new laptop when I tried to run the &lt;code&gt;fly deploy&lt;/code&gt; command today, so things were a tiny bit more complex. I had to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;install the fly command line stuff with &lt;code&gt;brew install flyctl&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;then when I ran &lt;code&gt;fly deploy,&lt;/code&gt; it asked me to sign in, and opened a web page for me to do so.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Getting Your Vite React App to Work on Github Pages</title><link>https://blog.iankulin.com/getting-your-vite-react-app-to-work-on-github-pages/</link><pubDate>Fri, 26 Jan 2024 00:00:00 +0000</pubDate><guid>https://blog.iankulin.com/getting-your-vite-react-app-to-work-on-github-pages/</guid><description>&lt;img src="https://blog.iankulin.com/images/combined.png" width="512" alt=""&gt;
&lt;p&gt;One of the many cool things about GitHub is &lt;a href="https://pages.github.com"&gt;GitHub Pages&lt;/a&gt; - the free web hosting Microsoft gives you while they vacuum up &lt;a href="https://docs.github.com/en/copilot/overview-of-github-copilot/about-github-copilot-individual"&gt;your code for CoPilot&lt;/a&gt; training. Each repository you keep there can have pages at &lt;code&gt;&amp;lt;your-github-username&amp;gt;.github.io/&amp;lt;repo-name&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;h3 id="github"&gt;GitHub&lt;/h3&gt;
&lt;p&gt;To enable this, you need to go into the settings for the repository - look down the left for &amp;ldquo;Pages&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-12-31-at-1.58.05-pm.png" alt=""&gt;&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s possible to have it based on a complicated GitHub action (where your build step happens on GitHub when you push your code), but the easiest thing is just to have it deployed from a branch. To do this you choose which branch (usually main) and whereabouts in the main branch your HTML is. The choices are in the root of your project, or in the &lt;code&gt;/docs&lt;/code&gt; directory. I&amp;rsquo;ve chosen the &lt;code&gt;/docs&lt;/code&gt; directory in the screenshot above, since my messy React project is in the root.&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s all the GitHub set up we need. Now whenever I push my project to the &lt;code&gt;main&lt;/code&gt; branch on GitHub, whatever is in the &lt;code&gt;/docs&lt;/code&gt; directory will be uploaded to my GitHub page for this repo.&lt;/p&gt;
&lt;h3 id="vitereact"&gt;Vite/React&lt;/h3&gt;
&lt;p&gt;Now we need to make a couple of changes to our project to get this to work. The first is to tell Vite the &amp;ldquo;base directory&amp;rdquo; for the project which needs to be the repo name you&amp;rsquo;ve used on GutHub.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2023-12-31-at-4.04.50-pm.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-12-31-at-4.04.50-pm.png" width="900" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is written into the &lt;code&gt;index.html&lt;/code&gt; that is built as part of this process. If it&amp;rsquo;s not there, then any browser accessing your &lt;code&gt;index.html&lt;/code&gt; on gh-pages won&amp;rsquo;t be able to find your JavaScript, and the user will be left looking at a blank white page instead of your amazing app.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2023-12-31-at-4.11.06-pm.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-12-31-at-4.11.06-pm.png" width="900" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;My process from this point, is to build the project with &lt;code&gt;npm run build&lt;/code&gt;. By default, this creates a &lt;code&gt;/dist&lt;/code&gt; directory in your project (which is already added to &lt;code&gt;.gitignore&lt;/code&gt;) and puts the project artifacts (the HTML, JavaScript, CSS and any images) into it. I then manually copy the artifacts over to the &lt;code&gt;/docs&lt;/code&gt; directory of the project and push it up to GitHub to be published - which takes two or three minutes.&lt;/p&gt;
&lt;p&gt;I like this manual step of copying the files over so that publishing is an intentful action on my part, and also, for solo projects I generally just work out of the main branch rather than on feature branches that then get PR&amp;rsquo;d into main. If you did want the process to be more CI/CD flavoured, you can just make another change the &lt;code&gt;vite.config.ts&lt;/code&gt; file to have your builds go straight to the &lt;code&gt;/docs&lt;/code&gt; folder.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-gdscript3" data-lang="gdscript3"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;import &lt;span style="color:#eceff4"&gt;{&lt;/span&gt; defineConfig &lt;span style="color:#eceff4"&gt;}&lt;/span&gt; from &lt;span style="color:#a3be8c"&gt;&amp;#39;vite&amp;#39;&lt;/span&gt;import react from &lt;span style="color:#a3be8c"&gt;&amp;#39;@vitejs/plugin-react&amp;#39;&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;//&lt;/span&gt; https&lt;span style="color:#eceff4"&gt;:&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;//&lt;/span&gt;vitejs&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;dev&lt;span style="color:#81a1c1"&gt;/&lt;/span&gt;config&lt;span style="color:#81a1c1"&gt;/&lt;/span&gt;&lt;span style="color:#81a1c1;font-weight:bold"&gt;export&lt;/span&gt; default defineConfig&lt;span style="color:#eceff4"&gt;({&lt;/span&gt; base&lt;span style="color:#eceff4"&gt;:&lt;/span&gt; &lt;span style="color:#a3be8c"&gt;&amp;#34;/mosh-expense/&amp;#34;&lt;/span&gt;&lt;span style="color:#eceff4"&gt;,&lt;/span&gt; plugins&lt;span style="color:#eceff4"&gt;:&lt;/span&gt; &lt;span style="color:#eceff4"&gt;[&lt;/span&gt;react&lt;span style="color:#eceff4"&gt;()],&lt;/span&gt; build&lt;span style="color:#eceff4"&gt;:&lt;/span&gt; &lt;span style="color:#eceff4"&gt;{&lt;/span&gt; outDir&lt;span style="color:#eceff4"&gt;:&lt;/span&gt; &lt;span style="color:#a3be8c"&gt;&amp;#39;docs&amp;#39;&lt;/span&gt;&lt;span style="color:#eceff4"&gt;,&lt;/span&gt; &lt;span style="color:#eceff4"&gt;}})&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Once all that&amp;rsquo;s working, and you&amp;rsquo;ve pushed your changes and waited a minute or two, your project should be live to the world on &lt;code&gt;github.io&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2023-12-31-at-4.45.26-pm.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-12-31-at-4.45.26-pm.png" width="900" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you want users browsing your repo to find the live version, it&amp;rsquo;s worth editing your repository about settings to point to it.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.iankulin.com/images/screen-shot-2023-12-31-at-4.47.30-pm.png"&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-12-31-at-4.47.30-pm.png" width="900" alt=""&gt;&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>