<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>adem.build — Adem Usta&#39;s blog</title>
<link>https://adem.build/posts</link>
<description>Hands-on posts by Adem Usta on software, local and agentic AI, homelabs, Kubernetes and hardware: what worked, what broke, what I&#39;d do differently.</description>
<language>en</language>
<atom:link href="https://adem.build/rss.xml" rel="self" type="application/rss+xml"/>
<lastBuildDate>Tue, 07 Jul 2026 00:00:00 GMT</lastBuildDate>
<item><title>Building a complete local AI</title><link>https://adem.build/posts/building-a-complete-local-ai</link><guid isPermaLink="true">https://adem.build/posts/building-a-complete-local-ai</guid><pubDate>Tue, 07 Jul 2026 00:00:00 GMT</pubDate><dc:creator>Adem Usta</dc:creator><description>How my gaming rig turned into a full local AI: private, self-hosted, and voice-enabled.</description><category>ai</category><category>llm</category><category>homelab</category><category>vllm</category><category>qwen</category><category>open-webui</category><category>gpu</category><category>self-hosted</category><category>local-ai</category><category>opencode</category><category>agentic-coding</category><content:encoded><![CDATA[<h2 id="from-the-depths-of-gaming-">From the depths of gaming …</h2>
<p>I’m a nerd, I play (played…) in my spare time. So I’ve got a “gamer” type PC, with a solid graphics card, a beefy CPU and lots of RAM. It’s a build I started putting together during covid, before prices back then (already going off the rails at that point) went completely crazy.</p>
<p>An rtx 3080, and I was doing pretty well gaming (Watch Dogs, Satisfactory, and other wonders).</p>
<p>Then I swapped the GPU, to do a bit of ML on it. Added more RAM too. And little by little my gaming PC turns into an ML workstation. Cool.</p>
<p>Then we entered the era of AI agents, local LLMs (thanks China), OSS projects to run AI agents and so on (hello OpenClaw, Hermes, etc), and I wanted to play with all of that at home. The workstation was just waiting for it. Perfect timing.</p>
<p>First attempts with local AIs, and you already start seeing the limits of the rtx 3090, despite its 24 GB of VRAM.</p>
<p>Being a proper “tryharder”, I decide to find a second GPU, the exact same one, for peanuts (well okay, 650 euros still). And then I have to swap the motherboard to actually take advantage of both GPUs (PCI lane count, etc, basically big nerd stuff). Found a motherboard on leboncoin, the GPU too. Built the whole thing. The second GPU overheats (on its own or with both, cross tests, double check). I got scammed by a 60-year-old dude who, and I quote, only played Flight Simulator on it (and had left the plastic film on the cooling plate!). I should’ve been more careful.</p>
<p>Still tryharding, I decide to open up the card: thermal paste bone DRY.</p>
<p><img src="https://adem.build/articles/7/thermal-paste.webp" alt="Dried thermal paste" loading="lazy" decoding="async"></p>
<p>I redo all of that (I only have one photo, unfortunately). We put everything back together.. it rips and it’s stable temperature-wise.</p>
<p>The full build:</p>
<p><img src="https://adem.build/articles/7/build.webp" alt="The full build" loading="lazy" decoding="async"></p>
<ul>
<li>Amd Ryzen 3900x</li>
<li>64 GB DDR4 RAM</li>
<li>Asus ROG X570</li>
<li>2x Asus TUF RTX 3090</li>
</ul>
<h2 id="-to-a-local-ai">… to a local AI</h2>
<p>Let’s go. Step by step.</p>
<h2 id="preliminary-tests">Preliminary tests</h2>
<p>The machine is ready, I install a linux distro on it and run my first convincing tests, notably with gemma 4.</p>
<p>That’s all nice and cool, but I don’t want to manage my workstation as a standalone, with everything that implies.</p>
<p>Simple solution, it was right in front of me the whole time! Integrate the workstation into my homelab. Just like with the rpis, my workstation joins my cluster with a single command.</p>
<p>Now, what to do?</p>
<p>First step: have your own LLM served properly on this node.</p>
<p>At that point, gemma-4 is all over the LLM threads on OW, so I test serving it here.</p>
<p>For that, we’ll use <code>vllm</code>, configure it to load the right gemma-4 that fits across the 2 GPUs (48GB total). From memory, we use a quantized model + a 200k context pre-allocation to make things interesting.</p>
<p>Blown away by the results. Local LLMs are starting to get serious.</p>
<p>I let it run locally, without using it too much.. a bit of opencode on a “fake” project to see how it handles itself. Nothing more.</p>
<p>Then… the latest Qwen model drops: qwen3.6. The benchmarks are claiming insane numbers, especially in agentic coding.</p>
<h2 id="qwen36-just-thank-you">Qwen3.6: just thank you.</h2>
<p>You know the guy by now: FOMO makes me switch from Gemma to QWEN. But this time we go further: I want to turn it into a personal agent, available on my phone everywhere, all the time. With voice. All private, local, no data leaves the house.</p>
<p>To pull this off, we’re going with a complete stack that fits in the workstation:</p>
<ul>
<li>vllm serving qwen3.6 27B, the exact version being <code>cyankiwi/Qwen3.6-27B-AWQ-BF16-INT4</code></li>
<li>open-webui for a clean and configurable chat interface</li>
<li>STT and TTS to chat with Qwen smoothly.
<ul>
<li>STT: Speaches (faster whisper) locked to FR</li>
<li>TTS: Kokoro</li>
</ul>
</li>
<li>WebSearch SearXNG for web searches without external APIs.</li>
</ul>
<p>All of it reachable only through my private tailscale network.</p>
<p>Each AI building block is served via an openai-compliant API, for maximum interconnectivity.</p>
<p>A quick look at open-webui:</p>
<p><img src="https://adem.build/articles/7/open-webui.webp" alt="open-webui preview" loading="lazy" decoding="async"></p>
<h2 id="performance">Performance</h2>
<h3 id="first-simple-case-web-search-and-analysis">First simple case: web search and analysis.</h3>
<video controls preload="metadata" style="width: 100%; border-radius: 0.5rem;">
  <source src="https://adem.build/articles/7/websearch.webm" type="video/webm" />
</video>
<p>Performance:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="plaintext"><code><span class="line"><span>Engine 000: Avg prompt throughput: 531.9 tokens/s, Avg generation throughput: 120.5 tokens/s, Running: 1 reqs, Waiting: 0 reqs,</span></span></code></pre>
<h3 id="demo-of-an-audio-conversation">Demo of an audio conversation:</h3>
<video controls preload="metadata" style="width: 100%; border-radius: 0.5rem;">
  <source src="https://adem.build/articles/7/audio.webm" type="video/webm" />
</video>
<p>It works, the UI responds well and it’s pretty fluid. Sure it’s slow, but there’s got to be a way to optimize that. A solid v1.</p>
<h2 id="agentic-coding">Agentic coding</h2>
<p>For this test, we’ll use an open source project: opencode.</p>
<p><a href="https://opencode.ai/">https://opencode.ai/</a></p>
<p>For those who don’t know what it is: it’s kind of the equivalent of claude code for anthropic, and codex for openai. Software that fully assists you in understanding, managing, and evolving a codebase.</p>
<p>We plug it into our local llm via a simple configuration:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="json"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "$schema"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"https://opencode.ai/config.json"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "model"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"vllm/qwen3.6-27b"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "small_model"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"vllm/qwen3.6-27b"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "provider"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: {</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">    "vllm"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: {</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">      "npm"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"@ai-sdk/openai-compatible"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">      "name"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"vLLM (local)"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">      "options"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: {</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">        "baseURL"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"https://my.endpoint.com"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      },</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">      "models"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: {</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">        "qwen3.6-27b"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: {</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">          "name"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"Qwen 3.6 27B"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
<p>The interface looks like this:</p>
<p><img src="https://adem.build/articles/7/opencode.webp" alt="opencode interface" loading="lazy" decoding="async"></p>
<p>Everything is set up, we’re good. Now, what are we going to make it code to test its performance?</p>
<h3 id="first-test-tic-tac-toe">First test: tic-tac-toe.</h3>
<p>Prompt:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="plaintext"><code><span class="line"><span>Let's build a well known game: tictactoe.</span></span>
<span class="line"><span>The goal is quite simple: a small React App, Typescript, Tailwind, served with a local dev server. 2 players can play the game locally on the same computer. Rules are the game rules, you know them.</span></span>
<span class="line"><span>Simple yet beautiful design, keep it simple and UX friendly.</span></span>
<span class="line"><span>Plan and go !</span></span></code></pre>
<p>One-shot:</p>
<video controls preload="metadata" style="width: 100%; border-radius: 0.5rem;">
  <source src="https://adem.build/articles/7/tictactoe.webm" type="video/webm" />
</video>
<p>Code available here:</p>
<p><a href="https://github.com/ademoverflow/tictactoe-qwen/">https://github.com/ademoverflow/tictactoe-qwen/</a></p>
<p>What opencode did:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="plaintext"><code><span class="line"><span>Summary: Tic-Tac-Toe Build</span></span>
<span class="line"><span></span></span>
<span class="line"><span>1. Project Scaffolding</span></span>
<span class="line"><span>- Ran npm create vite@latest . -- --template react-ts to scaffold a Vite + React + TypeScript project in the existing empty git repo</span></span>
<span class="line"><span>- Installed all dependencies with npm install</span></span>
<span class="line"><span>- Added Tailwind CSS 4 via npm install -D tailwindcss @tailwindcss/vite</span></span>
<span class="line"><span>2. Configuration</span></span>
<span class="line"><span>- vite.config.ts — Added @tailwindcss/vite plugin alongside the React plugin</span></span>
<span class="line"><span>- index.html — Updated &lt;title&gt; from "tictactoe" to "Tic-Tac-Toe"</span></span>
<span class="line"><span>- Cleaned up default template assets (App.css, hero.png, react.svg, vite.svg, favicon.svg)</span></span>
<span class="line"><span>3. Styles — src/index.css</span></span>
<span class="line"><span>- Replaced the Vite template CSS entirely</span></span>
<span class="line"><span>- Imported Tailwind via @import "tailwindcss"</span></span>
<span class="line"><span>- Defined 4 custom @keyframes:</span></span>
<span class="line"><span>- cell-pop — scale + fade animation for marks appearing</span></span>
<span class="line"><span>- glow — pulsing box-shadow for winning cells</span></span>
<span class="line"><span>- fade-in — slide-up + fade for result banners</span></span>
<span class="line"><span>- shimmer — (available for future use)</span></span>
<span class="line"><span>- Mapped keyframes to utility classes (.cell-pop, .cell-glow, .fade-in)</span></span>
<span class="line"><span>4. Game Logic — src/App.tsx</span></span>
<span class="line"><span>- Win detection — checkWinner() iterates 8 possible lines (3 rows, 3 cols, 2 diagonals)</span></span>
<span class="line"><span>- Draw detection — isDraw() checks if all 9 cells are filled</span></span>
<span class="line"><span>- AI (minimax with alpha-beta pruning) — getBestMove() evaluates all possible moves recursively, making the computer unbeatable</span></span>
<span class="line"><span>- Game state — board (9 cells), xIsNext, mode (2p / ai), status (playing / won / draw), winningLine, thinking flag</span></span>
<span class="line"><span>- AI move trigger — useEffect fires on AI's turn with a 400ms delay for natural feel</span></span>
<span class="line"><span>- Components — CellComponent renders each cell with SVG X/O, hover states, and winning glow</span></span>
<span class="line"><span>5. UI Design</span></span>
<span class="line"><span>- Gradient background (slate-100 → slate-200), centered layout</span></span>
<span class="line"><span>- Mode toggle buttons (pill-shaped, indigo active state)</span></span>
<span class="line"><span>- Turn indicator with animated dots during AI thinking</span></span>
<span class="line"><span>- 3×3 grid with rounded cells, shadow, hover scale effect</span></span>
<span class="line"><span>- X in indigo, O in rose/red</span></span>
<span class="line"><span>- Winning cells get a pulsing glow animation</span></span>
<span class="line"><span>- Result banner with fade-in animation</span></span>
<span class="line"><span>- "New Game" button after game ends, "Reset" button during play</span></span>
<span class="line"><span>6. Verification</span></span>
<span class="line"><span>- npx tsc --noEmit — zero TypeScript errors</span></span>
<span class="line"><span>- npm run dev — Vite dev server started successfully on http://localhost:5173/</span></span></code></pre>
<p>Functional, no issues, no bugs.</p>
<h2 id="second-test-a-real-app">Second test: a real app</h2>
<p>That’ll be the topic of the next article.</p>
<p>Until then, patience.</p>
<p>See you next time,</p>
<p>Adem.</p>
]]></content:encoded></item>
<item><title>Monitoring your Homelab k3s</title><link>https://adem.build/posts/monitoring-your-homelab-k3s</link><guid isPermaLink="true">https://adem.build/posts/monitoring-your-homelab-k3s</guid><pubDate>Thu, 09 Apr 2026 00:00:00 GMT</pubDate><dc:creator>Adem Usta</dc:creator><description>Monitoring a Raspberry Pi k3s homelab with Prometheus and Grafana (kube-prometheus via Helm), then reaching it from anywhere with Tailscale and Cloudflare Tunnel.</description><category>kubernetes</category><category>homelab</category><category>k3s</category><category>hardware</category><category>software</category><category>raspberry-pi</category><category>grafana</category><category>monitoring</category><category>tailscale</category><content:encoded><![CDATA[<h2 id="flashback">Flashback</h2>
<p>The k3s homelab is ready, clean and fully functional.</p>
<p>If you landed on this article without any context, I’d suggest checking out the previous one first: <a href="https://adem.build/posts/build-homelab-rpis-k3s">Building your homelab with RPis</a></p>
<p><img src="https://adem.build/articles/6/wait.gif" alt="Waiting" loading="lazy" decoding="async"></p>
<p>If you’re reading this line, I think you’re all set to keep going! Let’s go.</p>
<h2 id="why-how-where">Why, how, where?</h2>
<p>Right now, we have zero visibility into the homelab, unless we connect to it via k9s, or worse, SSH into each node manually to check on hardware health.</p>
<p>Obviously, that’s not gonna fly. We need to set up a few nice things to make our lives easier.</p>
<p>Let’s start by laying out what we want:</p>
<ul>
<li>Visibility on the hardware side (CPU, memory, disk, and network usage) -&gt; hardware observability.</li>
<li>The ability to access it from outside our local network, while keeping a reasonable level of security.</li>
</ul>
<p>Let’s dig into each of these.</p>
<h2 id="observability">Observability</h2>
<p>No need to reinvent the wheel here. I already know what I want, given how many times I’ve set this up on client engagements. The prometheus - grafana stack. A timeless classic, it just works.</p>
<p><img src="https://adem.build/articles/6/prometheus-grafana.webp" alt="Prometheus Grafana" loading="lazy" decoding="async"></p>
<p>To put it simply: it’s a classic stack that lets you:</p>
<ul>
<li>collect metrics (whatever they are) -&gt; Prometheus</li>
<li>have a clean and efficient UI to do whatever you want with them (dashboards, aggregations, etc) -&gt; Grafana.</li>
</ul>
<p>Once again, no reinventing the wheel here – we’ll use <code>kube-prometheus-stack</code> to deploy the whole thing.</p>
<p>Pretty straightforward, we’ll use the Helm package manager, which lets you install multiple services in one shot.</p>
<p>Here’s a quick screenshot of the interface, with a pre-built dashboard for hardware metrics:</p>
<p><img src="https://adem.build/articles/6/grafana-dashboard.png" alt="Grafana dashboard" loading="lazy" decoding="async"></p>
<p>Here we can see an overview of what’s happening on the cluster, specifically on one rpi (the control plane here).</p>
<p>Not much going on… for now (which is totally normal, relax).</p>
<p>Nothing too crazy, and we already have direct access to hardware data.</p>
<p><strong>Note</strong>: this stack isn’t just for pulling hardware metrics. You can plug in other data sources:</p>
<ul>
<li>Loki -&gt; to ship container logs into Grafana</li>
<li>Custom metrics -&gt; you can define metrics directly in your code (meaning in your apps) and visualize them in Grafana.</li>
</ul>
<p>You can also push Grafana further: if you want to get alerted on anomalies, you can hook it up to external services (Slack, Discord, you name it).</p>
<p>This opens up a lot of room for improvement and makes maintenance way easier.</p>
<p>Like I said in the previous article: we don’t do things halfway.</p>
<h2 id="accessibility">Accessibility</h2>
<p>Alright, this is all great, but if I’m not home, I have zero visibility and can’t access anything.</p>
<p>A real shut-in of a project.</p>
<p><img src="https://adem.build/articles/6/confine-en.gif" alt="Stuck at home" loading="lazy" decoding="async"></p>
<p>To solve this, we need to properly frame the problem before we start breaking things.</p>
<p>We want two distinct things:</p>
<ul>
<li>access from outside to tools / apps, but only us (private network basically)</li>
<li>access to apps from the internet, fully public (no network-level restrictions)</li>
</ul>
<p>For the first one, I’ll use a tool I discovered at Boxy (RIP…) -&gt; Tailscale.</p>
<h3 id="tailscale-what-is-that-now">Tailscale, what is that now?</h3>
<p><img src="https://adem.build/articles/6/tailscale.webp" alt="Tailscale" loading="lazy" decoding="async"></p>
<p>Simply put, it’s a SaaS that lets you create a virtual private network between machines that aren’t physically in the same place, on the same network. It’s built on Wireguard, among other things (you know, the thing powering that VPN you bought to… watch anime on Netflix Japan).</p>
<p>Basically, Tailscale lets you connect your machines together, and define within your private network who has access to what. Which is exactly what we want!</p>
<p>You create your Tailscale account (free), register your devices (iPhone, NAS, personal Mac, etc) and you can access exposed services between each machine. Nice.</p>
<h4 id="and-how-does-it-work-in-your-homelab">And how does it work in your homelab?</h4>
<p>Pretty simple. We’ll set up the homelab at a few levels.</p>
<p>First, we want to be able to access our cluster via kubectl (k9s TUI for us).</p>
<p>Simple solution -&gt; install tailscale on the control plane, it joins our VPN and is therefore reachable from my Mac, for example. Side note: you just need to update the IP in your kubeconfig to point to the control plane’s IP in the VPN for it to work.</p>
<p>For k9s, done.</p>
<p>For our services, we’ll take a different approach.</p>
<p>Take the Grafana dashboard as an example. It’s reachable via a cluster IP, so you just need to be on the local network to access it.</p>
<p>To access it through the Tailscale VPN, we need to:</p>
<ul>
<li>create a Tailscale OAuth client</li>
<li>install the tailscale-operator with the right OAuth credentials</li>
<li>define a Tailscale ingress to serve our app inside the Tailscale VPN</li>
</ul>
<p>Quick example for reference:</p>
<p>Our sample application:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="yaml"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">apiVersion</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">v1</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">kind</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">Namespace</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">metadata</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">---</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">apiVersion</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">apps/v1</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">kind</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">Deployment</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">metadata</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  namespace</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">spec</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  replicas</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">1</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  selector</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    matchLabels</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">      app</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  template</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    metadata</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">      labels</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        app</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    spec</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">      containers</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">          image</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">tiangolo/uvicorn-gunicorn-fastapi:python3.11-slim</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">          ports</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">            - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">containerPort</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">80</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">---</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">apiVersion</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">v1</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">kind</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">Service</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">metadata</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  namespace</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">spec</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  selector</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    app</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  ports</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">port</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">80</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">      targetPort</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">80</span></span></code></pre>
<p>And the Tailscale ingress:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="yaml"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">apiVersion</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">networking.k8s.io/v1</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">kind</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">Ingress</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">metadata</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  namespace</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">spec</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  ingressClassName</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">tailscale</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  rules</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">http</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        paths</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">          - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">path</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">            pathType</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">Prefix</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">            backend</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">              service</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">                name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">                port</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">                  number</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">80</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  tls</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">hosts</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-app</span></span></code></pre>
<p>And just like that, our app is accessible at <a href="https://my-app.your-tailscale.ts.net">https://my-app.your-tailscale.ts.net</a></p>
<p>Clean, functional, and secured.</p>
<p><strong>Note 1</strong>: Tailscale is still a SaaS, so it’s a trusted third party by definition for the service it provides.</p>
<p>Tailscale uses some pretty smart tech, like NAT traversal to establish direct connections. In that case, nothing goes through their servers.</p>
<p>But, if you ever feel like self-hosting your own Tailscale, you can run <a href="https://github.com/juanfont/headscale">Headscale</a> and rest easy. It’s basically an open source, self-hostable version.</p>
<p><strong>Note 2</strong>: With Tailscale, you can now create Funnels to expose apps to the entire internet. But it’s still in beta, the bandwidth is limited and not really documented (at least I couldn’t find it). So it technically covers the second use case, but it’s not reliable enough yet.</p>
<p>That’s why we went with a more robust solution for public internet access: Cloudflare Tunnel.</p>
<h3 id="cloudflare-yet-another-cloud-thing">Cloudflare, yet another cloud thing?</h3>
<p><img src="https://adem.build/articles/6/cloudflare.webp" alt="Cloudflare" loading="lazy" decoding="async"></p>
<p>Well yes, another cloud thing… but for a good reason!</p>
<p>Say I need an app that should be accessible from the internet (let’s say, the analytics for this blog :)).</p>
<p>With Tailscale we’re limited, we need a stable solution. One option is to open ports on our router and allow inbound traffic from the outside. That works, but we’re not doing that here.</p>
<p>The other option is to create a tunnel between our homelab and the outside world. That’s exactly what we’ll do here, using Cloudflare Edge.</p>
<h4 id="the-setup">The setup</h4>
<p>The simplest approach is to have a domain name on Cloudflare. Otherwise it gets annoying. Let’s stick with that.</p>
<p>The traffic flow looks like this:</p>
<p>Internet -&gt; Cloudflare Edge -&gt; [encrypted tunnel] -&gt; cloudflared pod -&gt; your service</p>
<p>I won’t go into the full setup details, Claude is your friend :)</p>
<p>It’s free, solid, and stays secure.</p>
<h2 id="conclusion">Conclusion</h2>
<p>A slightly more technical article (but not too bad, don’t worry), that sets us up for what’s next: deploying real apps on the cluster, accessible both privately and publicly.</p>
<p>But that, I’ll cover in the next articles.</p>
<p>Spoiler: AI agents, LLMs, GPUs, and many other things.</p>
<p>Until then, take care.</p>
<p>Adem.</p>
]]></content:encoded></item>
<item><title>Build your Homelab with Raspberry Pis</title><link>https://adem.build/posts/build-homelab-rpis-k3s</link><guid isPermaLink="true">https://adem.build/posts/build-homelab-rpis-k3s</guid><pubDate>Sun, 05 Apr 2026 00:00:00 GMT</pubDate><dc:creator>Adem Usta</dc:creator><description>How I turned salvaged Raspberry Pis into a k3s Kubernetes homelab: NVMe boot, OS setup, the k3s cluster and LAN access, from bare boards to a finished rack.</description><category>kubernetes</category><category>homelab</category><category>k3s</category><category>hardware</category><category>software</category><category>raspberry-pi</category><content:encoded><![CDATA[<h2 id="building-a-homelab-with-salvaged-rpis">Building a homelab with salvaged Rpis.</h2>
<h2 id="what-do-you-mean-salvaged-rpis">What do you mean, salvaged Rpis?</h2>
<p>It’s June 2024. With my partner / brother / co-founder at <a href="https://antipodestudios.io/">@antipodestudios</a>, we land a pretty sick gig: building a full-blown app to manage a Nike Football event right in the heart of Paris.</p>
<p>The event featured several football workshops organized around different themes, plus a 1v1 tournament. To handle workshop and player management, we needed to build a web app that would let Nike staff manage the workshops through multiple iPads, and build separate giant-screen displays for scores, leaderboards, and all that good stuff.</p>
<p>We won’t get into the technical nitty-gritty — that’s not what this article is about. But basically, we went with raspberry pi 5s to drive each screen and display event data through a webapp.</p>
<p>If you want to learn more, check out <a href="https://antipodestudios.io/projects/nike-bureau-pleiades/">@Nike Football x Bureau Pleiades x Antipodestudios</a>. Or our instagram <a href="https://www.instagram.com/antipode.studios/">@antipodestudios</a>.</p>
<p>After the event wrapped up (which was a technical win for us), I was left with several rpis 5 on my hands.
Sitting next to some old rpis 4 and 3, they were just gathering dust.</p>
<p>Had to find a way to put them to work.</p>
<h2 id="what-do-you-even-do-with-these-nerd-toys">What do you even do with these nerd toys?</h2>
<p>5 Raspberry pi 5s (8GB), 1 Raspberry 4 (2 GB), and 1 Raspberry pi 3 (not enough GB). A switch. Some microSD cards.
That’s what I had lying around.</p>
<p>What to do with them?</p>
<p>And then, it hit me.</p>
<p><img src="https://adem.build/articles/5/homer.gif" alt="Homer Super Intelligence" loading="lazy" decoding="async"></p>
<p>Throw them on the local network (my home network, duh), ssh in and host your little projects. That’s cool, but tedious. You need a more serious setup.</p>
<p>For client projects, I often set up Coolify on VPS instances to host their apps. It’s fast, efficient, connected to GitHub. But I wanted to host multiple projects without having to worry about which project goes on which machine. I needed a higher level of abstraction.</p>
<p>You get it — we’re here to go the extra mile and set up a full mini infrastructure. So we’re going with a kubernetes solution.</p>
<p>But here’s the catch: rpis aren’t really built for that. k8s is resource-hungry, just running it by itself. That would be a waste.</p>
<p>That’s when I stumbled on a project started by the folks at Rancher — ladies and gentlemen, <a href="https://k3s.io/">k3s</a>.</p>
<p>k3s is a lightweight version of kubernetes, designed to run on low-powered machines, e.g rpis. Perfect candidate for us!</p>
<p>Let’s get to it.</p>
<p><img src="https://adem.build/articles/5/7nains-cartoon.gif" alt="Job done" loading="lazy" decoding="async"></p>
<h2 id="the-hardware">The hardware</h2>
<p>Before diving in, I still asked my buddy <a href="https://claude.ai">Claude</a> what he thought about the project. Fully validated! With one caveat: don’t rely on microSD cards. They tend to burn out over time. We want a stable cluster here.</p>
<p>So here’s the hardware setup we’ll roll with for the project:</p>
<ul>
<li>4x raspberry pi v5 (8GB) -&gt; workers</li>
<li>1x raspberry pi v4 (2GB) -&gt; control plane</li>
<li>1x 2.5” SSD for the control plane</li>
<li>4x nvme SSDs for the workers (128 GB each)</li>
<li>8-port 2.5G switch</li>
<li>Beefy 200W power supply to carry all this beautiful mess (and avoid having 5 separate power adapters for each rpi.)</li>
</ul>
<p>The raspberry pi v5s can accommodate an nvme SSD through an expansion board connected to the PCI port, here’s what it looks like:</p>
<p><img src="https://adem.build/articles/5/rpi-nvme.webp" alt="Raspberry Pi with an NVMe SSD" loading="lazy" decoding="async"></p>
<p>Yeah, alright… this was supposed to be a salvage project… no one’s judging here. We do things right.</p>
<p>We’ve got all the hardware we need to start setting up the software side. Let’s go.</p>
<h2 id="the-software">The software</h2>
<p>The software side breaks down into two parts:</p>
<ul>
<li>pick the right OS, install it on NVME and auto-boot from it</li>
<li>set up k3s on each rpi.</li>
</ul>
<h3 id="the-os">The OS</h3>
<p>Not a ton of options here. We pick from the official OS choices in <a href="https://www.raspberrypi.com/software/">Raspberry PI Imager</a>. The only real candidate for us is Raspberry Pi lite OS (64-bit), no desktop environment.</p>
<p>The setup is pretty straightforward: flash microSD, create a user, add an ssh key (to access the pi directly — useful for setup and debugging), etc.</p>
<p>Flash it, power up the rpi, connect it to the network through the switch, and configure a static DHCP lease <em>(important!)</em> so it keeps the same local IP address (a prerequisite for proper communication under k3s).</p>
<p>To boot from the nvme, you need to copy everything over (<code>dd</code> is your best friend here) to the nvme, then select NVME boot with <code>raspi-config</code>.</p>
<p>Do this for all the raspberry pis. It’s time-consuming but simple. You could script this with Ansible or Terraform, but no need to overthink it here. It would be worth it though if the homelab needs rpi swaps down the road, to avoid having to redo everything by hand.</p>
<h3 id="k3s">K3S</h3>
<p>The fun part — and ironically the simplest. Follow the official docs. Starting with the control plane, obviously.</p>
<p>SSH into it.</p>
<p>I’ll skip the details (if you need help with this part, shoot me an email at <a href="mailto:hello@ademoverflow.com">hello@ademoverflow.com</a>), but basically you install with this beautiful one-liner:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">curl</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -sfL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> https://get.k3s.io</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> |</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> -</span></span></code></pre>
<p>Check that everything looks good, then run <code>sudo kubectl get nodes</code> to see if your control plane shows up.</p>
<p>Grab the k3s authentication token, then do the same on the other rpis:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">curl</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -sfL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> https://get.k3s.io</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> |</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> </span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">K3S_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">https://</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">control-plane-ip</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&gt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">:6443</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> </span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">K3S_TOKEN</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">node-token</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&gt;</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> -</span></span></code></pre>
<p>If all goes well, we’re up and running! Our k3s cluster is live and ready. Well, almost.</p>
<h3 id="accessing-from-the-local-network">Accessing from the local network</h3>
<p>You could access the cluster from the control plane by ssh’ing into it. But that’s annoying and not clean.</p>
<p>So we’ll grab the kube config with the right certificates, and get it on our local machine (your computer, basically).</p>
<p>If I remember right, it’s at <code>/etc/rancher/k3s/k3s.yaml</code>. You might need to swap the loopback IP with the rpi’s actual IP for it to work.</p>
<p>At this point, our k3s cluster is up and ready to take on workloads.</p>
<p><img src="https://adem.build/articles/5/hellfire.gif" alt="Fire" loading="lazy" decoding="async"></p>
<p>A little k9s screenshot, because why not!</p>
<p><img src="https://adem.build/articles/5/k9s.png" alt="Fire" loading="lazy" decoding="async"></p>
<h2 id="software-ok-hardware-ok-now-what">Software OK, Hardware OK, now what?</h2>
<p>Alright, this is all great, but this whole setup isn’t going to stay on my desk. Just look at this mess:</p>
<p><img src="https://adem.build/articles/5/mess.webp" alt="Messy setup" loading="lazy" decoding="async"></p>
<p>Time to design a mini vertical homelab-style server rack (who would’ve guessed!?), all 3D-printed.</p>
<p>I scroll through makerworld, looking for a similar project, but nothing really catches my eye. I do find a decent “tower” base though and kick off the print.</p>
<p>Here’s what it looks like:</p>
<p><img src="https://adem.build/articles/5/tour.webp" alt="Empty tour" loading="lazy" decoding="async"></p>
<p>Time to design the shelves now. We’ve got room, but let’s optimize a bit and fit 2 rpis per shelf.</p>
<p>Here’s the result:</p>
<p><img src="https://adem.build/articles/5/workers.webp" alt="Workers" loading="lazy" decoding="async"></p>
<p>In the end, we’ve got 3 shelves:</p>
<p><img src="https://adem.build/articles/5/all.webp" alt="All racks" loading="lazy" decoding="async"></p>
<p>Assembly, cabling, yada yada…</p>
<p>And we get this beautiful homelab server:</p>
<p><img src="https://adem.build/articles/5/finished.webp" alt="Finished" loading="lazy" decoding="async"></p>
<p>Alright, everything’s good to go! Now, let’s talk about managing it.</p>
<p>But… that’ll be a separate article.</p>
<p>Until then, take care.</p>
<p>Adem.</p>
]]></content:encoded></item>
<item><title>Hey, I&#39;m back.</title><link>https://adem.build/posts/hey-im-back</link><guid isPermaLink="true">https://adem.build/posts/hey-im-back</guid><pubDate>Mon, 30 Mar 2026 00:00:00 GMT</pubDate><dc:creator>Adem Usta</dc:creator><description>10 years of dev, AI shaking everything up, and a comeback. Here&#39;s my journey and what&#39;s changed in this industry.</description><category>im-back</category><category>2026</category><category>update</category><content:encoded><![CDATA[<p>2026, maybe my last year of dev as I knew it 10 years ago.</p>
<h2 id="2016--my-beginnings-in-dev">2016 — My beginnings in dev</h2>
<p>2016, I land in this world through web dev, in a Parisian startup that was the “shazam for celebrities” (Reminiz, later became Context).</p>
<p>Basically, I had to work on an internal app to annotate celebrity photos, store them in a database, which was then used to recognize celebrities on live TV feeds.</p>
<p>It was cool, I learned the basics of web dev on the job, straight up full stack mode. No time to mess around.</p>
<p>Originally, I have a background in robotics and machine learning (anyway, that’s not the point here).</p>
<p>Shoutout to Reminiz’s CTO from that bygone era @Antoine Biard, who trained me in this craft in the best way possible:</p>
<ul>
<li>1 hour of vim every day (yeah I know, the guy was hardcore)</li>
<li>touch typing sessions during the day, to reach 120 wpm and ship code as fast as possible.</li>
</ul>
<p>I’m telling you, it was a crazy time. I was learning something new every single day. I loved it.</p>
<h2 id="doing-everything-learning-everything">Doing everything, learning everything</h2>
<p>Then the years went by, I spent 4 years at that company, where you had to handle everything yourself, between newbies and passionate devs.</p>
<p>The whole stack, from design to code, to infra, monitoring, basically all of that on the back of a 4-person team. You had to learn everything.</p>
<p>When I say everything, I mean everything:</p>
<ul>
<li>creating / managing a k8s cluster (not with today’s tools, we’re talking <code>kops</code>, no managed EKS, no GKE, none of that).</li>
<li>developing the apps (internal and client-facing), architecting them properly</li>
<li>deploying monitoring tools and managing errors, alerts, etc</li>
<li>meeting client SLAs (well we didn’t have that many clients, but enough for it to be a challenge).</li>
</ul>
<p>And we made it. We sweated it out, but we got there. And damn it felt good to learn, to feel alive through your work.</p>
<p>OK… I’m exaggerating a bit but it was truly enriching.</p>
<h2 id="what-came-next">What came next?</h2>
<p>After that glorious era, I switched jobs, looking for new markets, wanting to see new things.</p>
<p>Going freelance, doing your craft for a direct client -&gt; completely different. Less dopamine, but more cash.</p>
<p>That career kept going, and it still does today (thank God). But for over a year now, one thing has changed.</p>
<h2 id="the-elephant-in-the-room">The elephant in the room</h2>
<p><img src="https://adem.build/articles/4/elephant-room.jpg" alt="The elephant in the room" loading="lazy" decoding="async"></p>
<p>Let’s talk about the elephant in the room: genAI. Not Kling or Nanobanana (nobody cares about that here), but coding agents. BOOM.</p>
<p>We won’t go through the whole history, but basically we went through several stages:</p>
<ul>
<li>Github Copilot -&gt; garbage, janky autocomplete, sometimes funny (go try typing “Hey baby, wanna see my “ in copilot and wait for the autocomplete. (It’s probably been fixed, don’t try it)).</li>
<li>Cursor and other early AI-assisted IDEs -&gt; first decent results, features were shipping week after week, but it still wasn’t magic.</li>
</ul>
<p>And then…</p>
<p><img src="https://adem.build/articles/4/claude-code.jpg" alt="Claude Code" loading="lazy" decoding="async"></p>
<p>Sweet Jesus (relax, I’m French, it’s a cultural thing), what magic! This tool was a unanimous hit among my colleagues and friends after a weekend of testing.</p>
<p>The thing ships code (oh it generates it alright, the 120 wpm are useless now).</p>
<p>If you give it a solid foundation, you (almost, calm down) don’t need to type code anymore. You express a request, and the agents execute. Fascinating. Terrifying.</p>
<h2 id="where-does-that-leave-us">Where does that leave us?</h2>
<p>And there, as a software engineer, you start asking yourself a lot of questions about your role, your career, and the future of this profession.</p>
<p>So yes, we have some semblance of increased productivity, because it’s physically impossible to type code as fast as these agents generate tokens.</p>
<p>But, if you take your craft seriously, you review everything. Absolutely everything. Even if you have tests.</p>
<p>Now, I’m not saying I do it every time (cognitive overload) but you have to, to avoid surprises and especially to be able to understand and explain what was implemented and how.</p>
<p>So this isn’t an article about “for or against coding agents”, it’s not 2025 anymore. The answer to that question is crystal clear -&gt; you can’t be against it. The industry won’t let you.</p>
<p>And so… the backlash, and this is the key point of this comeback: desire, passion.</p>
<p>Many developers I know are in this spot: not knowing if they love this job anymore, or at least if they still love it in its current form.</p>
<p>If we go back to my 2016 experience, the hours of grinding, learning, reading docs, binging hours of YouTube tutorials (shoutout to the Indian devs for the content) to acquire skills and be able to use them the next day at work…</p>
<p>That era is sadly over, I believe.</p>
<p>If you’re reading this and you’re just starting out in this field, don’t hesitate to use AI to learn faster, but don’t fall into the trap of Plan -&gt; Approve without at least trying to understand what’s happening.</p>
<h2 id="the-comeback">The comeback</h2>
<p>After that terrible old man lecture, let’s get to the title of this post: my comeback.</p>
<p>Well.. my blog only had 3 posts before this one, but they date back to 2021… I had to come back.</p>
<p>Why now?</p>
<p>Because I feel like I have the time to transfer my knowledge, my projects and my experiences. 2026, Claude Code and I’ll tell you what I told it to build.</p>
<p>Next article: a project that’s already done and working, which will serve as the foundation for the next ones: a small kubernetes cluster with raspberry pis.</p>
<hr>
<p>See you soon,</p>
<p>Adem.</p>
]]></content:encoded></item>
<item><title>Git flow workflow simply explained</title><link>https://adem.build/posts/git-flow-tutorial</link><guid isPermaLink="true">https://adem.build/posts/git-flow-tutorial</guid><pubDate>Sun, 13 Jun 2021 00:00:00 GMT</pubDate><dc:creator>Adem Usta</dc:creator><description>Git flow simply explained: feature, release and hotfix branches step by step, the git-flow CLI that automates them, and consistent changelogs between two tags.</description><category>git</category><category>software-development</category><category>workflow</category><content:encoded><![CDATA[<h2 id="what-is-git-flow-and-why-implement-it-">What is Git Flow and why implement it ?</h2>
<p>Working on a repository with several contributors may be hard and confusing.</p>
<p>At least if there is not any sealed workflow regarding the usage of git.</p>
<p>That’s why some people (I honestly don’t know who) have designed a solid workflow to enhance the usage of git.</p>
<p>This workflow is simply named <em>git flow</em>. Let’s talk about that !</p>
<h2 id="disclaimer">Disclaimer</h2>
<p>In this tutorial there may be some changes compared to the original git flow workflow.</p>
<p>The key ideas are kept, feel free to compare with other articles or tutorials on the web.</p>
<p>I also try to add some enhancements regarding commit format in order to create changelogs easily.</p>
<h2 id="the-git-flow-workflow">The <code>git flow</code> workflow</h2>
<h3 id="key-ideas">Key ideas</h3>
<p>One of the key ideas of the workflow is to keep a single branch for production releases, and another branch for adding new features to the project:</p>
<ul>
<li><code>master</code> : branch for releases (some people name that branch <code>main</code>).</li>
<li><code>develop</code> : branch that hosts new features between two releases.</li>
</ul>
<h3 id="developing-a-new-feature">Developing a new feature</h3>
<p>Let’s say you want to develop a new feature, the idea is to follow these few steps:</p>
<ul>
<li>
<p>From the <code>develop</code> branch, create a new branch:</p>
<p><code>git checkout -b feature/my-awesome-feature</code></p>
</li>
<li>
<p>Do your magic with the code, add as many commits as you want.</p>
</li>
<li>
<p>Once the code is ready to be tested and reviewed by your colleagues, open a Merge / Pull Request.</p>
</li>
<li>
<p>Don’t hesitate to rebase your branch against <code>origin/develop</code> to be sure that you have the latest changes.</p>
<p>To do a rebase locally:</p>
<p><code>git fetch -ap &amp;&amp; git rebase origin/develop</code></p>
<p>After that, you need to push force to the remote branch because of the rebase:</p>
<p><code>git push -f</code></p>
</li>
<li>
<p>Once your code is tested, has passed your CI pipeline and approved by your pairs, you can merge <code>feature/my-awesome-feature</code> to <code>develop</code>.</p>
<p>Do this step in your Git hosting service web application.</p>
<p><strong>Note</strong>: In order to keep a nice commit historic on <code>develop</code>, be sure to select <code>squash and merge</code> when merging your branch: there will be a single commit on <code>develop</code>.</p>
<p>You will be asked for a merge commit message:</p>
<p>Ideally, you can use this well known format for this message: <code>type(scope): my commit message</code>.</p>
<p>Where:</p>
<ul>
<li><code>type</code> could be any of: <code>feat,fix,docs,breaking,build,ci,misc,refactor,style,test</code></li>
<li><code>scope</code> could be any word.</li>
</ul>
<p>Other formats exist and could be used.</p>
<p>The idea is to be able to parse commits messages to create a clear ChangeLog between releases.</p>
<p>But it’s not part of the git flow workflow. So do what you want regarding your commit messages.</p>
</li>
</ul>
<h3 id="preparing-a-new-release">Preparing a new release</h3>
<p>Now, let’s say you have some cool features / fixes ready to be deployed on production, the idea is to follow these few steps:</p>
<ul>
<li>
<p>Create a branch <code>release/vx.x.x</code> from <code>develop</code></p>
</li>
<li>
<p>If you have any integration tests, use this branch to validate your release candidate</p>
</li>
<li>
<p>If there are some bugs, you can add commits to fix them on this branch.</p>
</li>
<li>
<p>Once you’re done testing, you are ready to merge it to <code>master</code>.</p>
<p><strong>Note</strong>: in the traditionnal git flow workflow, a release branch merged to <code>master</code> is meant to be squashed before merged.
But as I said in the disclaimer, I decided to modify a little bit the workflow.
The idea is to keep commits from develop when merging to master. Merge commit could be as simple as <code>vX.X.X</code> . Keep those well formatted commits to master will help you create changelogs. We’ll see that at the end of the article.</p>
</li>
<li>
<p>Do a new release (with a new tag), or edit your current major release with a new tag and describe the changes in the release description.</p>
</li>
<li>
<p>Do not forget to rebase <code>develop</code> to <code>master</code> to keep the same historic. <code>develop</code> should be aware of what’s in <code>master</code>. Always ahead.</p>
</li>
</ul>
<h3 id="developing-hot-fixes">Developing hot fixes</h3>
<p>Sometimes (not to say all the time …), there are bugs in a fresh release.</p>
<p>Some bugs can wait for the next release to be patched, but some cannot.</p>
<p>They must be patched as fast as possible. Git flow has planned this case, follow these steps:</p>
<ul>
<li>
<p>Create a branch from <code>master</code>, called <code>hotfix/my-hotfix</code></p>
</li>
<li>
<p>Add your changes</p>
</li>
<li>
<p>Test it to check that the hotfix is:</p>
<ul>
<li>patching the bug</li>
<li>not causing any other part of the app(s) to crash</li>
<li>not causing any regression</li>
</ul>
</li>
<li>
<p>Once the hotfix is tested and approved by the team, merge to <code>master</code> with a squash and merge.
The commit message should include the hotfix message, and the next release version.</p>
<p>Example: <code>hotfix(scope): fix critical vx.x.x</code></p>
</li>
<li>
<p>Add a new release, or edit the current release with a new tag.</p>
</li>
<li>
<p>Rebase <code>develop</code> to <code>master</code> to keep it always at the same level.</p>
</li>
</ul>
<h3 id="important-notes">Important notes</h3>
<ul>
<li>
<p>Each time there is a change in <code>master</code>, do not forget to rebase <code>develop</code> to <code>master</code>:</p>
<p><code>git fetch -ap &amp;&amp; git rebase origin/master</code> and <code>git push -f origin/develop</code></p>
</li>
<li>
<p>Same thing for the feature branches, when <code>develop</code> has changed:</p>
<p><code>git fetch -ap &amp;&amp; git rebase origin/develop</code> and <code>git push -f origin/feature/my-awesome-feature</code></p>
</li>
</ul>
<h2 id="appendix-1-git-flow--a-package-to-facilitate-the-implementation-of-git-flow-workflow">Appendix 1: <code>git flow</code> , a package to facilitate the implementation of git flow workflow</h2>
<p>When reading the explanation of git flow, I can understand that you think this workflow is hard to maintain in the long run.</p>
<p>That’s why a package has been released to automate the workflow: <code>git flow</code>.</p>
<p>I personnaly don’t use it because I’m used to work with this workflow for a while now.</p>
<p>But if you want to facilitate the use of the workflow in your team, you can check this repository <a href="https://github.com/nvie/gitflow">https://github.com/nvie/gitflow</a> and use it !</p>
<h2 id="appendix-2-create-consistent-changelogs-between-two-tags">Appendix 2: Create consistent changelogs between two tags</h2>
<p>In this article, some enhancements have been made from the traditional git flow workflow.</p>
<p>The main one deals with git commit messages.</p>
<p>If you follow those few guidelines, then you can create changelogs easily when releasing a new version of your app.</p>
<p>To do so, you need to install a small binary called <code>git-chlog</code>.</p>
<p>You can find it there <a href="https://github.com/git-chglog/git-chglog">https://github.com/git-chglog/git-chglog</a></p>
<p>I’m not going to do a full tutorial on how to use it, so be free to check its documentation and profit from it.</p>
<p>I’ll just show you how it can be used in our case.</p>
<p>Let’s say you have a new version of your app: <code>v1.1.0</code> .</p>
<p>The tag before was <code>v1.0.7</code>. You want to create a changelog between those two tags.</p>
<p>If you follow our advices regarding messages format, you can create a simple changelog by running: <code>git-chlog v1.1.0..</code></p>
<p>Also, you can create a full changelog of you app since the beginning: <code>git-chlog</code>.</p>
<p><strong>As simple as that !</strong></p>
<h2 id="conclusions">Conclusions</h2>
<p>In this article I wanted to show how a clean git workflow can help you and your team optimize your time and help you focus on what’s important.</p>
<p>I hope this article / tutorial will help you guys understand how git flow works and how to implement it on your repositories !</p>
<p>I also want to share with you some cool articles / videos about git flow:</p>
<ul>
<li><a href="https://www.toptal.com/gitflow/enhanced-git-flow-explained">Toptal: enhanced git flow explained</a></li>
<li><a href="https://www.youtube.com/watch?v=1SXpE08hvGs">The gitflow workflow - in less than 5 mins (from the youtuber <code>DevChild</code>)</a></li>
</ul>
<p>See you soon,</p>
<p>Adem.</p>
]]></content:encoded></item>
<item><title>How to deploy your FastAPI application on AWS Lambda with Serverless</title><link>https://adem.build/posts/tutorial-fastapi-aws-lambda-serverless</link><guid isPermaLink="true">https://adem.build/posts/tutorial-fastapi-aws-lambda-serverless</guid><pubDate>Sat, 10 Apr 2021 00:00:00 GMT</pubDate><dc:creator>Adem Usta</dc:creator><description>Step-by-step tutorial: deploy a FastAPI app on AWS Lambda with the Serverless Framework and Mangum, test it locally, then serve it on your own domain.</description><category>fastapi</category><category>tutorial</category><category>lambda</category><category>serverless</category><content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>FastAPI, the python package created by <a href="https://github.com/tiangolo">Sebastián Ramírez</a>, is a great framework that allows you to create REST APIs.</p>
<p>It’s quite straightforward to take the control of it.</p>
<p>If you didn’t know this package, I wisely invite you to visit the <a href="https://fastapi.tiangolo.com/">official documentation</a> and create your APIs with it !</p>
<p>If you came accross this article, you are probably looking for a way to deploy your FastAPI application on AWS Lambda, the Amazon serverless ecosystem.</p>
<p>Good pick ! We will try to explain to you how to proceed.</p>
<h2 id="tutorial">Tutorial</h2>
<h3 id="step-1---create-a-simple-fastapi-app">Step 1 - Create a simple FastAPI app</h3>
<p>By following the official guide, we can code an application with a few lines of code.</p>
<p>Let’s create a file <code>main.py</code> that declares the app and a <code>/hello</code> route:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> fastapi </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> FastAPI</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">app </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> FastAPI(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70">title</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"MyAwesomeApp"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">@app.get</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"/hello"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> hello_world</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">():</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"message"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"Hello World"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
<h3 id="step-2---test-your-application-locally">Step 2 - Test your application locally</h3>
<p>To test the app locally, let’s create a virtual environment and install what’s inside the <code>requirements.txt</code> file:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">fastapi</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">=0.63.0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">uvicorn</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">=0.13.4</span></span></code></pre>
<p>Some commands to do that:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">python3.8</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -m</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> venv</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> .virtualenv</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">   # Creates a virtual environment</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">source</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> .virtualenv/bin/activate</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"> # Activates it in the current shell</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">pip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> install</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> requirements.txt</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"> # Installs python packages</span></span></code></pre>
<p>Deploy your application locally:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">uvicorn</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> main:app</span></span></code></pre>
<p>You should see some logs like these:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="plaintext"><code><span class="line"><span>INFO:     Started server process [87999]</span></span>
<span class="line"><span>INFO:     Waiting for application startup.</span></span>
<span class="line"><span>INFO:     Application startup complete.</span></span>
<span class="line"><span>INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)</span></span></code></pre>
<p>Your app is available here: <a href="http://127.0.0.1:8000">http://127.0.0.1:8000</a>.</p>
<p>You can check the autogenerated documentation here: <a href="http://127.0.0.1:8000/docs">http://127.0.0.1:8000/docs</a></p>
<p>A small overview:</p>
<p><img src="https://adem.build/articles/2/1.webp" alt="FastAPI autogenerated documentation" loading="lazy" decoding="async"></p>
<p>Is your app fully functionnal locally ? Perfect, we are ready for the rest.</p>
<h3 id="step-3---adapt-your-fastapi-application-with-the-aws-lambda-ecosystem">Step 3 - Adapt your FastAPI application with the AWS Lambda ecosystem</h3>
<p>To make your application compatible with Lambda, we will use a small package called <a href="https://github.com/jordaneremieff/mangum">Mangum</a>.</p>
<p>Add it in your <code>requirements.txt</code> file, it will be essential in the next steps.</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">fastapi</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">=0.63.0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">uvicorn</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">=0.13.4</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">mangum</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">=0.11.0</span></span></code></pre>
<p>We will modify <code>main.py</code> to wrap up the <code>app</code> object:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> fastapi </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> FastAPI</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> mangum </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Mangum</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">app </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> FastAPI(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70">title</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"MyAwesomeApp"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">@app.get</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"/hello"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> hello_world</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">():</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"message"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"Hello World"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">handler </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Mangum(app)</span></span></code></pre>
<p><strong>Note</strong>:</p>
<p>At this point, the app is ready and will be functionnal with Lambda, but one of the features won’t be accessible: the autogenerated documentation.</p>
<p>Indeed, when deployed, the application will be accessible with an endpoint that has this shape: <code>https://XXXXXXX.execute-api.eu-west-1.amazonaws.com/stage</code>.</p>
<p>Out, to generate the documentation, FastAPI needs, by default, to be served through a domain, not a path.</p>
<p>To solve this problem, we will modify the python code:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> os</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> fastapi </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> FastAPI</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> mangum </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Mangum</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">stage </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> os.environ.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">'STAGE'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">openapi_prefix </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"/</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">stage</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> stage </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">else</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "/"</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">app </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> FastAPI(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70">title</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"MyAwesomeApp"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70">openapi_prefix</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">openapi_prefix) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Here is the magic</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">@app.get</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"/hello"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> hello_world</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">():</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"message"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"Hello World"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">handler </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Mangum(app)</span></span></code></pre>
<p><strong>In summary</strong>:</p>
<p>We changed the path that is used to serve <code>openapi.json</code>, that will allow the documentation page to be generated without any issue.</p>
<p>At this point, your python code is ready ! Let’s deploy that with <code>serverless</code>.</p>
<h3 id="step-4---use-serverless-to-deploy-the-application">Step 4 - Use <code>serverless</code> to deploy the application</h3>
<p>You need to install the <code>serverless</code> CLI and configure it with your AWS credentials.</p>
<p>Install the CLI with <code>npm</code>:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">npm</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> install</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -g</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> serverless</span></span></code></pre>
<p>It’s a tool that facilitate the deployment of applications and services in the cloud, by describing them in a YAML file.</p>
<p>It’s compatible with AWS Lambda, and more generally with AWS Cloudformation.</p>
<p>For more info about this tool, go check <a href="serverless.com">serverless.com</a>.</p>
<p>Configure <code>serverless</code> with your credentials:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">serverless</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> config</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> credentials</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --provider</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> aws</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">YOUR_KE</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&gt;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">YOUR_SECRET_KE</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&gt;</span></span></code></pre>
<p>Let’s create a <code>serverless.yaml</code> file that contains all the specifications of our app:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="yaml"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">service</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-awesome-app</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">package</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  individually</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">true</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">provider</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">aws</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  runtime</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">python3.8</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  region</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">eu-west-1</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  stage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${opt:stage, "dev"}</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">plugins</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">serverless-python-requirements</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">custom</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  pythonRequirements</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    dockerizePip</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">true</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    layer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">      name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">my-awesome-app-layer</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">      description</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">My awesome app layer</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">      compatibleRuntimes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">python3.8</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">functions</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  app</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    package</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">      include</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"main.py"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">      exclude</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"requirements.txt"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"package.json"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"package-lock.json"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">".serverless/**"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">".virtualenv/**"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"node_modules/**"</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    handler</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">main.handler</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">      STAGE</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${self:provider.stage}</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    layers</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - { </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">Ref</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">PythonRequirementsLambdaLayer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> }</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    events</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">http</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">          method</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">any</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">          path</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/{proxy+}</span></span></code></pre>
<p>And, at the same level, create a <code>package.json</code> file:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="json"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "name"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"my-awesome-app"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "version"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"1.0.0"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "author"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"&lt;YOUR_NAME&gt;"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "dependencies"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: {</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">    "serverless-python-requirements"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"^5.0.1"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
<p>This file will help us install some JavaScript plugins that are used in our YAML file.</p>
<p>Install these plugins:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">npm</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> install</span></span></code></pre>
<p>And, let’s deploy our application !</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">sls</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> deploy</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --stage</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> staging</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"> # "stage" indicates which stage you are deploying. It could be anything.</span></span></code></pre>
<p><code>serverless</code> does its magic.</p>
<p>After some minutes (no more than 5 usually), you will see some logs like these:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Service</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Information</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">service:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> my-awesome-app</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">stage:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> staging</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">region:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> eu-west-1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">stack:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> my-awesome-app-staging</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">resources:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 12</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">api</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> keys:</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">  None</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">endpoints:</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">  ANY</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> -</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">ENDPOINT</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> HER</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">E</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&gt;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">functions:</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">  app:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> my-awesome-app-staging-app</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">...</span></span></code></pre>
<p>By checking these logs, you will find your application endpoint !</p>
<p>Here, it’s <code>https://XXXXXXXXX.execute-api.eu-west-1.amazonaws.com/staging/</code> (XXXXXX is usually a mix of numbers and letters).</p>
<p>If you visit <code>https://XXXXXXXXX.execute-api.eu-west-1.amazonaws.com/staging/docs</code>, you will see your application documentation !</p>
<p>To update your app (e.g add a new route, etc.), you just need to modify your code, and deploy again:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">sls</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> deploy</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --stage</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> staging</span></span></code></pre>
<p>To completely delete your application from the cloud:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">sls</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> remove</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --stage</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> staging</span></span></code></pre>
<p>You now have all the information to create FastAPI apps and host them on AWS Lambda !</p>
<h3 id="bonus-step-5---use-your-own-domain-with-your-app">[Bonus] Step 5 - Use your own domain with your app</h3>
<p>If you want your application to be available through your own domain, you’re a few steps from doing it !</p>
<p>Some prerequisites are necessary:</p>
<ul>
<li>a domain name hosted on AWS Route53</li>
<li>a certificate linked to this domain (for HTTPS), generated with AWS Certificate Manager (if you don’t have it, create a new one and host it on the AWS default region <code>us-east-1</code>, as it is considered as global for certificates).</li>
</ul>
<p>We will use a plugin to make our life easier: <code>serverless-domain-manager</code>.</p>
<p>Install it:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">npm</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> serverless-domain-manager</span></span></code></pre>
<p>Add it in the list of plugins, in your <code>serverless.yaml</code> file:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="yaml"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">plugins</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">serverless-python-requirements</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">serverless-domain-manager</span></span></code></pre>
<p>We need to configure the plugin, so add these few lines in the <strong>custom</strong> section of <code>serverless.yaml</code>:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="yaml"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">custom</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  customDomain</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    domainName</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">YOUR_DOMAIN_HERE</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    stage</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${self:provider.stage}</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    certificateArn</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">YOUR_CERTIFICATE_ARN_HERE</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    endpointType</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"edge"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    securityPolicy</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">tls_1_2</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    apiType</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">rest</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    autoDomain</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">true</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    autoDomainWaitFor</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">120</span></span></code></pre>
<p>(Don’t forget to fill the fields with your own values).</p>
<p>Once it’s done, deploy:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">sls</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> deploy</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --stage</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> staging</span></span></code></pre>
<p>After a few minutes, we can access to our app with our own domain !</p>
<p>… Really ?</p>
<p>Try to access to the documentation page located at <code>/docs</code>, you see the trap ?</p>
<p><img src="https://adem.build/articles/2/2.webp" alt="FastAPI documentation error" loading="lazy" decoding="async"></p>
<p>This error occurs because of what we did previously to access the documentation page with the lambda default endpoint.</p>
<p>We just need to rollback:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="python"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">app </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> FastAPI(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70">title</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"MyAwesomeApp"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70">openapi_prefix</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">openapi_prefix) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Change this</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">app </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> FastAPI(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70">title</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"MyAwesomeApp"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># With this</span></span></code></pre>
<p>Deploy again.</p>
<p><img src="https://adem.build/articles/2/tada.webp" alt="Tada GIF" loading="lazy" decoding="async"></p>
<p>You now have your application running on AWS Lambda, with your own domain !</p>
<h2 id="conclusion">Conclusion</h2>
<p>Through this article written in the form of a tutorial, you are now capable of creating a FastAPI application, test it locallly and deploy it on the cloud !</p>
<p>If you have any questions, feel free to contact me. Don’t hesitate !</p>
<p>See you soon,</p>
<p>Adem.</p>
]]></content:encoded></item>
<item><title>Merge vs rebase strategies with git</title><link>https://adem.build/posts/git-merge-vs-rebase</link><guid isPermaLink="true">https://adem.build/posts/git-merge-vs-rebase</guid><pubDate>Sat, 01 Aug 2020 00:00:00 GMT</pubDate><dc:creator>Adem Usta</dc:creator><description>Merge, or rebase before merging? Both git strategies compared on a real multi-developer case, with commit graphs, force push caveats and rebasing from GitHub.</description><category>git</category><category>software-development</category><category>workflow</category><content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>One of the best practices as a developer is to use code versioning software to maintain their project.</p>
<p>In this context, the open-source software <a href="https://git-scm.com/">git</a> helps the developers a lot.</p>
<p>It allows the developers to version their application source code, so they can keep old versions of their software.</p>
<p>It also allows several developers to work on the same project at the same time, well at least in theory if git is well used.</p>
<p>I will expose in this article a classical situation where an application is enhanced with new features by several developers.</p>
<p>Here is the context:</p>
<ul>
<li>a single project which its source code hosted on <a href="https://github.com">GitHub</a>.</li>
<li>several developers are working on the same file, and potentially are modifying the same part of it.</li>
</ul>
<h2 id="context">Context</h2>
<p>The main branch of the project is named <strong>master</strong>, as in a lot of git projects.</p>
<p>The branch <strong>master</strong> already contains some commits:</p>
<p><img src="https://adem.build/articles/1/1.webp" alt="GitHub network graph: the master branch and its first commits" loading="lazy" decoding="async"></p>
<h2 id="source-code-modified-by-several-developers">Source code modified by several developers</h2>
<p>Let’s say there are two developers A and B. They want to add some new features in the project.</p>
<p>The best practice is to create a new branch for each feature, and add their feature into. I will name those branchs <em>branch-A</em> and <em>branch-B</em>.</p>
<p>When they’re done, A and B will want to merge their branchs into <strong>master</strong>, to let their new feature be on production.</p>
<p>It’s at this moment that developers have to choose between two possibilities: <code>merge</code> or <code>rebase</code>.</p>
<p>Here are the branchs state:</p>
<p><img src="https://adem.build/articles/1/2.webp" alt="GitHub network graph: branch-A and branch-B started from master" loading="lazy" decoding="async"></p>
<p>In the following, I suppose that A will push his changes into <strong>master</strong> first.</p>
<p>He creates a pull-request, and after validation by the team, he merges <em>branch-A</em> into <strong>master</strong>. The schema becomes:</p>
<p><img src="https://adem.build/articles/1/3.webp" alt="GitHub network graph: branch-A merged into master" loading="lazy" decoding="async"></p>
<p>Until there, nothing really fancy.</p>
<p>But when B wants to do the same with his branch, things gets interesting.</p>
<p>As shown in the branchs network, <strong>master</strong> has changed thanks to A, and <em>branch-B</em> does not have these changes.</p>
<p>It’s at this moment that the choice between <code>merge</code> and <code>rebase</code> must be done.</p>
<p>I will experiment the two ways, and see what it implies on the network, potential conflicts, etc.</p>
<h3 id="merge-strategy">Merge strategy</h3>
<p>By choosing a merge strategy, git will naturally take all your branch commits and add them to <strong>master</strong>, here is the result:</p>
<p><img src="https://adem.build/articles/1/4.webp" alt="GitHub network graph: branch-B merged into master with a merge commit" loading="lazy" decoding="async"></p>
<p><strong>Note</strong>: the colors does not represent the same branchs from one image to another, thank you GitHub !</p>
<p><strong>Note 2</strong>: another developer C added a new branch, it will be used to show the rebase strategy.</p>
<p>The graph shows that the branch network is not readable.</p>
<p>Moreover, there only are a small amount of developers !</p>
<p>Imagine with 10 or 20 developers, doing some merge directly …</p>
<p>In this context, I will show how a simple rebase could do the trick and make the network looks more readable.</p>
<h3 id="rebase-strategy">Rebase strategy</h3>
<p>A new developer C is now part of the project.</p>
<p>He has his own branch <em>branch-C</em> in which he’s working on a new feature.</p>
<p>Comes the moment when he wants to push his changes on <strong>master</strong>.</p>
<p>His pull-request gets accepted, he decides to do a rebase before merging.</p>
<p><strong>Note</strong>: to perform a rebase before merging, you can do this either by the CLI in you workstation, or directly on <a href="https://github.com">GitHub</a>.</p>
<p>With the CLI:</p>
<pre class="astro-code astro-code-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> fetch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> &amp;&amp; </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> rebase</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> origin/master</span></span></code></pre>
<p>At this moment, if you have some conflicts with the master branch, you need to resolve them.</p>
<p>Then you need to push force your branch to the remote one.</p>
<p>This (push force) can be problematic in some cases, for example when you are more than one developer working in the same branch.</p>
<p>Else, you can to the rebase before merging in <a href="https://github.com">GitHub</a> directly:</p>
<p><img src="https://adem.build/articles/1/5.webp" alt="GitHub network graph: branch-C rebased and merged from GitHub" loading="lazy" decoding="async"></p>
<p>In this case, github does not show <em>branch-C</em>, but the commits on this one are now in <strong>master</strong>: the last ones are the <em>branch-C</em> ones.</p>
<p>To show what a rebase with the CLI does, I add another <em>branch-D</em> :</p>
<p><img src="https://adem.build/articles/1/6.webp" alt="GitHub network graph: branch-D before the rebase" loading="lazy" decoding="async"></p>
<p>After rebasing + push force, the network looks like:</p>
<p><img src="https://adem.build/articles/1/7.webp" alt="GitHub network graph: branch-D rebased on master after a force push" loading="lazy" decoding="async"></p>
<p>The graph shows what a rebase does here: git moved our branch <em>branch-D</em> at the top of <strong>master</strong>, and then it replays all of our <em>branch-D</em> commits to see if there is any conflicts.</p>
<p>If there is any, you need to resolve them at this moment.</p>
<p>All I have to do is merge the branch with the GitHub interface. The network looks like this:</p>
<p><img src="https://adem.build/articles/1/8.webp" alt="GitHub network graph: branch-D merged into master" loading="lazy" decoding="async"></p>
<p>Here, we see that <em>branch-D</em> (the one in blue, at the top) went up.</p>
<p>The interest of this strategy is to have a network more readable, with <strong>master</strong> that follows a straight line, and merged branchs to be “separated” in the network (each merged branch form a single loop to master, without overlap).</p>
<p>There is a caveat with this strategy: the push force is mandatory.</p>
<p>In the case where there are several developers that are working on the same branch, be sure to pull all your collegues work locally before rebasing and do a push force.</p>
<p>If you don’t do that, you will potentially delete your collegues work.</p>
<h2 id="conclusions">Conclusions</h2>
<p>The <code>merge</code> strategy is straightforward, the workflow is simple:</p>
<ol>
<li>I develop on a new branch our new feature</li>
<li>Once ready, I open a pull-request</li>
<li>Once validated, I merge it</li>
</ol>
<p>But this implies a network not really readable (in my opinion).</p>
<p>Conversely, a <code>rebase</code> implies more discipline:</p>
<ol>
<li>I develop on a new branch a new feature</li>
<li>Once ready, I open a pull-request</li>
<li>Once validated, I do a rebase</li>
<li>I merge the pull-request.</li>
</ol>
<p>The workflow is more complicated, and requires some discipline. But the result is a better branch network.</p>
<p>That’s it for my first article ! If you have any question, please feel free to send me an email !</p>
<p>See you soon,</p>
<p>Adem Usta.</p>
]]></content:encoded></item>
</channel>
</rss>