diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..516041f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +node_modules +.next +out +.git +.gitea +.claude +.vscode +helm +Dockerfile +.dockerignore +README.md +AGENTS.md +npm-debug.log* +*.tsbuildinfo +.env* diff --git a/.gitea/workflows/cicd.yaml b/.gitea/workflows/cicd.yaml new file mode 100644 index 0000000..840e41d --- /dev/null +++ b/.gitea/workflows/cicd.yaml @@ -0,0 +1,209 @@ +name: CI/CD (dev on branch, prod on tag) + +on: + push: + branches: + - dev # build & deploy for dev only + tags: + - "*" # build & deploy for prod only when a tag is pushed + +jobs: + build-and-deploy: + # Gitea Actions: runners are selected by label only (no runner groups). + runs-on: ubuntu-latest + + # Per-environment group: a dev push must never cancel an in-flight prod + # deploy. NOTE: act_runner does not support dynamic matrix (fromJSON of a + # job output expands every matrix.* to ""), so per-env config is computed + # in the "Resolve environment config" bash step below instead. + concurrency: + group: deploy-${{ github.ref_type == 'tag' && 'prod' || 'dev' }} + cancel-in-progress: true + + env: + # Harbor on the Mac mini host. The runner pod mounts the Docker Desktop + # daemon socket, so from the daemon's point of view the registry is + # reachable as host.docker.internal:8080 (plain HTTP — the daemon must + # list it under "insecure-registries"). Images live in Harbor's + # "library" project. + REGISTRY: host.docker.internal:8080/library + DOCKER_BUILDKIT: "1" + COMPOSE_DOCKER_CLI_BUILD: "1" + + steps: + - name: Checkout (with tags) + uses: actions/checkout@v4 + with: + fetch-depth: 0 # IMPORTANT to access tags + + # Replaces the former setup job + dynamic matrix (unsupported on + # act_runner). Everything derived from the ref type lands in GITHUB_ENV + # so later steps can use plain $VARS. + - name: Resolve environment config + shell: bash + run: | + if [[ "${{ github.ref_type }}" == "tag" ]]; then + DEPLOY_ENV=prod + RELEASE_TAG="${GITHUB_REF#refs/tags/}" + else + DEPLOY_ENV=dev + RELEASE_TAG="" + fi + { + echo "DEPLOY_ENV=${DEPLOY_ENV}" + echo "RELEASE_TAG=${RELEASE_TAG}" + echo "IMAGE=${REGISTRY}/portal-${DEPLOY_ENV}" + echo "LATEST_TAG=latest-${DEPLOY_ENV}" + echo "RELEASE=portal-${DEPLOY_ENV}" + echo "NAMESPACE=portal-${DEPLOY_ENV}" + echo "CHART=./helm" + echo "VALUES_FILE=./helm/values-${DEPLOY_ENV}.yaml" + } >> "$GITHUB_ENV" + + echo "Resolved environment: ${DEPLOY_ENV} (release tag: '${RELEASE_TAG}')" + + - name: Verify tag is on prod branch (main) + if: github.ref_type == 'tag' + shell: bash + run: | + git fetch origin main --quiet + if git merge-base --is-ancestor "${{ github.sha }}" origin/main; then + echo "Tag commit is on main. Proceeding with prod deploy." + else + echo "::error::Tag ${GITHUB_REF#refs/tags/} points at a commit not on main. Refusing prod deploy." + exit 1 + fi + + # The runner's job image ships docker but not kubectl/helm, so install + # them at job start (static binaries, linux/amd64). + - name: Install kubectl & helm + run: | + if ! command -v kubectl >/dev/null 2>&1; then + KVER=$(curl -sfL https://dl.k8s.io/release/stable.txt) + curl -sfL -o /usr/local/bin/kubectl "https://dl.k8s.io/release/${KVER}/bin/linux/amd64/kubectl" + chmod +x /usr/local/bin/kubectl + fi + if ! command -v helm >/dev/null 2>&1; then + curl -sfL https://get.helm.sh/helm-v3.16.4-linux-amd64.tar.gz | tar xz -C /tmp + mv /tmp/linux-amd64/helm /usr/local/bin/helm + fi + kubectl version --client + helm version + + # Fail fast on chart/template errors before spending time on a build. + - name: Lint Helm chart + run: | + helm lint "${CHART}" -f "${VALUES_FILE}" + + - name: Set up kubeconfig + run: | + echo "KUBECONFIG=${RUNNER_TEMP}/kubeconfig" >> "$GITHUB_ENV" + echo "${{ secrets.KUBE_CONFIG_DATA }}" | base64 -d > "${RUNNER_TEMP}/kubeconfig" + chmod 600 "${RUNNER_TEMP}/kubeconfig" + + - name: Login to Harbor + run: | + # REGISTRY is host/project but `docker login` takes only the host. + REGISTRY_HOST=$(echo "${REGISTRY}" | cut -d'/' -f1) + echo "Logging in to ${REGISTRY_HOST}" + echo "${{ secrets.HARBOR_PASSWORD }}" | docker login "${REGISTRY_HOST}" \ + -u "${{ secrets.HARBOR_USERNAME }}" \ + --password-stdin + + - name: Pre-build diagnostics + run: | + echo "Ref: ${GITHUB_REF}" + echo "Environment: ${DEPLOY_ENV}" + echo "Release tag: ${RELEASE_TAG}" + echo "Image: ${IMAGE}" + docker version + helm version + kubectl version --client + + - name: Build & Push image + run: | + BUILD_TAG_ARGS=( + -t "${IMAGE}:${LATEST_TAG}" + -t "${IMAGE}:${{ github.sha }}" + ) + if [[ -n "${RELEASE_TAG}" ]]; then + BUILD_TAG_ARGS+=( -t "${IMAGE}:${RELEASE_TAG}" ) + fi + + docker build \ + -f Dockerfile \ + "${BUILD_TAG_ARGS[@]}" \ + . + + docker push "${IMAGE}:${LATEST_TAG}" + docker push "${IMAGE}:${{ github.sha }}" + if [[ -n "${RELEASE_TAG}" ]]; then + docker push "${IMAGE}:${RELEASE_TAG}" + fi + + - name: Ensure namespace exists + run: | + # `helm --atomic` against a missing namespace fails outright. + kubectl create namespace "${NAMESPACE}" \ + --dry-run=client -o yaml | kubectl apply -f - + + # The kubelet pulls through the same Docker Desktop daemon that built the + # image, so the pull server must match the push host exactly + # (host.docker.internal:8080). + - name: Ensure Harbor pull secret exists + run: | + kubectl create secret docker-registry harbor-pull-secret \ + --docker-server="$(echo "${REGISTRY}" | cut -d'/' -f1)" \ + --docker-username="${{ secrets.HARBOR_USERNAME }}" \ + --docker-password="${{ secrets.HARBOR_PASSWORD }}" \ + --namespace "${NAMESPACE}" \ + --dry-run=client -o yaml | kubectl apply -f - + + # ---- DEV DEPLOY (branch dev only) ---- + # Deployed by commit SHA, not latest-dev: an immutable tag sidesteps the + # moving-tag + IfNotPresent stale-cache trap and makes `kubectl describe + # pod` show exactly which commit is live. + - name: Deploy DEV with Helm + if: github.ref_type == 'branch' && github.ref == 'refs/heads/dev' + run: | + kubectl get nodes + kubectl get ns + + helm upgrade --install "${RELEASE}" "${CHART}" \ + -f "${VALUES_FILE}" \ + --namespace "${NAMESPACE}" \ + --set server.image.repository="${IMAGE}" \ + --set server.image.tag="${{ github.sha }}" \ + --wait --timeout 10m --atomic --debug + + # ---- PROD DEPLOY (tag push only) ---- + - name: Deploy PROD with Helm + if: github.ref_type == 'tag' + run: | + kubectl get nodes + kubectl get ns + + if [[ -z "${RELEASE_TAG}" ]]; then + echo "No tag detected; aborting prod deploy." + exit 1 + fi + + helm upgrade --install "${RELEASE}" "${CHART}" \ + -f "${VALUES_FILE}" \ + --namespace "${NAMESPACE}" \ + --set server.image.repository="${IMAGE}" \ + --set server.image.tag="${RELEASE_TAG}" \ + --wait --timeout 10m --atomic --debug + + - name: Post-deploy diagnostics (if failure) + if: failure() + run: | + echo "----- Diagnostics -----" + kubectl get deploy,po,svc,ing -n "${NAMESPACE}" -o wide || true + echo "----- Events -----" + kubectl get events -n "${NAMESPACE}" --sort-by=.lastTimestamp || true + for p in $(kubectl get po -n "${NAMESPACE}" -o name); do + echo "### $p" + kubectl describe "$p" -n "${NAMESPACE}" || true + kubectl logs "$p" -n "${NAMESPACE}" --all-containers --tail=200 || true + done diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f93d687 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# env files (can opt-in for committing if needed) +.env* + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts + +# local tooling +/.claude/ diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..af3b7c8 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,9 @@ + + +## This is NOT the Next.js you know + +This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices. + +This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean. + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..02d98c4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# syntax=docker/dockerfile:1 + +# ---- deps: install node_modules from the lockfile ---- +FROM node:24-alpine AS deps +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci + +# ---- builder: produce the standalone Next.js output ---- +FROM node:24-alpine AS builder +WORKDIR /app +ENV NEXT_TELEMETRY_DISABLED=1 +COPY --from=deps /app/node_modules ./node_modules +COPY . . +# public/ may be empty (git does not track empty dirs); the runner stage copies it. +RUN mkdir -p public && npm run build + +# ---- runner: minimal image with only what `node server.js` needs ---- +FROM node:24-alpine AS runner +WORKDIR /app +ENV NODE_ENV=production \ + NEXT_TELEMETRY_DISABLED=1 \ + PORT=3000 \ + HOSTNAME=0.0.0.0 + +RUN addgroup -S -g 1001 nodejs && adduser -S -u 1001 -G nodejs nextjs + +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +COPY --from=builder --chown=nextjs:nodejs /app/public ./public + +USER 1001 +EXPOSE 3000 +CMD ["node", "server.js"] diff --git a/app/favicon.ico b/app/favicon.ico new file mode 100644 index 0000000..af98450 Binary files /dev/null and b/app/favicon.ico differ diff --git a/app/globals.css b/app/globals.css new file mode 100644 index 0000000..ce3477f --- /dev/null +++ b/app/globals.css @@ -0,0 +1,107 @@ +@import "tailwindcss"; + +:root { + --background: #060a14; + --foreground: #e6edf7; + color-scheme: dark; +} + +@theme inline { + --color-background: var(--background); + --color-foreground: var(--foreground); + --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, + "Helvetica Neue", Arial, sans-serif; + --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, + "Liberation Mono", monospace; +} + +html { + scroll-behavior: smooth; +} + +body { + background-color: var(--background); + color: var(--foreground); + font-family: var(--font-sans); + background-image: + radial-gradient(60rem 30rem at 15% -10%, rgb(56 189 248 / 0.14), transparent 60%), + radial-gradient(50rem 30rem at 95% 5%, rgb(129 140 248 / 0.12), transparent 60%), + linear-gradient(rgb(255 255 255 / 0.025) 1px, transparent 1px), + linear-gradient(90deg, rgb(255 255 255 / 0.025) 1px, transparent 1px); + background-size: auto, auto, 48px 48px, 48px 48px; + background-repeat: no-repeat, no-repeat, repeat, repeat; +} + +/* + * Animated "traffic" connector used by the flow diagrams. + * Vertical by default (mobile); turns horizontal from the lg breakpoint. + */ +.flow-line { + --flow-color: #38bdf8; + flex: none; + width: 2px; + height: 2rem; + background-image: linear-gradient(to bottom, var(--flow-color) 0 6px, transparent 6px); + background-size: 2px 10px; + background-repeat: repeat-y; + animation: flow-y 0.9s linear infinite; +} + +@media (min-width: 1024px) { + .flow-line { + width: 2.25rem; + height: 2px; + background-image: linear-gradient(to right, var(--flow-color) 0 6px, transparent 6px); + background-size: 10px 2px; + background-repeat: repeat-x; + animation-name: flow-x; + } +} + +/* Always-vertical variant for hand-offs between stacked boundaries. */ +.flow-line-v { + --flow-color: #38bdf8; + flex: none; + width: 2px; + height: 2rem; + background-image: linear-gradient(to bottom, var(--flow-color) 0 6px, transparent 6px); + background-size: 2px 10px; + background-repeat: repeat-y; + animation: flow-y 0.9s linear infinite; +} + +@keyframes flow-y { + to { + background-position: 0 10px; + } +} + +@keyframes flow-x { + to { + background-position: 10px 0; + } +} + +@keyframes pulse-ring { + 0% { + box-shadow: 0 0 0 0 rgb(52 211 153 / 0.5); + } + 100% { + box-shadow: 0 0 0 10px rgb(52 211 153 / 0); + } +} + +.pulse-ring { + animation: pulse-ring 1.8s ease-out infinite; +} + +@media (prefers-reduced-motion: reduce) { + html { + scroll-behavior: auto; + } + .flow-line, + .flow-line-v, + .pulse-ring { + animation: none; + } +} diff --git a/app/layout.tsx b/app/layout.tsx new file mode 100644 index 0000000..5d810d1 --- /dev/null +++ b/app/layout.tsx @@ -0,0 +1,17 @@ +import type { Metadata } from "next"; +import { profile } from "@/content/site"; +import "./globals.css"; + +export const metadata: Metadata = { + title: `${profile.name} · Portal`, + description: + "Personal portal: an introduction, the architecture and CI/CD workflow of my Kubernetes home lab, and my travel album.", +}; + +export default function RootLayout({ children }: LayoutProps<"/">) { + return ( + + {children} + + ); +} diff --git a/app/page.tsx b/app/page.tsx new file mode 100644 index 0000000..fbda20b --- /dev/null +++ b/app/page.tsx @@ -0,0 +1,66 @@ +import { Header } from "@/components/Header"; +import { Introduction } from "@/components/Introduction"; +import { Section } from "@/components/Section"; +import { Travel } from "@/components/Travel"; +import { CicdFlow } from "@/components/lab/CicdFlow"; +import { RequestFlow } from "@/components/lab/RequestFlow"; +import { ServiceLinks } from "@/components/lab/ServiceLinks"; +import { StackBadges } from "@/components/lab/StackBadges"; + +function SubHeading({ title, children }: { title: string; children?: React.ReactNode }) { + return ( +
+

{title}

+ {children &&

{children}

} +
+ ); +} + +export default function Home() { + return ( + <> + +
+
+ + +
+ + +
+ + DNS is managed at GoDaddy. From there a request passes through the host Nginx and + the cluster ingress before landing on a pod. + + +
+ +
+ + Gitea Actions builds the image on the Docker Desktop daemon, stores it in Harbor and + deploys it with Helm. A branch push goes to dev, a tag goes to prod. + + +
+ +
+ + Live endpoints you can open yourself. + + +
+
+ + +
+
+ Built with Next.js and deployed by the pipeline described above. +
+ + ); +} diff --git a/components/BrandIcon.tsx b/components/BrandIcon.tsx new file mode 100644 index 0000000..7a1c638 --- /dev/null +++ b/components/BrandIcon.tsx @@ -0,0 +1,23 @@ +import type { SimpleIcon } from "simple-icons"; + +export function BrandIcon({ + icon, + className, + color, +}: { + icon: SimpleIcon; + className?: string; + /** Override the brand colour (dark brand colours vanish on a dark theme). */ + color?: string; +}) { + return ( + + ); +} diff --git a/components/CredentialRows.tsx b/components/CredentialRows.tsx new file mode 100644 index 0000000..5c28cce --- /dev/null +++ b/components/CredentialRows.tsx @@ -0,0 +1,18 @@ +import { KeyRound, User } from "lucide-react"; + +export function CredentialRows({ user, password }: { user: string; password: string }) { + return ( +
+
+
+
{user}
+
+
+
{password}
+
+ ); +} diff --git a/components/Header.tsx b/components/Header.tsx new file mode 100644 index 0000000..287de6a --- /dev/null +++ b/components/Header.tsx @@ -0,0 +1,44 @@ +import { profile } from "@/content/site"; + +const links = [ + { href: "#introduction", label: "Introduction" }, + { href: "#lab", label: "The Lab" }, + { href: "#travel", label: "Travel" }, +]; + +export function Header() { + const initials = profile.name + .split(" ") + .map((w) => w[0]) + .join(""); + + return ( +
+
+ + + {initials} + + {profile.name} + + +
+
+ ); +} diff --git a/components/Introduction.tsx b/components/Introduction.tsx new file mode 100644 index 0000000..b368ce1 --- /dev/null +++ b/components/Introduction.tsx @@ -0,0 +1,24 @@ +import { introduction, profile } from "@/content/site"; + +export function Introduction() { + return ( +
+
+

+ Introduction +

+

+ Hi, I'm{" "} + + {profile.name} + +

+
+ {introduction.map((p, i) => ( +

{p}

+ ))} +
+
+
+ ); +} diff --git a/components/Section.tsx b/components/Section.tsx new file mode 100644 index 0000000..e13391f --- /dev/null +++ b/components/Section.tsx @@ -0,0 +1,30 @@ +import type { ReactNode } from "react"; + +export function Section({ + id, + eyebrow, + title, + lead, + children, +}: { + id: string; + eyebrow: string; + title: string; + lead?: ReactNode; + children: ReactNode; +}) { + return ( +
+
+

+ {eyebrow} +

+

+ {title} +

+ {lead &&
{lead}
} +
{children}
+
+
+ ); +} diff --git a/components/Travel.tsx b/components/Travel.tsx new file mode 100644 index 0000000..47f67c6 --- /dev/null +++ b/components/Travel.tsx @@ -0,0 +1,93 @@ +import { ExternalLink, MapPin, Plane } from "lucide-react"; +import { CredentialRows } from "@/components/CredentialRows"; +import { Section } from "@/components/Section"; +import { travel } from "@/content/site"; + +/** Decorative route map: dotted "world" backdrop, a dashed flight path and pins. */ +function RouteArt() { + const pins = [ + { x: 70, y: 150 }, + { x: 170, y: 70 }, + { x: 290, y: 120 }, + { x: 400, y: 50 }, + ]; + return ( + + + + + + + + + + + + + {pins.map((p, i) => ( + + + + + + ))} + + ); +} + +export function Travel() { + return ( +
+
+
+
+ + + +
+ +
+
+

+

+

+ Sign in with the credentials below to browse the album. +

+
+ + {travel.host} + + +
+
+
+
+ ); +} diff --git a/components/flow.tsx b/components/flow.tsx new file mode 100644 index 0000000..d2d9e22 --- /dev/null +++ b/components/flow.tsx @@ -0,0 +1,121 @@ +import type { CSSProperties, ReactNode } from "react"; +import { ChevronDown, ChevronRight } from "lucide-react"; + +/** One box in a flow diagram: icon tile, title, subtitle and a mono detail line. */ +export function FlowNode({ + icon, + title, + subtitle, + detail, + accent, + step, + className = "", +}: { + icon: ReactNode; + title: string; + subtitle?: string; + detail?: string; + /** Hex colour used for the icon tile glow. */ + accent: string; + step?: number; + className?: string; +}) { + return ( +
+ {step !== undefined && ( + + {step} + + )} +
+ {icon} +
+

{title}

+ {subtitle &&

{subtitle}

} + {detail && ( +

+ {detail} +

+ )} +
+ ); +} + +/** + * Animated dashed connector with an arrow head. Vertical on mobile and + * horizontal on lg+, unless `vertical` pins it to a top-to-bottom hand-off. + */ +export function Connector({ + label, + color = "#38bdf8", + vertical = false, +}: { + label?: string; + color?: string; + vertical?: boolean; +}) { + if (vertical) { + return ( + + ); + } + + return ( + + ); +} + +/** Dashed container that groups nodes belonging to the same host / system. */ +export function Boundary({ + label, + icon, + children, + className = "", + tone = "border-white/15", +}: { + label: string; + icon: ReactNode; + children: ReactNode; + className?: string; + tone?: string; +}) { + return ( +
+
+ {icon} + {label} +
+ {children} +
+ ); +} diff --git a/components/lab/CicdFlow.tsx b/components/lab/CicdFlow.tsx new file mode 100644 index 0000000..b24b4c4 --- /dev/null +++ b/components/lab/CicdFlow.tsx @@ -0,0 +1,139 @@ +import { siDocker, siGit, siGitea, siHarbor, siHelm, siKubernetes } from "simple-icons"; +import { GitBranch, ShieldCheck, Tag, Undo2 } from "lucide-react"; +import { BrandIcon } from "@/components/BrandIcon"; +import { Connector, FlowNode } from "@/components/flow"; + +const lanes = [ + { + env: "DEV", + badge: "border-amber-300/40 bg-amber-300/10 text-amber-200", + ring: "border-amber-300/25", + icon: