<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lajancia on Medium]]></title>
        <description><![CDATA[Stories by Lajancia on Medium]]></description>
        <link>https://medium.com/@lajancia?source=rss-e240ff76f50d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mXCTqx_n_rzwhEzv28AbMQ.jpeg</url>
            <title>Stories by Lajancia on Medium</title>
            <link>https://medium.com/@lajancia?source=rss-e240ff76f50d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 08:30:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lajancia/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Server as Code — Provisioning and Auditing My Homelab with Ansible]]></title>
            <link>https://medium.com/@lajancia/server-as-code-provisioning-and-auditing-my-homelab-with-ansible-35ec630bec4f?source=rss-e240ff76f50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/35ec630bec4f</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[server-management]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Lajancia]]></dc:creator>
            <pubDate>Fri, 20 Nov 2026 16:55:28 GMT</pubDate>
            <atom:updated>2026-11-20T16:55:28.570Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kyUuNXt2RYYR8OMTZiE09g.jpeg" /><figcaption>gemini generated image</figcaption></figure><h3>Intro</h3><p>This post documents how I turned the entire state of my homelab server (soominlab.com) into Ansible code. Two goals:</p><ol><li>If I ever move to a new server (cheaper hosting, or AWS), a single ansible-playbook site.yml should bring up the exact same stack — k3s, nodeport-guard, tailscale serve, kube-prometheus-stack, and a weekly security audit.</li><li>Prevent a repeat of a past incident where a hosting provider’s forced shutdown left missing services and an <strong>unexpectedly exposed port</strong> — now enforced by a server-side weekly audit that stays silent unless something is wrong.</li></ol><h3>1. What is Ansible?</h3><p>Ansible is a tool that <strong>declares the desired state of servers as code (YAML) and reconciles the actual state to match</strong>.</p><ul><li>No agent to install, unlike Chef/Puppet — SSH access is enough.</li><li>You don’t write <em>procedures</em> (“run apt install curl”); you write <em>states</em> (“curl must be present”).</li><li>Running the same playbook any number of times yields the same result — <strong>idempotency</strong>. If the state is already correct, nothing changes. That property is the heart of this post.</li></ul><p>Three concepts are enough to get started:</p><p><strong>Inventory : </strong>List of managed servers (inventory/hosts.yml)</p><p><strong>Playbook : </strong>“Apply these roles to this server” (site.yml)</p><p><strong>Role : </strong>A reusable bundle of state (k3s, firewall, monitoring, …)</p><h3>2. Why Ansible — Two Incidents and One Plan</h3><h3>Incident: what a hosting provider’s shutdown left behind</h3><p>In the past, my hosting provider force-shutdown and rebooted the server. Some services came back missing, and a Docker container ended up <strong>exposing an unintended port to the public internet</strong>. A dead service behind an open port is the worst combination.</p><p>Since then I built two layers of defense on this server (covered in a previous post):</p><ul><li><strong>nodeport-guard</strong>: an iptables rule in the mangle table that only allows ports 80/443 from eth0, dropping all k3s NodePorts. Tailscale (100.64.0.0/10) is exempted via RETURN.</li><li><strong>Dual persistence</strong>: the rule must exist in BOTH the live iptables state and /etc/iptables/rules.v4, because the provider’s hypervisor-maintenance reboots wipe the live rules.</li></ul><p>But having defenses is one thing; knowing <strong>they’re alive right now</strong> is another. Eventually, the checks had to be automated too.</p><h3>Plan: moving to a cheaper server</h3><p>The second reason is a future migration. The current setup — k3s, iptables, systemd timers, tailscale, helm — was built by hand. Reproducing it on a new server from memory is <strong>guaranteed to produce omissions</strong> — the incident above was exactly that pattern. With the server state in code, a migration becomes “git clone → inject secrets → run playbook”.</p><blockquote><em>IaC is not a big-company tool. It’s </em>more<em> essential for a solo operator — because memory weathers faster than code.</em></blockquote><h3>3. How I Use It — The Actual Setup</h3><p>The repo layout looks like this (kept private in practice; shown as an example tree):</p><pre>server-ops/<br>├── site.yml              # role application order<br>├── inventory/hosts.yml   # target servers<br>└── roles/<br>    ├── common/           # base packages (Docker intentionally NOT installed)<br>    ├── k3s/              # k3s server install + wait for node Ready<br>    ├── nodeport_guard/   # mangle firewall unit + rules.v4 dual persistence<br>    ├── tailscale/        # install + serve (ArgoCD :8443, Grafana :8444)<br>    ├── monitoring/       # kube-prometheus-stack (helm)<br>    └── weekly_audit/     # weekly security audit (systemd timer)</pre><h3>The control node — where the playbook runs</h3><p>Ansible runs the playbook from a command post (the <strong>control node</strong>) and configures the servers listed in the inventory over SSH. The control node can be a dedicated server or just my laptop; the target servers need no Ansible install — only reachable SSH keys. The control node is the brain; targets are just hands.</p><p>What I chose here:</p><ul><li><strong>Now (one server)</strong>: srv695066 controls itself (ansible_connection: local). Like keeping the remote next to the TV — for a single server, this is the simplest setup.</li><li><strong>On migration (option C)</strong>: SSH into the new server, clone the repo, inject secrets, and run with local mode as-is. If/when several servers need managing (option B), I’d move the control node to a laptop and change the inventory host to an SSH target — the switch cost is one line of inventory.</li></ul><p>A design lesson here: <strong><em>where</em> the code executes is part of the IaC design.</strong> With option C (the target server becomes the command post), the code revives with a single git clone even if the old server dies. With option B (command post separate from targets), the operational workflow survives any server change.</p><h3>Secrets never touch the repo</h3><p>The kube-prometheus-stack values file contains the Grafana admin password. Such files live outside the repo in /root/server-ops-secrets/ (chmod 700) and are referenced by path at run time. Same for the Discord webhook URL. Same rule as “never store PATs in files”: secrets are injected manually.</p><h3>The weekly audit — the server checks itself, and only complains on failure</h3><p>A systemd timer (weekly-audit.timer, Sundays 03:00 UTC, Persistent=true so missed runs after reboots are caught up) runs a script whose checks mirror the past incidents precisely:</p><ol><li><strong>Docker container detection</strong> — every service on this server runs inside k3s (which uses its own containerd), so the healthy Docker container count is <strong>zero</strong>. The Docker daemon is essentially an empty shell; if a container shows up, it came up unintentionally — the incident pattern all over again.</li><li><strong>Guard rule dual check</strong> — both the live mangle rule and the persisted rules.v4 copy. If either disappears after a reboot, it gets caught.</li><li><strong>External NodePort scan</strong> — curling NodePorts 30801 (Grafana) / 32085 (ArgoCD) <em>from the server itself</em> reports misleading results (self-connections traverse lo/hairpin). So the script asks an <strong>external scanner (check-host.net)</strong>: “can the public internet connect to this port?”</li><li><strong>Control plane</strong> — k3s/nodeport-guard service active, monitoring pods Running.</li></ol><p>A clean run appends a single OK: all checks passed to the log and stays quiet. <strong>Only failures trigger one Discord alert.</strong> Daily “everything is fine” pings become unread noise — designing against alert fatigue was a deliberate choice.</p><h3>Idempotency verification — the most important measurement</h3><p>A playbook only deserves to be called “state as code” if re-running it changes nothing. I ran it twice in a row:</p><pre>$ ansible-playbook site.yml --skip-tags manual-step   # 1st run<br>PLAY RECAP ... changed=0 failed=0<br>$ ansible-playbook site.yml --skip-tags manual-step   # 2nd run<br>PLAY RECAP ... changed=0 failed=0</pre><p>Getting changed=0 required fixing several traps I hit along the way:</p><ul><li><strong>Don’t add </strong><strong>changed_when: true out of habit.</strong> I put it on an iptables-persistence task; it flagged “changed” on every run and even triggered a k3s restart. Ansible’s built-in change detection is already correct.</li><li><strong>Gate helm upgrades on state.</strong> A bare helm upgrade is always “changed”. Read the release version with helm get metadata -o json and upgrade only when the release is missing or stale.</li><li><strong>Stamp first-run-only logic.</strong> The audit’s initial run is detected by the absence of its own log file.</li><li><strong>--check mode limitation</strong>: tasks that enable systemd units whose unit <em>files</em> the same play creates will fail in check mode (the file never gets written). Validate such plays with a real run.</li></ul><p>This habit — “periodically re-run and confirm idempotency hasn’t broken” — pairs naturally with incidents where settings fail to survive a reboot. If settings aren’t persisted and validation doesn’t repeat, the operator is being lied to in between.</p><h3>4. What I Expect Next</h3><ul><li><strong>A server migration becomes three commands</strong>: git clone → inject secrets → ansible-playbook site.yml --skip-tags manual-step. Only the interactive tailnet auth (tagged manual-step) needs a human; everything else is decided by code.</li><li><strong>AWS expansion</strong>: add the host to the inventory and apply the same roles. If a multi-node k3s becomes necessary, the k3s role grows a worker-join step — nothing else changes.</li><li><strong>Pairing with CI</strong>: today the audit runs inside the server on a systemd timer. Next step is running the playbook <em>from outside</em> (e.g. GitHub Actions) on a schedule, adding an out-of-band drift check — this post’s idempotency measurement is the safety net for that.</li><li><strong>Expanding the audit</strong>: currently ports/containers/pods; the same frame can accumulate auth-log review (verifying zero external login attempts) and more.</li></ul><p>Most of introducing IaC on a running server turned out to be not coding, but <strong>honestly transcribing what the server’s real state is into code</strong> — and then verifying, twice, that the resulting code changes nothing (changed=0). Once those two are done, the server exists as code, not as memory.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35ec630bec4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Retrospective on Google Chrome’s WebMCP: How a Web Page Hands Tools to an AI Agent, and What I…]]></title>
            <link>https://medium.com/@lajancia/a-retrospective-on-google-chromes-webmcp-how-a-web-page-hands-tools-to-an-ai-agent-and-what-i-2182184e5e83?source=rss-e240ff76f50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2182184e5e83</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-mcp]]></category>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Lajancia]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 15:40:15 GMT</pubDate>
            <atom:updated>2026-11-11T15:40:15.847Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Retrospective on Google Chrome’s WebMCP: How a Web Page Hands Tools to an AI Agent, and What I Learned Building One</h3><p>Not a spec review. A field report on what works and what doesn’t yet.</p><p><em>On November 7, at BiznagaFest 2026 in Málaga, I first ran into Web-MCP, the proposal led by the Google Chrome team. Reading about it wasn’t enough, so I built a small experiment to try the spec for real: a page that an agent fills in like a newspaper with my schedule and work. The result is on GitHub. The newspaper is just a test vehicle; the subject of this post is WebMCP itself. I start from the basics so that even if you’ve never heard of WebMCP you can follow along, then look back on what I learned and how far it works today.</em></p><h3>1. WebMCP in plain words</h3><p><strong>Start with MCP</strong></p><p>For an AI agent (an AI that searches, books, and schedules things on your behalf) to actually get work done, it has to use features of outside services. MCP (Model Context Protocol) is a shared standard for that connection. A service publishes a list of what it can do, such as “search flights” or “add a calendar event” (these are called tools), and the agent reads the list and calls what it needs. It’s similar to how phones converged on USB-C so that any charger fits.</p><p>In classic MCP, the party publishing that tool list is a server (the backend). That’s where the friction comes from. The agent talks directly to the server and knows nothing about the screen you’re looking at in your browser. Developers also have to copy login state and page state onto the server separately.</p><p><strong>WebMCP changes who publishes the tools</strong></p><p>At BiznagaFest, Raúl Tovar (The Workshop) introduced WebMCP in his session “Construyendo la Web Agéntica” (“Building the Agentic Web”). In one line:</p><p><strong>With MCP, a server gives tools to an agent. With WebMCP, a web page does.</strong></p><p>Think of a restaurant. MCP is like phoning your order in to the kitchen: it works, but the kitchen can’t see what you’re looking at at your table. WebMCP is the tablet menu on the table. You and the agent look at the same screen, and orders go through the buttons (tools) that the screen provides.</p><p><strong>It also differs from how agents use the web today</strong></p><p>Browser agents usually read the screen (HTML or a screenshot) and click like a person would. If a button moves or gets renamed, things break. WebMCP is the page handing over an official instruction manual: “don’t click around, just call this function.”</p><p>Four differences at a glance:</p><ul><li><strong>Who registers the tools:</strong> MCP uses a backend server; WebMCP uses the web page inside the browser.</li><li><strong>Where the agent connects:</strong> MCP goes through an API server, bypassing the page. WebMCP goes through the very tab the user has open.</li><li><strong>State and auth:</strong> with MCP you have to duplicate them on a server. With WebMCP the page already has them and just uses them.</li><li><strong>The screen (UI):</strong> with MCP the agent can’t see it. With WebMCP the user and the agent look at the same screen (shared context).</li></ul><p><strong>What it looks like in code</strong></p><p>The page registers a tool in JavaScript. Trimmed down from what I actually used:</p><pre>// Newest location is document; fall back to navigator on older Chrome<br>const mc = document.modelContext ?? navigator.modelContext;</pre><pre>mc?.registerTool({<br>  name: &quot;add_headline&quot;,                       // the tool&#39;s name<br>  description: &quot;Add one main headline to the newspaper&quot;, // what the agent reads<br>  inputSchema: {                              // the shape of accepted arguments<br>    type: &quot;object&quot;,<br>    properties: { title: { type: &quot;string&quot; }, url: { type: &quot;string&quot; } },<br>  },<br>  execute: async (args) =&gt; { render(args); return { ok: true }; }, // what actually happens<br>});</pre><p>Reading it is easy. name and description are the tool&#39;s label and manual. inputSchema fixes the shape of the values it accepts (&quot;title is a string, link is a string&quot;), so the agent can&#39;t make up parameters. execute is what the page actually does when the tool is called. Instead of poking around the DOM, the agent just reads this &quot;contract&quot; and calls add_headline with a title and a link. All the code that draws the screen lives inside the page, so as long as the tool signature stays the same, a layout redesign won&#39;t break the call.</p><p><strong>Where it stands today</strong></p><p>The spec is a W3C Community Group draft, and the GitHub repo (webmachinelearning/webmcp) lists engineers from Google Chrome and Microsoft as co-authors. It began as a flag-gated preview in Chrome 146 Canary, and an origin trial (a test period in which a site can request a token and turn the feature on early) opened in Chrome 149. It is not a finished standard.</p><h3>2. Where it fits, and the trade-offs</h3><p><strong>How a call flows</strong></p><ol><li>The user opens a page that supports WebMCP.</li><li>The agent discovers the tools registered in that tab (discovery).</li><li>The agent calls a tool with arguments.</li><li>The page runs execute() and updates the screen. The browser mediates the whole exchange.</li></ol><p><strong>Good fits:</strong> complex forms with split fields (first name, last name, address), multi-leg booking flows, diagnostic triggers buried deep in settings pages.</p><p><strong>Pros</strong></p><ul><li>You get an agent touchpoint with client-side JS only, no backend.</li><li>Page state and agent actions happen in the same tab, so context isn’t torn apart.</li><li>Unlike DOM scraping, it survives layout changes.</li></ul><p><strong>Cons</strong></p><ul><li><strong>Tool lifetime is tied to the tab.</strong> Tools exist only while the tab is open, so background batch jobs are out of scope.</li><li><strong>The client ecosystem is young.</strong> Few agents act as WebMCP clients. The page side is ready, but almost nothing consumes it. That’s effectively the biggest bottleneck.</li><li><strong>The spec is still moving.</strong> The July 2026 draft moved the API from navigator.modelContext to document.modelContext, and Chrome 150 deprecated the old location. Checking both is now a must.</li><li><strong>There’s a refactoring cost.</strong> To expose something as a tool, you have to pull render logic out of components and into execute(). In an existing React app, that&#39;s real work.</li></ul><h3>3. The experiment: a newspaper the agent fills in</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AjQ6xAprHDbofKn3ONEMig.png" /><figcaption>Newspaper sample</figcaption></figure><p>To try WebMCP hands-on, I picked one idea: <strong>a page where an agent collects my schedule, work, and news interests every day and lays them out like a front page.</strong> It was just the right size to test whether a single page, with no server, could become an agent touchpoint.</p><p>I set one design rule: <strong>serverless.</strong> No backend and no server-side user data. News and schedule are a one-off stream the agent collects at fill time, and a refresh gives you a blank page. Data lives only in the memory of the open tab. Deployment is just static file hosting, so each visitor’s own agent fills their own paper in their own browser. With no shared server state, every user gets a fully independent instance, and multi-user support fell out of the architecture as a side effect.</p><p>The stack is Next.js (App Router) + Tailwind + shadcn/ui, with five tools: set_date, add_headline, add_story, add_task, and clear_paper.</p><h3>4. What I learned building it</h3><p><strong>(1) Define tools in one place.</strong> I split tool definitions (name, schema, execute), the state store, and the UI components into three layers, so I can tear up the newspaper layout later without touching the contract. All rendering lives inside execute(). The key is never exposing a DOM API to the agent.</p><p><strong>(2) The path that works today: a mirrored registry.</strong> Native WebMCP clients are rare, so the page does two things at once:</p><ul><li>It registers properly on document.modelContext (or navigator.modelContext on older builds). In supporting browsers it switches to the native path immediately.</li><li>It mirrors the same tool objects onto window.__NEWSPAPER_TOOLS__. An agent attaches to the tab over CDP (Chrome DevTools Protocol, the channel developer tools use to remote-control a browser) and runs tool.execute(args) inside the tab. It&#39;s a pipe that passes the same contract through today, without browser mediation.</li></ul><pre>agent ──CDP──▶ window.__NEWSPAPER_TOOLS__ in the tab ──▶ execute(args) ──▶ render<br>        (today)</pre><pre>agent ──WebMCP client──▶ document.modelContext ──▶ execute(args) ──▶ render<br>        (later)       ↑ only this pipe changes; the contract stays</pre><p><strong>(3) Security: agent arguments aren’t trustworthy either.</strong> Even a value sent by my own agent becomes a vulnerability if it’s drawn on screen without checking. Here’s what I confirmed with attack-style test inputs:</p><ul><li>A link starting with javascript: arriving as a news URL runs malicious script on one click (XSS). I blocked it with a scheme allowlist that permits only http/https.</li><li>Control characters (newlines, tabs) break headline layout. I strip them and cap each field’s length.</li><li>If the bridge picks a tab with prefix matching like url.startsWith(), a sibling path (&lt;url&gt;-evil) can hijack the tool channel. Compare origin + pathname strictly.</li><li>When testing over a debug port, never use your main Chrome profile. Use a dedicated --user-data-dir.</li></ul><p>In short: <strong>sanitize at the page boundary, match strictly at the bridge boundary, and verify tests against DOM state.</strong> A tool can return {ok:true} and you still have to read the actually rendered DOM to know.</p><p><strong>(4) Design the transition up front.</strong> Moving from bridge to native only swaps the pipe. The flow (discover tools, collect data, call execute) is identical. If Chrome standardizes this and agents become native clients, only the middleman gets replaced. It’s a “ship the contract first, let the pipe arrive later” design.</p><h3>5. Current limitations, honestly</h3><ul><li><strong>Every fill so far went through the workaround path.</strong> Native WebMCP clients aren’t mainstream yet, so I used a pipe that attaches over CDP, skipping the browser’s consent UI. That differs from the standard’s intended browser-mediated model: the page-side contract is real WebMCP, but the client-side pipe is not yet. I designed it as a transition path, not a failure, but I want that distinction to be clear.</li><li><strong>Tools aren’t permanent.</strong> Close the tab and the tools vanish. Recurring background work has to wait until the Service Worker integration discussion matures.</li><li><strong>No cross-device sync.</strong> I don’t use localStorage by default either, so with multiple devices you get independent papers. That’s the price of leaving out a server, and I chose to pay it.</li></ul><h3>6. Looking back: takeaways</h3><ul><li><strong>MCP is a server handing out tools; WebMCP is a page handing them out.</strong> Instead of agents scraping the web, the page gives agents an official contract.</li><li>The page side can ship today. A few dozen lines of registration code establish the contract, and layout changes won’t break it.</li><li>The real bottleneck isn’t pages but the <strong>client ecosystem.</strong> The standard takes hold only when more agents consume WebMCP.</li><li>Agent arguments are an attack surface too. Sanitizing at the page boundary is new work for frontend developers.</li></ul><p>I don’t know yet whether this standard, pushed by Google Chrome, will take hold. But the direction, pages handing agents an official contract, is persuasive. My small newspaper was an experiment that showed both the promise and the limits. The agent fills the paper, and I read it. The server hosting the page still knows nothing.</p><p><em>Repo: github.com/Lajancia/newspaper-web-mcp (Next.js + shadcn/ui, includes tool registration / bridge / sanitize)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2182184e5e83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rebuilding My Homelab CI/CD — From nginx + Jenkins to k3s Traefik, Cloudflare Certificates, and…]]></title>
            <link>https://medium.com/@lajancia/rebuilding-my-homelab-ci-cd-from-nginx-jenkins-to-k3s-traefik-cloudflare-certificates-and-3e6f7332d9c2?source=rss-e240ff76f50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e6f7332d9c2</guid>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[homelab]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Lajancia]]></dc:creator>
            <pubDate>Sun, 04 Oct 2026 14:51:18 GMT</pubDate>
            <atom:updated>2026-10-08T06:33:37.968Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rebuilding My Homelab CI/CD — From nginx + Jenkins to k3s Traefik, Cloudflare Certificates, and GitHub Actions GitOps</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*if-8KqhhQfOvQol1VWnQBA.jpeg" /><figcaption>Image created with gemini</figcaption></figure><h3>Introduction</h3><p>This post documents the full overhaul of my homelab’s (soominlab.com) deployment and infrastructure stack. Compressed into one sentence:</p><blockquote><strong><em>Docker nginx + certbot + a Jenkins container → k3s Traefik + Cloudflare Origin certificates + GitHub Actions → GitOps (ArgoCD)</em></strong></blockquote><p>There are two services: the portfolio site soominlab.com (a Next.js case-study) and creative.soominlab.com (Next.js + React Three Fiber). The goal was to bring both under a single pipeline system.</p><h3>Before: Operations Scattered Across Three Paradigms</h3><p>The old setup’s core problem was that infrastructure lived in three different paradigms.</p><p><strong>1. Reverse proxy: nginx + certbot containers</strong></p><ul><li>A Dockerized nginx took 80/443, and certbot renewed Let’s Encrypt certificates on a 90-day cycle</li><li>Every renewal was a nagging “did it expire?” checklist item, and the coupling between the nginx container’s ports/config and the app containers kept growing</li></ul><p><strong>2. CI: a Jenkins container</strong></p><ul><li>The pipeline GitHub → Jenkins → GHCR → GitOps repo → ArgoCD → k3s worked fine, but Jenkins itself was the burden</li><li>A containerized Jenkins demands constant care: plugin updates, credential management, worker resources</li><li>Worse, <strong>Jenkins was effectively another “server” to operate</strong> — the essential cost of running it on a homelab</li></ul><p><strong>3. CD: ArgoCD already existed</strong></p><ul><li>The GitOps layer was already complete with k3s + ArgoCD, so it stayed as-is</li></ul><p>So the targets for replacement were <strong>TLS (nginx/certbot) and CI (Jenkins)</strong>; k3s + ArgoCD stayed.</p><h3>After: The Full Architecture</h3><pre>┌── Cloudflare (proxied, Full strict) ──┐<br>soominlab.com ──────┤                                       <br>creative.soominlab.com ──┘                                  <br>                         │ 443 (svclb hostport)<br>                         ▼<br>              Traefik (HelmChart, kube-system)<br>                         │ TLSStore default → soominlab-origin-tls<br>                         ▼<br>        case-study:3000 / next-r3f:3000 (k3s Deployment)</pre><pre>CI:  push(main) → GitHub Actions → GHCR push → bump image tag in ops repo → push<br>CD:  ArgoCD watches ops repo → auto sync → k3s deploy</pre><h4>1. Reverse Proxy: Unified on k3s Traefik</h4><p>The bundled k3s Traefik was disabled at install time (--disable traefik), and the official Helm chart is deployed directly via a HelmChart manifest:</p><pre>apiVersion: helm.cattle.io/v1<br>kind: HelmChart<br>metadata:<br>  name: traefik-custom<br>  namespace: kube-system<br>spec:<br>  chart: traefik<br>  repo: https://traefik.github.io/charts<br>  valuesContent: |-<br>    ports:<br>      web: { port: 80 }<br>      websecure: { port: 443 }<br>    service: { type: LoadBalancer }<br>    additionalArguments:<br>      - --entrypoints.web.http.redirections.entrypoint.to=websecure<br>      - --entrypoints.web.http.redirections.entrypoint.scheme=https<br>      - --entrypoints.web.http.redirections.entrypoint.permanent=true</pre><p>svclb now occupies the host’s 80/443, and the nginx container retired (stopped; kept around before removal). Routing is declared with IngressRoute CRDs:</p><pre>apiVersion: traefik.io/v1alpha1<br>kind: IngressRoute<br>metadata:<br>  name: case-study<br>  namespace: default<br>spec:<br>  entryPoints: [websecure]<br>  routes:<br>    - match: Host(`soominlab.com`)<br>      kind: Rule<br>      services:<br>        - name: case-study<br>          port: 3000</pre><p>Fine-grained controls like cache headers are also declarative via Middleware CRDs — for example, a 1-day cache for RDKit.js static assets that lack content hashes in their filenames.</p><h4>2. TLS: Let’s Encrypt → Cloudflare Origin Certificate</h4><p>The highest-satisfaction choice of the whole overhaul.</p><ul><li>A <strong>Cloudflare Origin CA certificate</strong> covers the entire *.soominlab.com with a single cert</li><li>This certificate is valid <strong>only on the Cloudflare↔origin leg</strong>. Internet users see the certificate on Cloudflare’s edge; CF uses the Origin certificate only when connecting back to the server</li><li>In k3s it’s stored as the soominlab-origin-tls secret and applied automatically to every IngressRoute via a <strong>default TLSStore</strong>:</li></ul><pre>apiVersion: traefik.io/v1alpha1<br>kind: TLSStore<br>metadata:<br>  name: default<br>  namespace: kube-system<br>spec:<br>  defaultCertificate:<br>    secretName: soominlab-origin-tls</pre><ul><li>Cloudflare runs in <strong>Full (strict)</strong> mode — CF validates the origin certificate, guaranteeing end-to-end TLS without a man in the middle</li><li>The certbot renewal loop disappeared entirely. The Origin certificate is valid for <strong>15 years</strong>, so “TLS operations” essentially ceased to exist as a task</li></ul><p>There is a trade-off: the Origin certificate is only valid behind Cloudflare, making <strong>the CF proxy effectively mandatory</strong>. For a homelab, that’s actually a bonus — the origin IP is hidden behind CF.</p><h4>3. CI: Jenkins → GitHub Actions</h4><p>The Jenkins container was removed (the jenkins_home volume was preserved), and the pipeline moved to GitHub Actions:</p><pre>name: Build &amp; Deploy (GitOps)<br>on:<br>  push:<br>    branches: [main]<br>jobs:<br>  build-push:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: docker/login-action@v3<br>        with:<br>          registry: ghcr.io<br>          username: ghost<br>          password: ${{ secrets.* }}<br>      - uses: docker/build-push-action@v6<br>        with:<br>          push: true<br>          tags: |<br>            ghcr.io/ghost/case-study:$<br>            ghcr.io/ghost/case-study:latest<br>      - name: Update GitOps repo<br>        uses: actions/checkout@v4<br>        with:<br>          repository: g3941813-svg/case-study-ops<br>          token: ${{ secrets.* }}<br>      - run: |<br>          cd gitops<br>          sed -i &quot;s|image: ghcr.io/g3941813-svg/case-study:.*|image: ghcr.io/g3941813-svg/case-study:${GITHUB_SHA::7}|&quot; case-study.yaml<br>          git commit -am &quot;chore: update image tag&quot; &amp;&amp; git push</pre><ul><li>Build, GHCR push, and the image-tag bump in the ops repo are handled in <strong>one workflow</strong></li><li>Tokens live only in GitHub Secrets; no credentials are stored on the server</li><li>Jenkins-as-another-server is gone, and the pipeline definition became a single yaml file inside the repo</li></ul><h4>4. CD: ArgoCD, Unchanged</h4><p>ArgoCD continues watching the GitOps repos (case-study-ops, next-r3f-ops). Even though CI moved from Jenkins to Actions, <strong>as long as image-tag commits land in the ops repo</strong>, ArgoCD handles the rest. Drawing this boundary clearly is why the overhaul went smoothly:</p><blockquote><strong><em>CI ends at “source → image → ops repo commit”; CD belongs entirely to ArgoCD.</em></strong></blockquote><h3>Troubles Encountered During the Migration</h3><p><strong>GitOps self-reference and state consistency</strong></p><p>In a structure where an Application is defined by its own source repo, fields like repoURL revert to old values via self-heal if <strong>the yaml HEAD and the cluster state</strong> ever disagree. When changing a repoURL, the yaml, the Application, and the credential secret must be made consistent <strong>within the same commit cycle</strong>.</p><h3>Summary: What Got Better</h3><p>nginx + certbot containers : 90-day renewalsCloudflare Origin cert -&gt; one TLSStore, effectively zero maintenance</p><p>CI : Jenkins container -&gt;GitHub Actions (zero server resources)</p><p>CD : ArgoCD -&gt;ArgoCD (unchanged)</p><p>Infra definition : Scattered (docker-compose, Jenkins jobs) -&gt; k3s manifests + GitHub workflow = all code</p><p>The deployment flow simplified too: <strong>one git push, and Actions builds the image, updates the ops repo, and ArgoCD deploys.</strong> The only human step is a commit.</p><p>Some of this simplification is only possible because it’s a homelab — a single-node k3s, two services. But at exactly this scale, “choosing to operate fewer things” pays off the most. Three containers (nginx, certbot, Jenkins) are gone, and what remains is k3s manifests and workflow yaml.</p><p>The next step I’m considering: templating the two applications with an ArgoCD ApplicationSet, so adding a new service becomes “copy a yaml.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e6f7332d9c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Working Memory Vault for AI Coding Agents — Design and Practice of the Agent Working Memory…]]></title>
            <link>https://medium.com/@lajancia/a-working-memory-vault-for-ai-coding-agents-design-and-practice-of-the-agent-working-memory-ad8a828ebb41?source=rss-e240ff76f50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad8a828ebb41</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[markdown]]></category>
            <dc:creator><![CDATA[Lajancia]]></dc:creator>
            <pubDate>Sun, 06 Sep 2026 10:14:42 GMT</pubDate>
            <atom:updated>2026-09-06T10:14:42.803Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Working Memory Vault for AI Coding Agents — Design and Practice of the Agent Working Memory Template</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oWhoHXzGOq3HfJz9bxKdBQ.jpeg" /><figcaption><em>Image generated with Gemini</em></figcaption></figure><h3>Introduction</h3><p>AI coding agents are evolving fast. Claude now has Memory and session search. Context windows keep growing. Every generation is more capable than the last.</p><p>But progress creates a new problem.</p><p><strong>Your knowledge becomes agent-dependent.</strong></p><p>What you built up in Claude stays in Claude. Work done in Codex is locked inside Codex sessions. When a better agent comes along tomorrow — and it will — you start over. Re-explain your stack, your preferences, your decisions, your recurring patterns, from scratch.</p><p>This template exists for one reason:</p><blockquote><strong><em>To centralize your work knowledge in an agent-agnostic way, so no matter which agent you use — today or in the future — connecting the vault gives you immediate continuity.</em></strong></blockquote><p>Agents are tools. Tools change. But the knowledge and context you’ve accumulated should outlive any single tool.</p><h3>What This Solves</h3><h4>1. Agent Lock-In</h4><p>Claude Memory is useful inside Claude. Session search works within the same agent. But how about switching into Codex? Moving into Cursor? Upgrading to the next-generation agent?</p><p><strong>Knowledge locked inside a specific tool makes migrating to better tools expensive.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HG3P_0AIBDKbwGEPvoXfSA.png" /></figure><h4>2. Context Fragmentation</h4><p>The more agents you use in parallel, the more fragmented your context becomes. “This decision was made in Claude, that code was written in Codex…” — everything scattered across different sessions.</p><h4>3. Unstructured Information</h4><p>Even with session search, chat logs are fundamentally unstructured. Decisions, work patterns, and reusable workflows are buried inside message streams, making them hard to reuse without manual extraction.</p><h3>Design Principles</h3><p><strong>Agent-Agnostic — </strong>The vault is not tied to any specific agent. Claude, Codex, or any future agent can read and write the same vault</p><p><strong>Centralized — </strong>Context from every session converges in one place. No matter which agent you used, the information stays in the vault</p><p><strong>Personal vault first — </strong>Optimized around one person’s work style, project status, and preferences. Not designed for multi-user sharing</p><p><strong>Start with minimal routine — </strong>Morning Briefing and Wrap-up are the default triggers. Tune timing and scope through actual use</p><p><strong>Explicit sources &amp; uncertainty — </strong>The agent distinguishes files it actually checked from external sources it couldn’t access. Unqueried systems are marked “not queried”</p><p><strong>Tiered recording levels — </strong>Must / Should / Maybe / Do not write — four levels to maintain signal-to-noise ratio</p><p><strong>Bootability — </strong>hot.md serves as a boot cache answering: “where are we now, and what should happen next?”</p><h3>Overall Structure</h3><p>The template consists of three layers.</p><pre>Agent_Working_Memory_Template/<br>├─ AGENTS.md                         # Operating rules for the agent<br>├─ README.md                         # Quick-start guide for users<br>├─ SETUP.md                          # Setup questions and initialization guide<br>├─ hot.md                            # Boot cache for the next session<br>├─ log.md                            # Vault operation log (append-only)<br>├─ 00_Index.md                       # Vault index<br>├─ 01_Daily/                         # Daily notes and work logs<br>├─ 10_Projects/                      # Project wiki<br>├─ 20_Meetings/                      # Meeting notes and action items<br>├─ 30_Agent/<br>│  ├─ Working_Style.md               # User preferences and execution rules<br>│  ├─ Observations.md                # Recurring observed patterns<br>│  └─ Journal.md                     # Latest 1-2 session summaries<br>├─ 70_Entities/                      # People, tools, and concepts<br>│  ├─ People/<br>│  ├─ Tools/<br>│  └─ Concepts/<br>├─ 90_Retrospectives/                # Daily/session retrospectives<br>└─ 99_Templates/                     # Note templates</pre><p><strong>Three layers and their roles:</strong></p><p>LayerRoleRepresentative Files<strong>Agent Continuity</strong>Restore the same context and style across sessionshot.md, Working_Style.md, Observations.md<strong>Autonomous Wiki Growth</strong>Accumulate work knowledge into a personal wiki10_Projects/, 20_Meetings/, 70_Entities/<strong>Routine-Based Refresh</strong>Prevent the vault from going stale01_Daily/, 90_Retrospectives/, Journal.md</p><h3>Core Routines</h3><p><strong>1. Setup (First-time configuration)</strong></p><p>When the user says “Use this folder as my working memory vault,” the agent reads AGENTS.md and SETUP.md, asks 3–6 questions, and initializes the vault with user info, projects, briefing sources, and recording boundaries.</p><p><strong>2. Morning Briefing</strong></p><pre>Please give me a morning briefing from this working memory vault.</pre><p>The agent reads hot.md, the latest daily note, project index, and configured sources to summarize:</p><ul><li>Today’s focus</li><li>Pending items</li><li>Blockers</li><li>External inputs</li><li>Independent work</li></ul><p>If today’s daily note doesn’t exist, it’s auto-created from 99_Templates/daily.md.</p><p><strong>3. During Work (Automatic recording)</strong></p><p>The agent selectively records only what matters:</p><ul><li><strong>Must write</strong> — user corrections, explicit decisions, handoffs, external system status changes, meeting/document ingest results</li><li><strong>Should write</strong> — recurring work patterns, reusable workflows, bug cause/fix patterns</li><li><strong>Maybe write</strong> — brainstorming, one-off opinions, unverified interpretations</li><li><strong>Do not write</strong> — simple conversational reactions, duplicates already in hot.md, unverified guesses, sensitive information</li></ul><p><strong>4. Wrap-Up</strong></p><pre>Please wrap up today.</pre><p>The agent updates the daily note, creates/updates a retrospective, rewrites hot.md as a boot cache, and adds summaries to Journal.md and log.md. Recurring patterns are promoted to Observations.md or project notes.</p><h3>Information Promotion Flow</h3><pre>Conversation<br>    → Daily note / Journal<br>    → hot.md<br>    → Project / Meeting / Entity notes<br>    → Observations<br>    → Working_Style</pre><p><strong>Conversation — </strong>Raw context needed for immediate work</p><p><strong>Daily note / Journal — </strong>Compressed record of the day or session</p><p><strong>hot.md — </strong>Short boot cache for the next session</p><p><strong>Project / Meeting / Entity notes — </strong>Long-term work knowledge</p><p><strong>Observations — </strong>Recurring observed patterns</p><p><strong>Working_Style — </strong>Preferences validated enough to become execution rules</p><p>This flow prevents one-off information from becoming a permanent user rule too quickly.</p><h3>Relation to Claude Memory / Session Search</h3><p>This template does <strong>not replace</strong> Claude’s Memory or session search. It complements them.</p><p><strong>Claude Memory</strong></p><p>Feature : Fast in-agent reference, auto-learningClaude-only.</p><p>Strength : No export/portability.</p><p>Limitation : Unstructured</p><p><strong>Session Search</strong></p><p>Feature : Find past conversationsUnstructured data.</p><p>Strength : Hard to extract decisions/patterns.</p><p>Limitation : Agent-dependent</p><p><strong>This Vault</strong></p><p>Feature : Agent-agnostic. Structured knowledge.</p><p>Strength : Fully portable</p><p>Limitation : Requires initial setup. Needs routine maintenance</p><p>Using all three together is the most effective approach. Claude Memory for quick in-session reference, this vault for structured long-term preservation, and any agent can connect to it when needed.</p><h3>Referenced Patterns</h3><p>PatternCore IdeaReflection in Template</p><p><strong>Karpathy LLM Wiki</strong></p><p>A file-based wiki LLMs can read, organize, and connect over timeProjects, meetings, people, tools, and concepts are managed as Markdown wiki</p><p><strong>OpenClaw Auto-Dream</strong></p><p>Periodically summarize session history and promote important info to long-term memorySimplified into Journal → Observations → Working_Style flow</p><p><strong>Daily Review / Shutdown</strong></p><p>Use daily reviews and shutdown rituals to define start and end of dayMorning Briefing and Wrap-up form the minimum refresh cycle</p><h3>Expected Benefits</h3><ul><li><strong>Use any agent</strong> — connect the same vault and start working immediately</li><li><strong>Free migration</strong> — move from Claude to Codex to a future better agent without losing context</li><li><strong>Decisions and corrections survive agent changes</strong></li><li><strong>Centralized context</strong> — even when using multiple agents in parallel</li><li><strong>Knowledge scattered across chats accumulates into a personal work wiki</strong></li><li>Claude Memory + vault = <strong>short-term reference + long-term preservation</strong> optimized</li><li>Morning Briefing and Wrap-up keep the vault from going stale</li><li>A human-readable file structure anyone can inspect, edit, and correct directly</li></ul><h3>Limitations and Recommended Use</h3><p>This template is a <strong>personal working memory vault</strong> shaped around one person’s work style. It is <strong>not recommended as a shared team knowledge base</strong>.</p><ul><li>Each person copies the template and uses it as a personal vault</li><li>The personal vault stores work style, current state, handoffs, and observations</li><li>Team-level decisions or project knowledge should be promoted to a separate team wiki or issue tracker</li><li>Sensitive information is not automatically recorded without explicit approval</li><li>Update timing and recording scope are adjusted through actual use</li></ul><h3>Useful Prompt Examples</h3><p><strong>Initial setup</strong></p><p>“Use this folder as my working memory vault. Please run setup.”</p><p><strong>Start of day</strong></p><p>“Please give me a morning briefing.”</p><p><strong>End of day</strong></p><p>“Please wrap up today.”</p><p><strong>Meeting ingest</strong></p><p>“Please turn this meeting transcript into meeting notes and update the vault.”</p><p><strong>Reflect a correction</strong></p><p>“The corrected schedule is important for the next session, so please reflect it in hot.md and the daily note.”</p><p><strong>Exclude from record</strong></p><p>“This is personal, so please do not record it in the vault.”</p><h3>Real-World Experience — It’s Not Perfect, and That’s OK</h3><p>The most important lesson from actually using this template: <strong>Perfect automation doesn’t exist.</strong></p><p>Despite defining Morning Briefing and Wrap-up routines, agents sometimes skip them. The vault is the last layer an agent references — when the agent is deep in work, it’s easy to miss the briefing. So there are days when I still need to manually trigger “morning briefing” or “wrap up today.”</p><p>This isn’t a limitation of the template. <strong>It’s the reality of any knowledge management tool.</strong></p><p>RealityResponseAgent occasionally skips Morning BriefingManually trigger “morning briefing” — takes one secondSession ends without Wrap-uphot.md preserves last-known state; next session recovers from itRecording depth is inconsistentTweak Working_Style.md to adjust the thresholdVault gets clutteredPeriodically promote patterns to Observations.md and archive old journals</p><p>The key insight: <strong>don’t try to craft perfect rules upfront. Use the template, notice friction points, and continuously reflect improvements in </strong><strong>Working_Style.md and </strong><strong>AGENTS.md.</strong></p><h3>Closing Thoughts — The Vault Outlives the Agent</h3><p>Claude will keep evolving. Better agents will keep appearing. That doesn’t diminish the value of this template — it amplifies it.</p><p><strong>The better agents get, the more important it becomes to keep your knowledge independent of any single one.</strong></p><p>If tomorrow’s superior agent has no idea about the context you built in Claude today, it will have to learn everything about you from scratch. This vault bridges that gap. No matter which agent you use — today or five years from now — connecting the vault restores your work context instantly.</p><p>It’s not a silver bullet, but this is how I use AI agents in my work. Acknowledging that it’s not perfect is what makes it sustainable in the long run.</p><blockquote><strong><em>GitHub</em></strong><em>: </em><a href="https://github.com/Lajancia/agent-working-memory-template"><em>github.com/Lajancia/agent-working-memory-template</em></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad8a828ebb41" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a GitOps CI/CD Pipeline with K3s, ArgoCD & Jenkins (2) — Hands-On Setup]]></title>
            <link>https://medium.com/@lajancia/building-a-gitops-ci-cd-pipeline-with-k3s-argocd-jenkins-2-hands-on-setup-2e0b97efa188?source=rss-e240ff76f50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e0b97efa188</guid>
            <category><![CDATA[k3]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[jenkins]]></category>
            <dc:creator><![CDATA[Lajancia]]></dc:creator>
            <pubDate>Fri, 28 Aug 2026 04:37:44 GMT</pubDate>
            <atom:updated>2026-08-28T13:17:18.265Z</atom:updated>
            <content:encoded><![CDATA[<p>In the previous post, we looked at why we chose K3s and GitOps, and what the overall architecture looks like. In this post, we’ll actually build the cluster, install ArgoCD, and write a Jenkins pipeline so that a single git push triggers an entire deployment automatically.</p><pre>GitHub Push (main branch)<br>    ↓ (webhook)<br>Jenkins Pipeline<br>    ├─ Docker Build (Node 20 + pnpm)<br>    ├─ GHCR Push (ghcr.io/&lt;USER&gt;/next14-r3f:COMMIT_SHA)<br>    └─ GitOps repo image tag update<br>        ↓ (3-min polling)<br>ArgoCD Auto-Sync → K3s deployment</pre><h3>1. Installing K3s</h3><p>The server runs Ubuntu 24.04 LTS VPS (single node). K3s installation is a single command:</p><pre>curl -sfL https://get.k3s.io | sh -</pre><p>However, I disabled the Traefik Ingress Controller that comes bundled with K3s, since I was already running Nginx as a reverse proxy.</p><pre>sudo mkdir -p /etc/rancher/k3s<br>echo &quot;disable: traefik&quot; | sudo tee /etc/rancher/k3s/config.yaml<br>curl -sfL https://get.k3s.io | sh -</pre><p><em>(Note: Passing </em><em>--disable traefik via </em><em>INSTALL_K3S_EXEC only applies to the current systemd unit, which will be overwritten on script-based upgrades.)</em></p><p>Once installed, verify the node status:</p><pre>kubectl get nodes<br># NAME        STATUS   ROLES           VERSION<br># srv695066   Ready    control-plane   v1.35.5+k3s1</pre><p>Since it’s a single-node cluster, only the control-plane role shows up. After deploying K3s, the overall system resource usage barely increased — living up to the lightweight promise.</p><blockquote><em>Post-install checklist</em></blockquote><ul><li>kubectl get nodes → Ready status</li><li>kubectl get pods -A → all kube-system pods are Running</li><li>/etc/rancher/k3s/k3s.yaml → kubeconfig is accessible</li></ul><h3>2. Installing ArgoCD</h3><p>ArgoCD is installed using the official manifests:</p><pre>kubectl create namespace argocd<br>kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml</pre><p>The initial admin password is auto-generated and stored in a Secret:</p><pre>kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath=&quot;{.data.password}&quot; | base64 -d</pre><p>Since this is a portfolio/study project (not production), I exposed the service via NodePort for easy access:</p><pre>kubectl patch svc argocd-server -n argocd -p &#39;{&quot;spec&quot;: {&quot;type&quot;: &quot;NodePort&quot;}}&#39;</pre><pre>kubectl get svc argocd-server -n argocd<br># NAME            TYPE       CLUSTER-IP    PORT(S)                       AGE<br># argocd-server   NodePort   10.43.x.x     80:32085/TCP,443:31495/TCP   64d</pre><p>Then, configure Nginx reverse proxy to point a subdomain to this NodePort. Make sure to change the admin password on first login.</p><blockquote><em>Security note: For production, use Ingress + TLS + SSO instead of NodePort. For a study environment, accessibility was the priority.</em></blockquote><h3>3. Setting Up the GitOps Repository</h3><p>The core idea of GitOps is that manifests are code too. All deployment YAML files live in a separate repository (next-r3f-ops), and ArgoCD watches this repo.</p><pre>next-r3f-ops/<br>├── argocd-app.yaml   # ArgoCD Application definition<br>├── next-r3f.yaml     # Deployment<br>└── service.yaml      # Service</pre><p>The Deployment defines the app’s image and resource limits:</p><pre># next-r3f.yaml<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: next-r3f<br>  namespace: default<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: next-r3f<br>  template:<br>    metadata:<br>      labels:<br>        app: next-r3f<br>    spec:<br>      containers:<br>        - name: next-r3f<br>          image: ghcr.io/&lt;USER&gt;/next14-r3f:COMMIT_SHA<br>          ports:<br>            - containerPort: 3000<br>          resources:<br>            requests:<br>              memory: 256Mi<br>              cpu: 250m<br>            limits:<br>              memory: 512Mi<br>              cpu: 500m</pre><p>The Service exposes the app via NodePort:</p><pre># service.yaml<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: next-r3f<br>  namespace: default<br>spec:<br>  selector:<br>    app: next-r3f<br>  ports:<br>    - port: 3000<br>      targetPort: 3000<br>      name: http</pre><p>The ArgoCD Application itself is also managed in Git. This is the beauty of this approach — ArgoCD manages itself via GitOps.</p><pre># argocd-app.yaml<br>apiVersion: argoproj.io/v1alpha1<br>kind: Application<br>metadata:<br>  name: next-r3f<br>  namespace: argocd<br>spec:<br>  project: default<br>  source:<br>    repoURL: https://github.com/&lt;USER&gt;/next-r3f-ops.git<br>    targetRevision: master<br>    path: .<br>  destination:<br>    server: https://kubernetes.default.svc<br>    namespace: default<br>  syncPolicy:<br>    automated:<br>      prune: true      # Delete resources not in Git<br>      selfHeal: true   # Revert manual changes to Git state<br>    syncOptions:<br>      - CreateNamespace=true</pre><p>Two critical options:</p><ul><li>selfHeal: true — Even if someone manually changes the Deployment via kubectl, ArgoCD periodically compares the cluster state with Git and automatically restores it.</li><li>prune: true — If you delete a resource from the Git repo, it gets deleted from the cluster too.</li></ul><h3>4. Preparing Jenkins</h3><p>Jenkins runs as a Docker container. The key decision here is mounting the host’s docker.sock:</p><pre>docker run -d \<br>  --name jenkins \<br>  -p 8080:8080 -p 50000:50000 \<br>  -v jenkins_home:/var/jenkins_home \<br>  -v /var/run/docker.sock:/var/run/docker.sock \<br>  -v /usr/bin/docker:/usr/bin/docker \<br>  jenkins/jenkins:lts</pre><p>This is called Docker-outside-of-Docker (DooD). When Jenkins runs docker build inside the container, the host&#39;s Docker daemon performs the actual build.</p><ul><li>Pros: No need to install Docker inside the container, shared build cache, fast builds</li><li>Cons: Jenkins has full access to the host’s Docker daemon (security concern). For production, consider DinD or Kaniko.</li></ul><p>Two things are needed for GitHub integration:</p><ol><li>GitHub Webhook — Delivers Push events to Jenkins. Go to repo Settings → Webhooks → add Jenkins URL /github-webhook/</li><li>Credentials — Jenkins → Manage Jenkins → Credentials → add GitHub PAT. Used by the Jenkinsfile to push to the GitOps repo</li></ol><h3>5. Dockerfile — Multi-Stage Optimization</h3><p>The Next.js app’s Dockerfile uses 4 stages:</p><pre>FROM node:20-alpine AS base<br>RUN apk add --no-cache libc6-compat<br><br># Install pnpm<br>RUN corepack enable &amp;&amp; corepack prepare pnpm@9.11.0 --activate<br>FROM base AS deps<br>WORKDIR /app<br>COPY package.json pnpm-lock.yaml ./<br>RUN pnpm install --no-frozen-lockfile<br>FROM base AS builder<br>WORKDIR /app<br>COPY --from=deps /app/node_modules ./node_modules<br>COPY . .<br>RUN pnpm panda &amp;&amp; pnpm build<br>FROM base AS runner<br>WORKDIR /app<br>ENV NODE_ENV=production<br>ENV NEXT_TELEMETRY_DISABLED=1<br>RUN addgroup --system --gid 1002 nextgroup<br>RUN adduser --system --uid 1002 nextuser<br>COPY --from=builder /app/public ./public<br>COPY --from=builder --chown=nextuser:nextgroup /app/.next/standalone ./<br>COPY --from=builder --chown=nextuser:nextgroup /app/.next/static ./.next/static<br>USER nextuser<br>EXPOSE 3000<br>ENV PORT=3000<br>ENV HOSTNAME=&quot;0.0.0.0&quot;<br>CMD [&quot;node&quot;, &quot;server.js&quot;]</pre><p>Stage breakdown:</p><p>StageRoleDescriptionbaseCommon baseNode 20 + pnpm activationdepsDependenciesLock-file-based reproducible installbuilderBuildpnpm build produces .next/standalonerunnerRuntimeStandalone server + non-root user</p><p>Two key takeaways:</p><ul><li>.next/standalone — Next.js&#39;s output: &#39;standalone&#39; produces a minimal runtime. It only includes the node_modules that are actually used, significantly reducing the image size.</li><li>Non-root execution — Running as root in a container is risky. A dedicated user (nextuser) minimizes the blast radius of a container escape.6. Jenkinsfile — Pipeline as Code</li></ul><p>Now the core of the pipeline: the Jenkinsfile. In GitOps, Jenkins does not deploy directly. It builds the image, pushes it to the registry, and updates the image tag in the GitOps repo. ArgoCD handles the rest.</p><pre>pipeline {<br>    agent any<br>environment {<br>        GHCR_IMAGE = &#39;ghcr.io/&lt;USER&gt;/next14-r3f&#39;<br>    }<br>    stages {<br>        stage(&#39;Checkout&#39;) {<br>            steps {<br>                checkout scm<br>            }<br>        }<br>        stage(&#39;Docker Build &amp; Push&#39;) {<br>            steps {<br>                script {<br>                    def shortCommit = sh(returnStdout: true, script: &#39;git rev-parse --short HEAD&#39;).trim()<br>                    echo &quot;Building image: ${GHCR_IMAGE}:${shortCommit}&quot;<br>                    sh &quot;docker build -f dockerfile -t ${GHCR_IMAGE}:${shortCommit} .&quot;<br>                    sh &quot;docker tag ${GHCR_IMAGE}:${shortCommit} ${GHCR_IMAGE}:latest&quot;<br>                    sh &quot;docker push ${GHCR_IMAGE}:${shortCommit}&quot;<br>                    sh &quot;docker push ${GHCR_IMAGE}:latest&quot;<br>                }<br>            }<br>        }<br>        stage(&#39;Update GitOps Repo&#39;) {<br>            steps {<br>                script {<br>                    def shortCommit = sh(returnStdout: true, script: &#39;git rev-parse --short HEAD&#39;).trim()<br>                    sh &quot;&quot;&quot;<br>                        export GIT_TERMINAL_PROMPT=0<br>                        rm -rf gitops-tmp<br>                        git clone https://github.com/&lt;USER&gt;/next-r3f-ops.git gitops-tmp<br>                        cd gitops-tmp<br>                        sed -i &#39;s|image: ghcr.io/&lt;USER&gt;/next14-r3f:.*|image: ${GHCR_IMAGE}:${shortCommit}|&#39; next-r3f.yaml<br>                        git config user.name &quot;Jenkins CI&quot;<br>                        git config user.email &quot;ci@example.com&quot;<br>                        git add next-r3f.yaml<br>                        git commit -m &quot;chore: update image tag to ${shortCommit}&quot;<br>                        git push<br>                        cd .. &amp;&amp; rm -rf gitops-tmp<br>                    &quot;&quot;&quot;<br>                }<br>            }<br>        }<br>        stage(&#39;Cleanup&#39;) {<br>            steps {<br>                sh &#39;docker image prune -f || true&#39;<br>            }<br>        }<br>    }<br>    post {<br>        success {<br>            echo &#39;Pipeline completed successfully! Image pushed to GHCR and GitOps repo updated.&#39;<br>        }<br>        failure {<br>            echo &#39;Pipeline failed. Check Jenkins logs for details.&#39;<br>        }<br>    }<br>}</pre><p>Stage breakdown:</p><p>StageWhat it doesCheckoutClone the source code from GitHubDocker Build &amp; PushBuild with commit SHA tag + latest tag, push to GHCRUpdate GitOps RepoClone GitOps repo → sed to replace the image tag → commit &amp; pushCleanupPrune old build cache</p><p>Using the commit SHA as the image tag is intentional. You can always trace which commit produced which image, and rolling back is as simple as git revert — ArgoCD picks up the old image tag automatically.</p><blockquote><em>GHCR Authentication: Login once before the pipeline runs: </em><em>echo $PAT | docker login ghcr.io -u &lt;USER&gt; --password-stdin. Store the PAT in Jenkins Credentials, never in plain text in the Jenkinsfile.</em></blockquote><h3>7. Testing the Full Pipeline</h3><p>Now let’s verify the entire flow:</p><pre>git add .<br>git commit -m &quot;feat: add new feature&quot;<br>git push origin main</pre><p>What happens next:</p><ol><li>GitHub Webhook triggers the Jenkins pipeline</li><li>Jenkins runs: Docker build, GHCR push, GitOps repo image tag update</li><li>ArgoCD detects the change in the GitOps repo (within 3 minutes, default polling)</li><li>ArgoCD performs a Rolling Update with the new image</li><li>Nginx → NodePort → Pod delivers the traffic</li></ol><p>Verification commands:</p><pre># 1. ArgoCD Application status<br>kubectl get applications -n argocd<br># NAME       SYNC STATUS   HEALTH STATUS<br># next-r3f   Synced        Healthy</pre><pre># 2. Check if the pod is running the new image<br>kubectl get pods -l app=next-r3f -o jsonpath=&#39;{.items[0].spec.containers[0].image}&#39;</pre><pre># 3. HTTP response<br>curl -sI <a href="https://example.com/">https://example.com</a> | head -1<br># HTTP/2 200</pre><p>One thing I tested out of curiosity: I manually changed the Deployment’s image tag using kubectl edit. A few minutes later, ArgoCD automatically reverted it back to the tag in Git. The self-heal mechanism actually works as advertised! 😄</p><h3>Wrapping Up</h3><p>With this setup, the GitHub Push → Jenkins → GHCR → GitOps Repo → ArgoCD → K3s pipeline is complete.</p><p>The biggest change in mindset is that deployment is no longer a “scheduled action” — it’s the “tracking of a declared state”. Instead of SSHing into the server to dig through logs when something goes wrong, you just look at the ArgoCD dashboard to see where the sync broke.</p><p>In the next post, I’ll cover rollback strategies, ArgoCD Blue/Green deployments, and Secret management (External Secrets / Sealed Secrets).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e0b97efa188" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a GitOps CI/CD Pipeline with K3s, ArgoCD & Jenkins (1) — Overview & Motivation]]></title>
            <link>https://medium.com/@lajancia/building-a-gitops-ci-cd-pipeline-with-k3s-argocd-jenkins-1-overview-motivation-0243aeefbef2?source=rss-e240ff76f50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/0243aeefbef2</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[k3]]></category>
            <dc:creator><![CDATA[Lajancia]]></dc:creator>
            <pubDate>Fri, 28 Aug 2026 01:00:19 GMT</pubDate>
            <atom:updated>2026-08-28T01:00:19.636Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Until recently, my deployment environment was simple. I had a VPS server with Docker installed, and Jenkins would receive a GitHub webhook, build a Docker image, and run the container locally.</p><pre>GitHub Push → Jenkins Build → Docker build → docker run (local)</pre><p>This approach works, but it has some shortcomings:</p><ul><li>If a container crashes, I have to restart it manually</li><li>Rollbacks are tedious</li><li>Managing many services becomes painful</li><li>There’s no dashboard to see the deployment state at a glance</li></ul><p>While thinking about these issues, I started studying Kubernetes. So I decided to build a lightweight K3s cluster and set up a GitOps-style CI/CD pipeline from scratch.</p><h3>Why K3s?</h3><p>The full Kubernetes distribution is heavy and complex. Especially on a single-node VPS like mine, the overhead can be a burden. K3s, on the other hand:</p><ul><li>Lightweight — runs as a single binary (~60MB)</li><li>Low-spec friendly — works with 1GB RAM and 1 CPU</li><li>kubeconfig compatible — standard kubectl commands just work</li><li>Simple installation — one command to bootstrap the cluster</li></ul><pre>curl -sfL https://get.k3s.io | sh -</pre><p>After deploying K3s on my server, the overall system resource usage barely increased.</p><h3>Why GitOps?</h3><p>GitOps is an operating model that uses Git as the single source of truth.</p><p>The difference between traditional deployment and GitOps:</p><p>AspectTraditionalGitOpsDeployment triggerJenkins deploys directlyGit repo change → auto syncState managementManual or scriptsGit repo = desired stateRollbackRedeploy old versionGit revert → auto recoveryVisibilityCheck logsReal-time sync status in dashboard</p><p>Adopting GitOps gives you:</p><ol><li>Declarative infrastructure — K8s manifests live in Git, so you define <em>desired state</em>, not <em>current state</em></li><li>Self-healing — even if someone deletes a Pod, ArgoCD restores it to the state defined in Git</li><li>Audit trail — every change is recorded as a Git commit</li></ol><h3>Overall Architecture</h3><pre>GitHub Push (main branch)<br>    ↓ (webhook)<br>Jenkins Pipeline<br>    ├─ Docker Build (Node 20 + pnpm)<br>    ├─ GHCR Push (ghcr.io/.../next14-r3f:COMMIT_SHA)<br>    └─ GitOps repo image tag update<br>        ↓ (3-min polling)<br>ArgoCD Auto-Sync<br>    ↓<br>K3s cluster deployment</pre><h3>Tech Stack</h3><p>ToolRoleNotesK3sLightweight KubernetesSingle node, --disable traefikArgoCDGitOps OperatorAuto-sync, Self-HealJenkinsCI pipelineGitHub Webhook, Pipeline as CodeGHCRContainer registryGitHub Container RegistryNginxReverse proxySSL + domain routingNext.jsDeployed applicationR3F-based portfolio site</p><p>In the next post, I’ll walk through the actual setup step by step: installing K3s, configuring ArgoCD, and writing the Jenkinsfile.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0243aeefbef2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securely Connecting a Remote Hermes Agent to Your Local Desktop App via Tailscale]]></title>
            <link>https://medium.com/@lajancia/securely-connecting-a-remote-hermes-agent-to-your-local-desktop-app-via-tailscale-ae9749aebfd0?source=rss-e240ff76f50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae9749aebfd0</guid>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[hermes]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ai-agent-security]]></category>
            <category><![CDATA[hermes-agent]]></category>
            <dc:creator><![CDATA[Lajancia]]></dc:creator>
            <pubDate>Sat, 11 Jul 2026 11:12:09 GMT</pubDate>
            <atom:updated>2026-07-11T11:12:09.650Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why This Guide Exists</h4><p>Hermes Agent is designed to run as a persistent backend server. The `hermes serve` command powers the desktop app and remote backends via WebSocket/JSON-RPC. This creates a common scenario:</p><p>- <strong>*Server machine**</strong> (e.g., Mac Mini, Linux VPS): Runs `hermes serve` 24/7</p><p>- <strong>**Client machine**</strong> (e.g., MacBook Pro): Runs the Hermes Desktop App and connects to the server remotely</p><p>The naive approach — binding to `0.0.0.0` (all interfaces) — exposes the backend to <strong>**every network**</strong>: public internet, local LAN, and any VPN you’re connected to. A single misconfigured firewall rule or zero-day vulnerability could expose your entire Hermes session.</p><p>This guide presents a <strong>**defense-in-depth**</strong> approach using Tailscale, a zero-config WireGuard mesh VPN, combined with direct IP binding and authentication.</p><p>— -</p><h4>Architecture Overview</h4><p>[Your Server (e.g., Mac Mini)]</p><p>→ `hermes serve — host &lt;Tailscale_IP&gt; — port 9119`</p><p>→ BOUND ONLY TO: Tailscale IP (100.x.x.x) — <strong>**NOT**</strong> 0.0.0.0</p><p>[Your Client (e.g., MacBook Pro)]</p><p>→ Hermes Desktop App</p><p>→ Gateway Settings → URL: `http://&lt;hostname&gt;.&lt;tailnet&gt;.ts.net:9119`</p><p>→ Auth: username + password</p><p><strong>**Key property**</strong>: The Tailscale IP exists <strong>**only**</strong> within the Tailscale WireGuard mesh. No other network can route to it.</p><h4>Prerequisites</h4><p>| Requirement | Notes |</p><p>| — — — — — — -| — — — -|</p><p>| Tailscale account | Free tier supports up to 3 users, 100 devices |</p><p>| Tailscale on <strong>**both**</strong> machines | macOS: `brew install — cask tailscale` |</p><p>| MagicDNS enabled | Settings → DNS → Enable MagicDNS in Tailscale admin console |</p><p>| Both machines on same tailnet | `tailscale up` on each with the same account |</p><p>| Hermes Agent on server | Installed via pip or official installer |</p><p>| Hermes Desktop App on client | Available from Nous Research |</p><p>Verify connectivity:</p><pre>tailscale status<br># Expected output:<br>100.x.x.x my-server user@ macOS -<br>100.y.y.y my-laptop user@ macOS -</pre><h4>Step 1: Install &amp; Configure Tailscale</h4><pre># macOS (Homebrew)<br>brew install - cask tailscale<br># Launch the app from Applications folder<br>open -a Tailscale<br># Or start headless CLI daemon (Linux/macOS)<br>sudo tailscaled - tun=userspace-networking &amp;<br>tailscale up</pre><p><strong>**Enable MagicDNS:**</strong></p><p>1. Open [Tailscale Admin Console](https://login.tailscale.com/admin/dns)</p><p>2. Click <strong>**Enable MagicDNS**</strong></p><p>3. Note your tailnet name (e.g., `tailnet1234.ts.net`)</p><p>Verify DNS:</p><pre>dig &lt;your-server-hostname&gt;.&lt;your-tailnet&gt;.ts.net +short<br># Expected: 100.x.x.x</pre><h4>Step 2: Understand Your Current State</h4><p>Before making changes, check what’s currently running:</p><pre># Find all Hermes processes<br>ps aux | grep hermes | grep -v grep<br># Check which ports listen on ALL interfaces (dangerous)<br>lsof -iTCP -sTCP:LISTEN -P -n | grep &quot;0.0.0.0&quot;</pre><p>If you see something like `TCP *:9119 (LISTEN)` — that’s a red flag. That means it’s exposed to every network interface.</p><h4>Step 3: The Vulnerability — 0.0.0.0 Binding</h4><p>When a process binds to `0.0.0.0`, it accepts connections on <strong>**every available network interface**</strong>:</p><p>- WiFi (en0) → 192.168.x.x — anyone on your WiFi can reach it</p><p>- Ethernet (en1) → 10.0.x.x — anyone on your LAN can reach it</p><p>- Tailscale (utun) → 100.x.x.x — anyone in your tailnet can reach it</p><p>- Loopback (lo0) → 127.0.0.1 — local processes only</p><p><strong>**Risk**</strong>: Someone on the same WiFi (coffee shop, coworking space), someone on the LAN, or (if port forwarding is enabled) anyone on the public internet can attempt to connect.</p><h4>Step 4: Bind to Tailscale IP (The Fix)</h4><p><strong>**Why the Tailscale IP is safe:**</strong></p><p>Tailscale assigns each device an IP from the private CGNAT range `100.64.0.0/10` (RFC 6598). This range is:</p><p>- <strong>**Not routable on the public internet**</strong></p><p>- <strong>**Not routable on local LANs**</strong> (different subnets)</p><p>- <strong>**Only reachable through the Tailscale WireGuard tunnel**</strong></p><p>- Automatically encrypted end-to-end</p><p><strong>**The command:**</strong></p><pre># Get the server&#39;s Tailscale IP<br>TAILSCALE_IP=$(tailscale ip -4)<br>echo &quot;Server Tailscale IP: $TAILSCALE_IP&quot;<br># Stop any existing Hermes serve<br>pkill -f &quot;hermes serve&quot; 2&gt;/dev/null<br># Start Hermes serve bound ONLY to the Tailscale IP<br>hermes serve - host $TAILSCALE_IP - port 9119</pre><p><strong>**Verify the binding:**</strong></p><pre>lsof -i :9119 -P -n<br># Expected: TCP 100.x.x.x:9119 (LISTEN)</pre><p>After this fix, your Hermes backend is only reachable from devices on your tailnet. Full stop.</p><p><strong>**Making it permanent with launchd (macOS):**</strong></p><pre># Create a launchd plist for auto-start on boot<br>cat &gt; ~/Library/LaunchAgents/hermes.serve.plist &lt;&lt; &#39;EOF&#39;<br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot;<br>&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;<br>&lt;plist version=&quot;1.0&quot;&gt;<br>&lt;dict&gt;<br>&lt;key&gt;Label&lt;/key&gt;<br>&lt;string&gt;hermes.serve&lt;/string&gt;<br>&lt;key&gt;ProgramArguments&lt;/key&gt;<br>&lt;array&gt;<br>&lt;string&gt;/usr/local/bin/hermes&lt;/string&gt;<br>&lt;string&gt;serve&lt;/string&gt;<br>&lt;string&gt; - host&lt;/string&gt;<br>&lt;string&gt;TAILSCALE_IP_PLACEHOLDER&lt;/string&gt;<br>&lt;string&gt; - port&lt;/string&gt;<br>&lt;string&gt;9119&lt;/string&gt;<br>&lt;/array&gt;<br>&lt;key&gt;RunAtLoad&lt;/key&gt;<br>&lt;true/&gt;<br>&lt;key&gt;KeepAlive&lt;/key&gt;<br>&lt;true/&gt;<br>&lt;/dict&gt;<br>&lt;/plist&gt;<br>EOF<br># Replace placeholder with actual IP<br>sed -i &#39;&#39; &quot;s/TAILSCALE_IP_PLACEHOLDER/$(tailscale ip -4)/&quot; ~/Library/LaunchAgents/hermes.serve.plist<br>launchctl load ~/Library/LaunchAgents/hermes.serve.plist</pre><p><em>&gt; </em><strong>**Note:**</strong><em> If your Tailscale IP changes on reboot, reserve a static IP in the Tailscale admin console instead.</em></p><p>— -</p><h4>Step 5: Set Up Authentication</h4><p>Binding to the Tailscale IP prevents unauthorized <em>*network*</em> access, but any device on your tailnet can still reach the port. Add <strong>**username/password authentication**</strong> as a second layer:</p><pre># ~/.hermes/config.yaml<br>dashboard:<br>basic_auth:<br>username: admin<br>password: &lt;YOUR_STRONG_PASSWORD&gt;</pre><h4>How Authentication Works</h4><p>The code follows this precedence (simplified from the source):</p><p>1. If `HERMES_DASHBOARD_BASIC_AUTH_PASSWORD` env var is set → hash it in-memory (highest priority)</p><p>2. Else if `password_hash` exists in config → use it directly</p><p>3. Else if plaintext `password` exists in config → hash it in-memory at startup</p><p><strong>**Important:**</strong> If <strong>**both**</strong> `password_hash` and `password` are present in config, `password_hash` takes precedence and your plaintext `password` is <strong>**silently ignored**</strong>. Remove the hash:</p><pre>sed -i &#39;&#39; &#39;/password_hash:/d&#39; ~/.hermes/config.yaml</pre><p><strong>**Generate a strong password:**</strong></p><pre>openssl rand -base64 24<br># Example: Xk9pLm3qRt7vWz1yBn4cFg8h</pre><p><strong>**Restart to apply:**</strong></p><pre>pkill -f &quot;hermes serve&quot;<br>hermes serve - host $(tailscale ip -4) - port 9119</pre><h4>Step 6: Connect from the Desktop App</h4><p>On the <strong>**client machine**</strong> (e.g., MacBook Pro):</p><p>1. Open the <strong>**Hermes Desktop App**</strong></p><p>2. Navigate to <strong>**Settings → Gateway**</strong></p><p>3. Click <strong>**”Add Remote Gateway”**</strong></p><p>4. Fill in:</p><p>| Field | Value |</p><p>| — — — -| — — — -|</p><p>| Connection URL | `http://&lt;your-server-hostname&gt;.&lt;your-tailnet&gt;.ts.net:9119` |</p><p>| Username | admin |</p><p>| Password | the strong password you set |</p><p>5. Click <strong>**”Connect”**</strong></p><p><strong>**Finding your server’s MagicDNS hostname:**</strong></p><pre>tailscale status - json | jq -r &#39;.Self.DNSName&#39; | sed &#39;s/\.$//&#39;<br># Output: my-server.tailnet1234.ts.net</pre><p><strong>**Connection verification from the client:**</strong></p><pre>curl -s -o /dev/null -w &quot;%{http_code}&quot; http://&lt;server-hostname&gt;.&lt;tailnet&gt;.ts.net:9119<br># Expected: 302 (redirect to /login) - this is correct!</pre><h4>Alternative Approaches Compared</h4><p>| Approach | Security | Complexity | URL Format |</p><p>| — — — — — | — — — — — | — — — — — — | — — — — — — |</p><p>| <strong>**Tailscale IP direct (this guide)**</strong> | ✅ High | Low | `http://host.ts.net:9119` |</p><p>| 127.0.0.1 + Tailscale Serve | ✅ High | Medium | `https://host.ts.net` |</p><p>| 127.0.0.1 + SSH Tunnel | ✅ High | High | `http://localhost:9119` |</p><p>| 0.0.0.0 + Firewall rules | ❌ Medium | High | `http://public-ip:9119` |</p><p>| Cloudflare Tunnel | ✅ High | Medium | `https://host.domain.com` |</p><p>### Why Not Tailscale Serve?</p><p>`tailscale serve` creates an HTTPS reverse proxy on port 443 that forwards to your local port:</p><pre>tailscale serve - bg 9119<br># Result: https://host.ts.net/ → http://127.0.0.1:9119</pre><p>This works, but direct Tailscale IP binding is simpler:</p><p>- No extra TLS termination hop (already encrypted by WireGuard)</p><p>- Direct port 9119 access without proxy redirection</p><p>- No Let’s Encrypt certificate management</p><p>- More transparent for debugging</p><h4>Security Hardening Checklist</h4><p>- [ ] `hermes serve` bound to Tailscale IP (not 0.0.0.0)</p><p>- [ ] All 0.0.0.0 services migrated or secured</p><p>- [ ] Dashboard authentication enabled (username + password)</p><p>- [ ] `password_hash` removed from config (if using plaintext password)</p><p>- [ ] No 0.0.0.0 listeners remain: `lsof -iTCP -sTCP:LISTEN -P -n | grep “0.0.0.0”` returns nothing</p><p>- [ ] Auto-start configured (launchd/systemd)</p><p>- [ ] Strong password used (`openssl rand -base64 24`)</p><p>- [ ] Both devices on the same tailnet</p><p>— -</p><h4>Troubleshooting</h4><blockquote>“Cannot connect to server” from Desktop App</blockquote><p>Check network connectivity from the <strong>**client**</strong>:</p><pre>tailscale ping &lt;server-tailscale-ip&gt;<br># Expected: pong from &lt;server&gt; in &lt;ms&gt;<br>dig &lt;server-hostname&gt;.&lt;tailnet&gt;.ts.net +short<br># Expected: 100.x.x.x<br>nc -zv &lt;server-tailscale-ip&gt; 9119<br># Expected: Connected to …</pre><p>Check the <strong>**server**</strong> process:</p><pre>lsof -i :9119 -P -n<br># Expected: TCP 100.x.x.x:9119 (LISTEN)<br>curl -s http://localhost:9119<br># Expected: {&quot;error&quot;:&quot;Headless backend…&quot;} or HTML login page</pre><blockquote>“Invalid credentials” on login</blockquote><pre>grep -A 5 &quot;basic_auth&quot; ~/.hermes/config.yaml<br># If password_hash is present, remove it<br>sed -i &#39;&#39; &#39;/password_hash:/d&#39; ~/.hermes/config.yaml<br># Restart<br>pkill -f &quot;hermes serve&quot;<br>hermes serve - host $(tailscale ip -4) - port 9119</pre><blockquote>Tailscale IP changes after reboot</blockquote><p><strong>**Option A:**</strong> Reserve a static IP in Tailscale admin console</p><p>- Go to <a href="https://login.tailscale.com/admin/machines">https://login.tailscale.com/admin/machines</a></p><p>- Click your server → “Reserve IP”</p><p><strong>**Option B:**</strong> Use MagicDNS hostname in startup scripts</p><pre>HOSTNAME=$(tailscale status - json | jq -r &#39;.Self.DNSName&#39; | sed &#39;s/\.$//&#39;)</pre><blockquote>`tailscale` command not found</blockquote><pre># macOS Homebrew<br>export PATH=&quot;/opt/homebrew/bin:$PATH&quot;<br># Add to shell profile for persistence<br>echo &#39;export PATH=&quot;$PATH:/opt/homebrew/bin&quot;&#39; &gt;&gt; ~/.zshrc</pre><blockquote>`hermes serve` exits immediately</blockquote><pre># Check logs<br>hermes logs<br># Ensure no other process uses the same port<br>lsof -i :9119 -P -n<br># Run in foreground to see error output<br>hermes serve - host $(tailscale ip -4) - port 9119</pre><h4>Conclusion</h4><p>By binding Hermes Serve to your Tailscale IP instead of `0.0.0.0`, you achieve:</p><p>1. <strong>**Defense in depth**</strong>: Network isolation (Tailscale IP) + app-layer auth (dashboard password)</p><p>2. <strong>**Zero public exposure**</strong>: No ports open on public/LAN interfaces</p><p>3. <strong>**End-to-end encryption**</strong>: WireGuard tunnel even for local traffic</p><p>4. <strong>**Minimal complexity**</strong>: No reverse proxy, no TLS config, no firewall rules</p><p>5. <strong>**Port preservation**</strong>: Direct connection on port 9119 without proxy redirection</p><p>This pattern — <strong>**bind to the virtual network interface IP, not 0.0.0.0**</strong> — applies to any service you want to expose securely over Tailscale: databases, development servers, APIs, and more.</p><blockquote><em>*All IPs, passwords, and tokens shown are examples only. Replace with your own values. Follow the principle of least privilege.*</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae9749aebfd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins Setting with Docker-2]]></title>
            <link>https://medium.com/@lajancia/jenkins-setting-with-docker-2-8c5c922445b6?source=rss-e240ff76f50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c5c922445b6</guid>
            <category><![CDATA[next-14]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Lajancia]]></dc:creator>
            <pubDate>Mon, 09 Dec 2024 05:12:42 GMT</pubDate>
            <atom:updated>2024-12-09T05:12:42.747Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In the previous post, we configured Jenkins to build a Docker image. However, the website is not connecting through the Nginx proxy server.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sLkgXZIvtcvlmrOA" /><figcaption>Photo by <a href="https://unsplash.com/@bamin?utm_source=medium&amp;utm_medium=referral">Pierre Bamin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>By default, a domain name is connected to port 80. For example, Soominlab.com is the same as Soominlab.com:80. However, our application is running on port 3005, so we cannot access it with just the domain name.</p><p>While we could run our application on port 80, there’s a better option: using the Nginx reverse proxy server.</p><h3>What is Proxy server? Why do we have to use that?</h3><p>Before using Nginx, we need to understand what a proxy server is. Basically, a proxy is something that can take over the role of another entity. There are two kinds of proxy servers:</p><ul><li><strong>Forward Proxy</strong>: This proxy is in front of the client. When a client tries to access the outer network, they need to go through the forward proxy to connect to the outer network. Examples include VPNs or company local networks.</li><li><strong>Reverse Proxy</strong>: This proxy is in front of the web application server. The client requests the web application not directly through the Web Application Server (WAS) but through the reverse proxy server.</li></ul><p>In this case, we have to use a Reverse Proxy Server. If the client accesses our domain, it doesn’t directly connect with domain:3005; instead, Nginx takes over and redirects the connection to port 3005.</p><p>This reverse proxy has various benefits:</p><ul><li><strong>Load Balancing</strong>: We can handle massive traffic with load balancing, preventing the web application from shutting down.</li><li><strong>Security</strong>: A reverse proxy can hide the real IP address.</li><li><strong>Caching</strong>: If specific data is requested frequently, the reverse proxy can respond with cached data, improving response times.</li><li><strong>Encryption</strong>: The reverse proxy can decrypt all incoming requests and encrypt all outgoing responses, ensuring secure connections and reducing server load.</li></ul><h3>Using Nginx Reverse Proxy with Docker</h3><p>We can also create an Nginx Reverse Proxy server using a Docker image. However, this requires that two different containers share the same network. It may enough to use expose, But I just want to give name for the network group for further development. To achieve this, you first need to set up a Docker network. Open your server terminal and run the following command:</p><pre>docker network create my-network</pre><p>This command will create the my-network Docker network. Now, we need to ensure our web application container can run on this network.</p><p>Go to your Jenkinsfile and edit the command as follows:</p><pre>pipeline {<br>    agent any<br>    stages() {<br>        stage(&#39;Checkout&#39;) {<br>                steps {<br>                    checkout scmGit(branches: [[name: &#39;main&#39;]], <br>                                    userRemoteConfigs: [[url: &#39;https://github.com/Lajancia/nextjs-trello.git&#39;]])<br>                }<br>            }<br><br>        stage(&#39;Docker Image Build&#39;) {<br>            steps {<br>                echo &#39;Docker building..&#39;<br>                script {<br>                    sh &#39;docker build -t next14-trello .&#39;<br>                }<br>            }<br>        <br>        }<br>        <br>         stage(&#39;Run Docker Container&#39;) {<br>            steps {<br>                sh &#39;docker stop next-trello || true&#39;<br>                sh &#39;docker rm next-trello || true&#39;<br>                sh &#39;docker run -d --name next-trello --network my-network next14-trello&#39;<br>            }<br>        }<br>     // stage...<br>    }<br>}</pre><p>Now, our container will run on the my-network and can be connected with other containers. Finally, we need to set up the Nginx configuration file. Go to your Linux server terminal and create the .conf file. In my case, I created it at /etc/nginx/nginx-prod.conf.</p><pre>events {}<br><br>http {<br>upstream next-app {<br>    server next-trello:3000; // this next-trello should be same with your web application container name<br>}<br>    server {<br>        listen 80;<br> server_name soominlab.com;<br><br>        location / {<br>            proxy_pass http://next-app;<br>            proxy_set_header Host $host;<br>            proxy_set_header X-Real-IP $remote_addr;<br>            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>            proxy_set_header X-Forwarded-Proto $scheme;<br>        }<br>    }<br>}</pre><p>The upstream directive in Nginx can connect various servers to the Nginx reverse proxy server. Currently, my server isn&#39;t capable of handling multiple servers, so I&#39;m using only port 3000. Since we&#39;re sharing the network, there&#39;s no need to map port 3000 to 3005 externally. Instead, we can modify the docker-compose configuration to expose the port without mapping it directly to the outside. This way, other containers can access the port, but it won&#39;t be directly accessible from outside.</p><p>After setting up the Nginx configuration file, save it, and run the following command:</p><pre>docker run -d --name nginx-trello --network my-network -p 80:80 -v /etc/nginx/nginx-prod.conf:/etc/nginx/nginx.conf:ro nginx</pre><p>This means that the Nginx container will run with the name nginx-trello. The -d flag ensures it runs in the background. The -p 80:80 option maps port 80 on the host to port 80 on the container. The -v /etc/nginx/nginx-prod.conf:/etc/nginx/nginx.conf:ro mounts the configuration file /etc/nginx/nginx-prod.conf from the host to the container&#39;s /etc/nginx/nginx.conf path in read-only mode. The nginx command uses the Docker Hub Nginx image with the specified nginx-prod.conf configuration file.</p><p>Everything is set. Let’s trigger the GitHub Webhook and see how it works!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4lLFW-G3ri0cueVF.png" /></figure><p>It works perfectly, just like before. If your server memory is between 2 to 3 GB, it may take a minute to fully publish. I recommend having more than 4 to 6 GB of memory to handle Jenkins and Docker builds simultaneously. Personally, I need to upgrade my plan to Hostinger KVM due to memory constraints and monthly costs.</p><blockquote>I hope this post is helpful to you. See you in the next one!</blockquote><h3>Reference</h3><ul><li><a href="https://soomins.tistory.com/42">4. Docker + Jenkins + Github + Grafana + Next14</a></li><li><a href="https://soomins.tistory.com/41">3. Docker + Jenkins + Github + Grafana + Next14</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c5c922445b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins Setting with Docker-1]]></title>
            <link>https://medium.com/@lajancia/jenkins-setting-with-docker-1-6f7270b2fe09?source=rss-e240ff76f50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f7270b2fe09</guid>
            <category><![CDATA[webhooks]]></category>
            <category><![CDATA[cicd-pipeline]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Lajancia]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 02:12:51 GMT</pubDate>
            <atom:updated>2024-12-02T02:12:51.562Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NymxVJ6FmBVQQDMk" /><figcaption>Photo by <a href="https://unsplash.com/@scottrodgerson?utm_source=medium&amp;utm_medium=referral">Scott Rodgerson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It’s not very common to use Jenkins and an application on the same server. However, since I only have one server, I need to handle all CI/CD processes here. This means that Jenkins will need to build the image and run the container itself.</p><p>In this post, I’ll demonstrate how to set up Jenkins with a Docker image and enable it to build Docker images.</p><h3>Jenkins with Docker</h3><p>The purpose of this Jenkins setup is to ensure it can build images. Unfortunately, reinstalling Docker within a Docker container is not recommended. So, how can we make this work?</p><p>We can configure Jenkins to share the host’s Docker socket. Let’s install Jenkins with a Docker image using the command below:</p><pre>docker run -p 8000:8080 \<br>  -v /var/run/docker.sock:/var/run/docker.sock \<br>  --name jenkins \<br>  jenkins/jenkins:lts</pre><p>The most important part of this command is docker.sock. This allows access to the Docker socket at a specific path, enabling Jenkins to use the host Docker.</p><p>Additionally, since I am already using port 8080, I will change the mapping to port 8000.</p><p>Now, after the Docker image successfully runs the container, we need to access this container.</p><pre>docker exec -it -u root jenkins bash</pre><p>To install the Docker CE binary and configure the APT repository, run the command below:</p><pre>apt-get update &amp;&amp; \<br>apt-get -y install apt-transport-https \<br>     ca-certificates \<br>     curl \<br>     gnupg2 \<br>     software-properties-common &amp;&amp; \<br>curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo &quot;$ID&quot;)/gpg &gt; /tmp/dkey; apt-key add /tmp/dkey &amp;&amp; \<br>add-apt-repository \<br>   &quot;deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo &quot;$ID&quot;) \<br>   $(lsb_release -cs) \<br>   stable&quot; &amp;&amp; \<br>apt-get update &amp;&amp; \<br>apt-get -y install docker-ce</pre><p>Lastly, we need to ensure that Jenkins has access to the host Docker.</p><pre>groupadd -f docker<br><br>usermod -aG docker jenkins<br><br>chown root:docker /var/run/docker.sock</pre><h3>Docker Test</h3><p>Finally, it’s time to test if Jenkins can successfully use the host Docker to build the image. But before that, first log in to your Jenkins and create a new freestyle project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tg6e-Gz-_3WXWXSy.png" /></figure><p>In the build steps, simply add a single Docker image command and check if the build completes successfully. If it doesn’t, it means your Docker authorization is not set up properly. Just stop the Jenkins container and rerun it. This should fix the problem.</p><pre>docker stop &lt;container-id&gt;<br>docker start &lt;container-id&gt;</pre><h3>Docker Image Build Test</h3><p>If everything works fine, Let’s make a new pipeline that pull the code from github when main branch triggered and build the image in jenkins. To do that, I’ll use the next project that we previously created. To connect the github and jenkins, We need to make a personal access token. let’s go to github settings&gt; Developer Settings &gt; personal access token &gt; tokens &gt; generate new token and check the below options repo admin:repo_hook Once you create and get the key, you could not see the key again. So be sure to save the key in save place. Now, We need to set the credentials using this key. Go to Jenkins Management &gt; credentials</p><p>Here’s a refined version of your text for better clarity and flow:</p><p>If everything works fine, let’s create a new pipeline that pulls code from GitHub when the main branch is triggered and builds the image in Jenkins. To do this, I’ll use the project we previously created.</p><p>To connect GitHub and Jenkins, we need to create a personal access token. Go to GitHub Settings &gt; Developer Settings &gt; Personal Access Tokens &gt; Tokens &gt; Generate new token, and check the following options:</p><ul><li>repo</li><li>admin:repo_hook</li></ul><p>Once you create and receive the key, you won’t be able to view it again. So, be sure to save the key in a safe place.</p><p>Now, we need to set the credentials using this key. Go to Jenkins Management &gt; Credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qxQD_sPTmvuuu3W8.png" /></figure><p>Click on “Global” and add the credentials. Fill out the form as follows:</p><ul><li><strong>Username</strong>: your-github-id</li><li><strong>Password</strong>: github-token-you-created</li><li><strong>ID</strong>: github-token (a name to distinguish it from other IDs)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DtcL1Yza6kHhligK.png" /></figure><p>After setting the credentials, proceed to add WebHooks and include the URL:</p><p>your-jenkins-url/github-webhook/</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0Ocwv3dvxgwcwzRN.png" /></figure><p>Great! It successfully connected. Now, all we have to do is create the pipeline and test the Docker image build.</p><p>Go to Jenkins and create a new pipeline. Fill out the form as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ds_YUrV7KoyDMmgp.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hQdDWuW6oN75iBx-.png" /></figure><p>The pipeline script from SCM will read the Jenkinsfile in your repository and execute the process. If you prefer to write the Jenkins script directly in the Jenkins pipeline, you can use the pipeline script option.</p><p>In your project root directory, create a Jenkinsfile and include the following content:</p><pre>pipeline {<br>    agent any<br>    <br>    stages() {<br>        <br>        stage(&#39;Checkout&#39;) {<br>                steps {<br>                    checkout scmGit(branches: [[name: &#39;main&#39;]], <br>                                    userRemoteConfigs: [[url: &#39;https://github.com/Lajancia/nextjs-trello.git&#39;]])<br>                }<br>            }<br><br>        stage(&#39;Docker Image Build&#39;) {<br>            steps {<br>                echo &#39;Docker building..&#39;<br>                script {<br>                    sh &#39;docker build -t next14-trello .&#39;<br>                }<br>            }<br>        <br>        }<br>        <br>     // stage...<br>    }<br>}</pre><p>After this setting, Try push commit to main branch. Jenkins will automatically start the process base on your Jenkinsfile.</p><h3>ISSUE</h3><p>During the process, if you encounter an error related to npm: not found, it means you need an extra plugin in Jenkins. Go to Jenkins Manage &gt; Plugins &gt; Available Plugins and search for NodeJS. Installing this plugin will resolve the issue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/0*BdAV7qm7V1aBkSfj.png" /></figure><p>Additionally, if you want to see the progress bar, you should also install the plugin. Search for “Pipeline: Stage View” and install it. This will display the process as shown in the image above.</p><h3>REFERENCE</h3><ul><li><a href="https://velog.io/@chrkb1569/CICD-GitHub-Jenkins-Docker%EB%A5%BC-%ED%99%9C%EC%9A%A9%ED%95%9C-CICD-%ED%99%98%EA%B2%BD-%EA%B5%AC%EC%B6%95-4">[CI/CD] GitHub, Jenkins, Docker를 활용한 CI/CD 환경 구축 - 4</a></li><li><a href="https://velog.io/@rungoat/CICD-Jenkins%EC%99%80-GitHub-%EC%97%B0%EB%8F%99%ED%95%98%EA%B8%B0">[CI/CD] Jenkins와 GitHub 연동하기</a></li><li><a href="https://soomins.tistory.com/38">2. Docker + Jenkins + Github + Grafana + Next14</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f7270b2fe09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker and Next14 standalone -2]]></title>
            <link>https://medium.com/@lajancia/docker-and-next14-standalone-2-3804a7b30bf4?source=rss-e240ff76f50d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3804a7b30bf4</guid>
            <category><![CDATA[standalone]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[example]]></category>
            <category><![CDATA[next-14]]></category>
            <dc:creator><![CDATA[Lajancia]]></dc:creator>
            <pubDate>Mon, 25 Nov 2024 12:58:29 GMT</pubDate>
            <atom:updated>2024-11-25T12:58:29.570Z</atom:updated>
            <content:encoded><![CDATA[<h3>Let’s start from the beginning…</h3><p>I have a Next.js 14 app router project to test various libraries and code. I’ll use this repository during the Docker setup, but you can use your own project or create a new one.</p><p>Since I don’t have an AWS server right now, I’ll use my own VPS server from Hostinger. We will test the Docker image build and automatically publish it to the server using a GitHub webhook.</p><p>Here’s the flow:</p><ol><li>A git push will trigger the GitHub webhook.</li><li>The Jenkins pipeline will activate and build the Docker image.</li><li>The Docker image will run as a container.</li></ol><p>Additionally, we will use Nginx as a proxy server. This means the Next.js 14 project will run on port 3000, but Nginx will proxy it to port 80.</p><h3>Next14 +Docker setting</h3><p>First of all, you need a Next.js 14 project. If you don’t have one, here is the command you can use to create your own.</p><pre>// for npm<br>npx create-next-app@latest<br><br>// for yarn<br>yarn create next-app</pre><p>Done! Now we are ready to start. Making our Next.js 14 build result standalone is much easier. But wait, what is standalone?</p><p><a href="https://nextjs.org/docs/pages/api-reference/next-config-js/output#automatically-copying-traced-files">next.config.js Options: output | Next.js</a></p><p>This build mode helps you copy only the necessary files for production deployment. It also automatically includes the node_modules. Instead of running with next start, the standalone folder runs with server.js</p><p>However, this standalone output mode has some issues. It doesn’t properly work with yarn cache. So if you are using yarn, try using yarn node_modules or switch to pnpm or npm instead. Additionally, it cannot copy the public and static folders by itself, so we need to do some work with the Dockerfile.</p><p>To use the standalone mode, all you have to do is set the ‘standalone’ option in the output configuration like this:</p><pre>// next.config.js<br>  output: &quot;standalone&quot;,</pre><p>Now, when you run npm build or pnpm build or yarn build, it will create standalone folder under .next like image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/0*4uKhPXe8eD_gPaTE.png" /></figure><p>You can run this standalone with server.js file</p><pre>// inside standalone folder console<br>node server.js</pre><p>But in most cases, the result will not show any images or styles. This happens because the standalone mode doesn’t automatically include the public and static folders in the right place, as I mentioned. If you want to check if the standalone mode works properly, you can try copying the public folder directly to the standalone folder and copying the static folder to the standalone/.next folder. After that, running node server.js will show the proper result.</p><h3>Dockerfile</h3><p>Now, let’s write the Dockerfile. The Next.js 14 application will use pm2 to safely run and shut down the server.</p><pre>FROM node:18-alpine as base<br>RUN apk add --no-cache libc6-compat<br><br>FROM base as builder<br>WORKDIR /app<br>COPY . .<br>RUN npm run build<br><br>FROM builder as production<br>WORKDIR /app<br>RUN npm install --global pm2<br>RUN addgroup --system --gid 1002 nextgroup<br>RUN adduser --system --uid 1002 nextuser<br>COPY --from=builder /app/public ./public<br>COPY --from=builder --chown=nextuser:nextgroup /app/.next/standalone ./<br>COPY --from=builder --chown=nextuser:nextgroup /app/.next/static ./.next/static<br>COPY --from=builder --chown=nextuser:nextgroup /app/ecosystem.config.js ./<br>USER nextuser<br>ENTRYPOINT [&quot;pm2-runtime&quot;, &quot;start&quot;,&quot;ecosystem.config.js&quot;]</pre><p>The necessary folder is standalone, and we will create a Dockerfile that includes the static and public folders within the standalone folder.</p><p>Next, let&#39;s add the ecosystem.config.js file.</p><pre>module.exports = {<br>  apps: [<br>    {<br>      name: &quot;next-trello&quot;,<br>      script: &quot;npm&quot;,<br>      args: &quot;run serve&quot;,<br>      exec_mode: &quot;fork&quot;,<br>      watch: false,<br>    },<br>  ],<br>};</pre><p>This will run the npm run serve command.</p><p>Lastly, add the docker-compose file to easily build and run the Image</p><pre>version: &quot;3.8&quot;<br>services:<br>  app:<br>    image: nextjs-trello-app<br>    build:<br>      context: ./<br>      target: production<br>      dockerfile: dockerfile<br>    ports:<br>      - &quot;3005:3000&quot;</pre><p>Everything is ready. Let’s build the Docker and check if everything works fine.</p><pre>docker-compose up --build</pre><p>You can check the application running on localhost:3005, as we set it up in docker-compose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*loY5g346zEU3e5bq.png" /><figcaption>Actually there’s no content yet in this test project but run fine</figcaption></figure><p>Now, we have a super simple Next.js 14 application running on the local server. In the next post, let’s explore how to set up Jenkins with a Docker image and make it automatically deploy the project.</p><h3>Reference</h3><ul><li><a href="https://soomins.tistory.com/37">https://soomins.tistory.com/37</a></li><li><a href="https://tech.inflab.com/20230918-rallit-standalone/">https://tech.inflab.com/20230918-rallit-standalone/</a></li><li><a href="https://nextjs.org/docs/pages/api-reference/next-config-js/output">https://nextjs.org/docs/pages/api-reference/next-config-js/output</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3804a7b30bf4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>